Package com.priint.pubserver.tracing
Class SessionTracer
java.lang.Object
com.priint.pubserver.tracing.SessionTracer
Tracer for writing session specific trace messages into a persistent data store.
Create a tracer only once in a class.
Tracer tracer = new Tracer("MyDataFunctions");
Use simple or extended signature of methods. You are strongly advised to use message as a template with "{}" for replacement.
Add replacements in open argument list, so that they only get evaluated, when trace is really written and not e.g. for
sessions that do not log.
tracer.info("my message {} {} {}", "eins", new Integer(2), Float.parse("3.0"));
tracer.warnExtended("mysource", "my message for something: {}", "my hint", someObject);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidWrite error to session trace.voiderrorAndLog(String message, Object... argArray) Write error to session trace and server log.voiderrorExtended(String source, String message, String hint, boolean log, Object... argArray) Write an ERROR trace message for a session.voidWrite info to session trace.voidinfoAndLog(String message, Object... argArray) Write info to session trace and to server log.voidinfoExtended(String source, String message, String hint, boolean log, Object... argArray) Write an INFO trace message for a session.booleanisActive()Returns true if trace mode is active for the current session.voidlogAndTrace(TracerMessage.MessageType messageType, String source, String message, String hint, Object... argArray) writes a message to the server log and additionally - if tracing is enabled - writes a trace too.voidWrite warning to session trace.voidwarnAndLog(String message, Object... argArray) Write warning to session trace and server log.voidwarnExtended(String source, String message, String hint, boolean log, Object... argArray) Write an WARNING trace message for a session.
-
Constructor Details
-
SessionTracer
Create a tracer object.- Parameters:
source- Source of tracer (like plugin name and / or method name)
-
-
Method Details
-
info
Write info to session trace.- Parameters:
message- text for trace and logargArray- arguments to be used for replacement in message string- See Also:
-
infoAndLog
Write info to session trace and to server log.- Parameters:
message- text for trace and logargArray- arguments to be used for replacement in message string- See Also:
-
error
Write error to session trace.- Parameters:
message- text for trace and logargArray- arguments to be used for replacement in message string- See Also:
-
errorAndLog
Write error to session trace and server log.- Parameters:
message- text for trace and logargArray- arguments to be used for replacement in message string- See Also:
-
warn
Write warning to session trace.- Parameters:
message- text for trace and logargArray- arguments to be used for replacement in message string- See Also:
-
warnAndLog
Write warning to session trace and server log.- Parameters:
message- text for trace and logargArray- arguments to be used for replacement in message string- See Also:
-
infoExtended
public void infoExtended(String source, String message, String hint, boolean log, Object... argArray) Write an INFO trace message for a session. Analogous to a call to logger.info().For information on the arguments see
TracerMessage.- Parameters:
source- optional module or class and method namemessage- text for trace and loghint- optional information to user what to she can dolog- if true then SessionTracer will also write this message into the server log - at debug levelargArray- arguments to be used for replacement in message string
-
errorExtended
public void errorExtended(String source, String message, String hint, boolean log, Object... argArray) Write an ERROR trace message for a session. Analogous to a call to logger.error().For information on the arguments see
TracerMessage.- Parameters:
source- optional module or class and method namemessage- text for trace and loghint- optional information to user what to she can dolog- if true then SessionTracer will also write this message into the server log - at debug levelargArray- arguments to be used for replacement in message string
-
warnExtended
public void warnExtended(String source, String message, String hint, boolean log, Object... argArray) Write an WARNING trace message for a session. Analogous to a call to logger.warn().For information on the arguments see
TracerMessage.- Parameters:
source- optional module or class and method namemessage- text for trace and loghint- optional information to user what to she can dolog- if true then SessionTracer will also write this message into the server log - at debug levelargArray- arguments to be used for replacement in message string
-
isActive
public boolean isActive()Returns true if trace mode is active for the current session. -
logAndTrace
public void logAndTrace(TracerMessage.MessageType messageType, String source, String message, String hint, Object... argArray) writes a message to the server log and additionally - if tracing is enabled - writes a trace too.log level is tracing level - 1, e.g. trace error = log warn, trace warning = log info, trace info = log debug
- Parameters:
messageType-source-message-hint-argArray-
-