Class Log
- java.lang.Object
-
- com.perforce.p4java.Log
-
public class Log extends java.lang.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
Constructors Constructor Description Log()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
error(java.lang.String errorString, java.lang.Object... args)
Report a P4Java-internal error to the log callback (if it exists).static void
exception(java.lang.Throwable thr)
Report a P4Java-internal unexpected exception to the log callback (if it exists).static ILogCallback
getLogCallback()
static void
info(java.lang.String infoString, java.lang.Object... args)
Report a P4Java-internal informational event to the log callback (if it exists).static boolean
isTracingAtLevel(ILogCallback.LogTraceLevel traceLevel)
static ILogCallback
setLogCallback(ILogCallback logCallback)
Set the P4Java API's internal logger to log to the passed-in ILogCallback log callback.static void
stats(java.lang.String statsString, java.lang.Object... args)
Report a P4Java-internal statistics message to the log callback (if it exists).static void
trace(ILogCallback.LogTraceLevel traceLevel, java.lang.String traceMessage)
Report a P4Java-internal trace message to the log callback (if it exists).static void
warn(java.lang.String warnString, java.lang.Object... args)
Report a P4Java-internal warning to the log callback (if it exists).
-
-
-
Method Detail
-
getLogCallback
public static ILogCallback getLogCallback()
- Returns:
- 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(java.lang.String errorString, java.lang.Object... args)
Report a P4Java-internal error to the log callback (if it exists).- Parameters:
errorString
- non-null error string.args
- args
-
warn
public static void warn(java.lang.String warnString, java.lang.Object... args)
Report a P4Java-internal warning to the log callback (if it exists).- Parameters:
warnString
- non-null warning message.args
- args
-
info
public static void info(java.lang.String infoString, java.lang.Object... args)
Report a P4Java-internal informational event to the log callback (if it exists).- Parameters:
infoString
- non-null info message.args
- args
-
stats
public static void stats(java.lang.String statsString, java.lang.Object... args)
Report a P4Java-internal statistics message to the log callback (if it exists).- Parameters:
statsString
- non-null stats message.args
- args
-
exception
public static void exception(java.lang.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, java.lang.String traceMessage)
Report a P4Java-internal trace message to the log callback (if it exists).- Parameters:
traceLevel
- traceLeveltraceMessage
- traceMessage
-
isTracingAtLevel
public static boolean isTracingAtLevel(ILogCallback.LogTraceLevel traceLevel)
- Parameters:
traceLevel
- traceLevel- Returns:
- true if the
-
-