com.perforce.p4java
Class Log

java.lang.Object
  extended by com.perforce.p4java.Log

public class Log
extends Object

Simple P4Java-wide logger class based on the ILogCallback callback interface. Useful for letting P4Java consumers report errors, warnings, etc., generated within P4Java into their own logs.

Note that absolutely no guarantees or specifications are made about the format or content of strings that are passed through the logging mechanism, but in general all such strings are useful for Perforce support staff, and many info and stats strings passed to the callback may be generally useful for API consumers.

The Log class is itself used from within P4Java to report log messages; the intention here is to allow consumers to call the setLogCallback static method with a suitable log listener that the P4Java API will log to internally. Most of the methods below besides the setLogCallback method are mainly intended for API-internal use, but participating apps may find the other methods useful for interpolating marker text or other messages to the API's log.


Constructor Summary
Log()
           
 
Method Summary
static void error(String errorString)
          Report a P4Java-internal error to the log callback (if it exists).
static void exception(Throwable thr)
          Report a P4Java-internal unexpected exception to the log callback (if it exists).
static ILogCallback getLogCallback()
          Get the current log callback, if any.
static void info(String infoString)
          Report a P4Java-internal informational event to the log callback (if it exists).
static boolean isTracingAtLevel(ILogCallback.LogTraceLevel traceLevel)
          Return true if the
static ILogCallback setLogCallback(ILogCallback logCallback)
          Set the P4Java API's internal logger to log to the passed-in ILogCallback log callback.
static void stats(String statsString)
          Report a P4Java-internal statistics message to the log callback (if it exists).
static void trace(ILogCallback.LogTraceLevel traceLevel, String traceMessage)
          Report a P4Java-internal trace message to the log callback (if it exists).
static void warn(String warnString)
          Report a P4Java-internal warning to the log callback (if it exists).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log

public Log()
Method Detail

getLogCallback

public static ILogCallback getLogCallback()
Get the current log callback, if any. May return null.


setLogCallback

public static ILogCallback setLogCallback(ILogCallback logCallback)
Set the P4Java API's internal logger to log to the passed-in ILogCallback log callback. If the passed-in parameter is null, no logging will be performed. The caller is responsible for ensuring that there are not thread issues with the passed-in callback, and that callbacks to the callback object will not block or deadlock.

Parameters:
logCallback - callback to be used by P4Java to report log messages to; if null, stop logging.
Returns:
the previous callback registered, or null if no such callback existed.

error

public static void error(String errorString)
Report a P4Java-internal error to the log callback (if it exists).

Parameters:
errorString - non-null error string.

warn

public static void warn(String warnString)
Report a P4Java-internal warning to the log callback (if it exists).

Parameters:
warnString - non-null warning message.

info

public static void info(String infoString)
Report a P4Java-internal informational event to the log callback (if it exists).

Parameters:
infoString - non-null info message.

stats

public static void stats(String statsString)
Report a P4Java-internal statistics message to the log callback (if it exists).

Parameters:
statsString - non-null stats message.

exception

public static void exception(Throwable thr)
Report a P4Java-internal unexpected exception to the log callback (if it exists).

Parameters:
thr - non-null Throwable

trace

public static void trace(ILogCallback.LogTraceLevel traceLevel,
                         String traceMessage)
Report a P4Java-internal trace message to the log callback (if it exists).


isTracingAtLevel

public static boolean isTracingAtLevel(ILogCallback.LogTraceLevel traceLevel)
Return true if the

Parameters:
traceLevel -
Returns:


Copyright © 2015 Perforce Software. All Rights Reserved.