Class CategoryLogger.DelegateLogger

java.lang.Object
org.djutils.logger.CategoryLogger.DelegateLogger
Enclosing class:
CategoryLogger

public static final class CategoryLogger.DelegateLogger extends Object
DelegateLogger class that takes care of actually logging the message and/or exception.

Copyright (c) 2003-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUTILS License.

Author:
Alexander Verbraeck
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    DelegateLogger(org.slf4j.Logger slf4jLogger)
    Create a DelegateLogger with DelegateLogger as the only class to hide from the call stack.
    protected
    DelegateLogger(org.slf4j.Logger slf4jLogger, Class<?> callerBoundary, boolean log)
    Create a DelegateLogger with a class that indicates what to hide in the call stack.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addFormatter(String find, Supplier<String> replaceSupplier)
    Add a find-replace formatter on the delegate logger for this delegate logger.
    void
    debug(Object object)
    Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
    void
    debug(String message)
    Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
    void
    debug(String message, Object... arguments)
    Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
    void
    debug(Throwable throwable)
    Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
    void
    debug(Throwable throwable, String message)
    Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
    void
    debug(Throwable throwable, String message, Object... arguments)
    Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
    protected void
    Carry out the callback.
    void
    error(Object object)
    Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
    void
    error(String message)
    Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
    void
    error(String message, Object... arguments)
    Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
    void
    error(Throwable throwable)
    Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
    void
    error(Throwable throwable, String message)
    Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
    void
    error(Throwable throwable, String message, Object... arguments)
    Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
    void
    info(Object object)
    Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
    void
    info(String message)
    Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
    void
    info(String message, Object... arguments)
    Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
    void
    info(Throwable throwable)
    Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
    void
    info(Throwable throwable, String message)
    Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
    void
    info(Throwable throwable, String message, Object... arguments)
    Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
    protected void
    mdc()
    Apply the formatter suppliers to the mdc context.
    void
    Remove a find-replace formatter on the delegate logger for this delegate logger.
    void
    Set the callback.
    void
    trace(Object object)
    Create a debug log entry that will be output if TRACE is enabled for this DelegateLogger.
    void
    trace(String message)
    Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
    void
    trace(String message, Object... arguments)
    Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
    void
    trace(Throwable throwable)
    Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
    void
    trace(Throwable throwable, String message)
    Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
    void
    trace(Throwable throwable, String message, Object... arguments)
    Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
    void
    warn(Object object)
    Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
    void
    warn(String message)
    Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
    void
    warn(String message, Object... arguments)
    Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
    void
    warn(Throwable throwable)
    Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
    void
    warn(Throwable throwable, String message)
    Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
    void
    warn(Throwable throwable, String message, Object... arguments)
    Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
    when(boolean condition)
    The conditional filter that will result in the usage of a DelegateLogger.
    The conditional filter that will result in the usage of a DelegateLogger.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DelegateLogger

      protected DelegateLogger(org.slf4j.Logger slf4jLogger, Class<?> callerBoundary, boolean log)
      Create a DelegateLogger with a class that indicates what to hide in the call stack.
      Parameters:
      slf4jLogger - the logger facade from slf4j, can be null in case no logging is done
      callerBoundary - class that defines what to hide in the call stack
      log - whether we should log or not (the NO_LOGGER does not log)
    • DelegateLogger

      protected DelegateLogger(org.slf4j.Logger slf4jLogger)
      Create a DelegateLogger with DelegateLogger as the only class to hide from the call stack.
      Parameters:
      slf4jLogger - the logger facade from slf4j, can be null in case no logging is done
  • Method Details

    • when

      public CategoryLogger.DelegateLogger when(boolean condition)
      The conditional filter that will result in the usage of a DelegateLogger.
      Parameters:
      condition - the condition that should be evaluated
      Returns:
      the logger that further processes logging (DelegateLogger)
    • when

      The conditional filter that will result in the usage of a DelegateLogger.
      Parameters:
      supplier - the function evaluating the condition
      Returns:
      the logger that further processes logging (DelegateLogger)
    • addFormatter

      public void addFormatter(String find, Supplier<String> replaceSupplier)
      Add a find-replace formatter on the delegate logger for this delegate logger.
      Parameters:
      find - the string to find in the pattern
      replaceSupplier - the supplier for the replacement string
    • removeFormatter

      public void removeFormatter(String find)
      Remove a find-replace formatter on the delegate logger for this delegate logger.
      Parameters:
      find - the string to find in the pattern
    • mdc

      protected void mdc()
      Apply the formatter suppliers to the mdc context.
    • setCallback

      public void setCallback(Runnable callback)
      Set the callback.
      Parameters:
      callback - the callback runnable
    • doCallback

      protected void doCallback()
      Carry out the callback.
    • trace

      public void trace(Object object)
      Create a debug log entry that will be output if TRACE is enabled for this DelegateLogger.
      Parameters:
      object - the result of the toString() method of object will be logged
    • trace

      public void trace(String message)
      Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
      Parameters:
      message - the message to log
    • trace

      public void trace(String message, Object... arguments)
      Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
      Parameters:
      message - the message to be logged, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • trace

      public void trace(Throwable throwable)
      Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
    • trace

      public void trace(Throwable throwable, String message)
      Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
      message - the message to log
    • trace

      public void trace(Throwable throwable, String message, Object... arguments)
      Create a trace log entry that will be output if TRACE is enabled for this DelegateLogger.
      Parameters:
      throwable - the exception to log
      message - the message to log, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • debug

      public void debug(Object object)
      Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
      Parameters:
      object - the result of the toString() method of object will be logged
    • debug

      public void debug(String message)
      Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
      Parameters:
      message - the message to log
    • debug

      public void debug(String message, Object... arguments)
      Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
      Parameters:
      message - the message to be logged, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • debug

      public void debug(Throwable throwable)
      Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
    • debug

      public void debug(Throwable throwable, String message)
      Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
      message - the message to log
    • debug

      public void debug(Throwable throwable, String message, Object... arguments)
      Create a debug log entry that will be output if DEBUG is enabled for this DelegateLogger.
      Parameters:
      throwable - the exception to log
      message - the message to log, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • info

      public void info(Object object)
      Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
      Parameters:
      object - the result of the toString() method of object will be logged
    • info

      public void info(String message)
      Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
      Parameters:
      message - the message to log
    • info

      public void info(String message, Object... arguments)
      Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
      Parameters:
      message - the message to be logged, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • info

      public void info(Throwable throwable)
      Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
    • info

      public void info(Throwable throwable, String message)
      Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
      message - the message to log
    • info

      public void info(Throwable throwable, String message, Object... arguments)
      Create a info log entry that will be output if INFO is enabled for this DelegateLogger.
      Parameters:
      throwable - the exception to log
      message - the message to log, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • warn

      public void warn(Object object)
      Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
      Parameters:
      object - the result of the toString() method of object will be logged
    • warn

      public void warn(String message)
      Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
      Parameters:
      message - the message to log
    • warn

      public void warn(String message, Object... arguments)
      Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
      Parameters:
      message - the message to be logged, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • warn

      public void warn(Throwable throwable)
      Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
    • warn

      public void warn(Throwable throwable, String message)
      Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
      message - the message to log
    • warn

      public void warn(Throwable throwable, String message, Object... arguments)
      Create a warn log entry that will be output if WARN is enabled for this DelegateLogger.
      Parameters:
      throwable - the exception to log
      message - the message to log, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • error

      public void error(Object object)
      Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
      Parameters:
      object - the result of the toString() method of object will be logged
    • error

      public void error(String message)
      Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
      Parameters:
      message - the message to log
    • error

      public void error(String message, Object... arguments)
      Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
      Parameters:
      message - the message to be logged, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string
    • error

      public void error(Throwable throwable)
      Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
    • error

      public void error(Throwable throwable, String message)
      Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
      Parameters:
      throwable - the throwable to log
      message - the message to log
    • error

      public void error(Throwable throwable, String message, Object... arguments)
      Create a error log entry that will be output if ERROR is enabled for this DelegateLogger.
      Parameters:
      throwable - the exception to log
      message - the message to log, where {} entries will be replaced by arguments
      arguments - the arguments to substitute for the {} entries in the message string