Class SessionTracer

java.lang.Object
com.priint.pubserver.tracing.SessionTracer

public class SessionTracer extends Object
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 Details

    • SessionTracer

      public SessionTracer(String source)
      Create a tracer object.
      Parameters:
      source - Source of tracer (like plugin name and / or method name)
  • Method Details

    • info

      public void info(String message, Object... argArray)
      Write info to session trace.
      Parameters:
      message - text for trace and log
      argArray - arguments to be used for replacement in message string
      See Also:
    • infoAndLog

      public void infoAndLog(String message, Object... argArray)
      Write info to session trace and to server log.
      Parameters:
      message - text for trace and log
      argArray - arguments to be used for replacement in message string
      See Also:
    • error

      public void error(String message, Object... argArray)
      Write error to session trace.
      Parameters:
      message - text for trace and log
      argArray - arguments to be used for replacement in message string
      See Also:
    • errorAndLog

      public void errorAndLog(String message, Object... argArray)
      Write error to session trace and server log.
      Parameters:
      message - text for trace and log
      argArray - arguments to be used for replacement in message string
      See Also:
    • warn

      public void warn(String message, Object... argArray)
      Write warning to session trace.
      Parameters:
      message - text for trace and log
      argArray - arguments to be used for replacement in message string
      See Also:
    • warnAndLog

      public void warnAndLog(String message, Object... argArray)
      Write warning to session trace and server log.
      Parameters:
      message - text for trace and log
      argArray - 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 name
      message - text for trace and log
      hint - optional information to user what to she can do
      log - if true then SessionTracer will also write this message into the server log - at debug level
      argArray - 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 name
      message - text for trace and log
      hint - optional information to user what to she can do
      log - if true then SessionTracer will also write this message into the server log - at debug level
      argArray - 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 name
      message - text for trace and log
      hint - optional information to user what to she can do
      log - if true then SessionTracer will also write this message into the server log - at debug level
      argArray - 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 -