Class Log

java.lang.Object
org.jpos.util.Log
All Implemented Interfaces:
LogSource
Direct Known Subclasses:
BSHRequestListener, Debug, DummyPackager, FSDPackager, IncomingListener, JESpace, JSParticipant

public class Log extends Object implements LogSource
Represents a LogSource and adds several helpers
See Also:
  • Field Details

  • Constructor Details

    • Log

      public Log()
      Default constructor.
    • Log

      public Log(Logger logger, String realm)
      Constructs a Log bound to the given logger and realm.
      Parameters:
      logger - underlying Logger
      realm - realm to associate with emitted events
  • Method Details

    • getLog

      public static Log getLog(String logName, String realm)
      Convenience factory returning a Log bound to the given logger name and realm.
      Parameters:
      logName - name of the Logger to use
      realm - realm to associate with emitted events
      Returns:
      a new Log instance
    • setLogger

      public void setLogger(Logger logger, String realm)
      Replaces the underlying logger and realm.
      Specified by:
      setLogger in interface LogSource
      Parameters:
      logger - underlying Logger
      realm - realm to associate with emitted events
    • getRealm

      public String getRealm()
      Returns the realm associated with events emitted through this Log.
      Specified by:
      getRealm in interface LogSource
      Returns:
      the configured realm
    • getLogger

      public Logger getLogger()
      Returns the underlying logger.
      Specified by:
      getLogger in interface LogSource
      Returns:
      the Logger receiving events from this Log
    • setLogger

      public void setLogger(Logger logger)
      Replaces the underlying logger, leaving the realm unchanged.
      Parameters:
      logger - new Logger
    • setRealm

      public void setRealm(String realm)
      Replaces the realm associated with emitted events.
      Parameters:
      realm - new realm
    • setDefaultTag

      public void setDefaultTag(String key, String value)
      Sets a default tag on every event produced by this Log; a null value removes the entry.
      Parameters:
      key - tag name (ignored if null)
      value - tag value, or null to remove the tag
    • removeDefaultTag

      public void removeDefaultTag(String key)
      Removes a previously-registered default tag.
      Parameters:
      key - tag name (ignored if null)
    • setDefaultTags

      public void setDefaultTags(Map<String,String> tags)
      Replaces the entire set of default tags.
      Parameters:
      tags - new tag set, or null/empty to clear all tags
    • getDefaultTags

      Returns an unmodifiable snapshot of the current default tags.
      Returns:
      a snapshot of the registered default tags
    • applyDefaultTags

      Decorates evt with this Log's default tags, if any.
      Parameters:
      evt - the event to decorate
      Returns:
      the same event (for chaining)
    • trace

      public void trace(Object detail)
      Logs a trace event with the given detail.
      Parameters:
      detail - event payload
    • trace

      public void trace(Object detail, Object obj)
      Logs a trace event with the given detail and an additional payload.
      Parameters:
      detail - event payload
      obj - additional message appended to the event
    • debug

      public void debug(Object detail)
      Logs a debug event with the given detail.
      Parameters:
      detail - event payload
    • debug

      public void debug(Object detail, Object obj)
      Logs a debug event with the given detail and an additional payload.
      Parameters:
      detail - event payload
      obj - additional message appended to the event
    • info

      public void info(Object detail)
      Logs an info event with the given detail.
      Parameters:
      detail - event payload
    • info

      public void info(Object detail, Object obj)
      Logs an info event with the given detail and an additional payload.
      Parameters:
      detail - event payload
      obj - additional message appended to the event
    • warn

      public void warn(Object detail)
      Logs a warning event with the given detail.
      Parameters:
      detail - event payload
    • warn

      public void warn(Object detail, Object obj)
      Logs a warning event with the given detail and an additional payload.
      Parameters:
      detail - event payload
      obj - additional message appended to the event
    • error

      public void error(Object detail)
      Logs an error event with the given detail.
      Parameters:
      detail - event payload
    • error

      public void error(Object detail, Object obj)
      Logs an error event with the given detail and an additional payload.
      Parameters:
      detail - event payload
      obj - additional message appended to the event
    • fatal

      public void fatal(Object detail)
      Logs a fatal event with the given detail.
      Parameters:
      detail - event payload
    • fatal

      public void fatal(Object detail, Object obj)
      Logs a fatal event with the given detail and an additional payload.
      Parameters:
      detail - event payload
      obj - additional message appended to the event
    • createLogEvent

      public LogEvent createLogEvent(String level)
      Creates a new LogEvent at the given level decorated with this Log's default tags.
      Parameters:
      level - event level (one of the TRACE/DEBUG/INFO/WARN/ERROR/FATAL constants)
      Returns:
      a new event ready to be populated and logged
    • createLogEvent

      public LogEvent createLogEvent(String level, Object detail)
      Creates a new LogEvent at the given level with an initial payload.
      Parameters:
      level - event level
      detail - initial event payload
      Returns:
      a new event ready to be populated and logged
    • createTrace

      Creates an empty trace-level event.
      Returns:
      a new LogEvent at the TRACE level
    • createTrace

      public LogEvent createTrace(Object detail)
      Creates a trace-level event with the given payload.
      Parameters:
      detail - initial event payload
      Returns:
      a new LogEvent at the TRACE level
    • createDebug

      Creates an empty debug-level event.
      Returns:
      a new LogEvent at the DEBUG level
    • createDebug

      public LogEvent createDebug(Object detail)
      Creates a debug-level event with the given payload.
      Parameters:
      detail - initial event payload
      Returns:
      a new LogEvent at the DEBUG level
    • createInfo

      public LogEvent createInfo()
      Creates an empty info-level event.
      Returns:
      a new LogEvent at the INFO level
    • createInfo

      public LogEvent createInfo(Object detail)
      Creates an info-level event with the given payload.
      Parameters:
      detail - initial event payload
      Returns:
      a new LogEvent at the INFO level
    • createWarn

      public LogEvent createWarn()
      Creates an empty warning-level event.
      Returns:
      a new LogEvent at the WARN level
    • createWarn

      public LogEvent createWarn(Object detail)
      Creates a warning-level event with the given payload.
      Parameters:
      detail - initial event payload
      Returns:
      a new LogEvent at the WARN level
    • createError

      Creates an empty error-level event.
      Returns:
      a new LogEvent at the ERROR level
    • createError

      public LogEvent createError(Object detail)
      Creates an error-level event with the given payload.
      Parameters:
      detail - initial event payload
      Returns:
      a new LogEvent at the ERROR level
    • createFatal

      Creates an empty fatal-level event.
      Returns:
      a new LogEvent at the FATAL level
    • createFatal

      public LogEvent createFatal(Object detail)
      Creates a fatal-level event with the given payload.
      Parameters:
      detail - initial event payload
      Returns:
      a new LogEvent at the FATAL level