Class StandardLogger

java.lang.Object
org.omegazero.common.logging.StandardLogger
All Implemented Interfaces:
Logger

public final class StandardLogger extends Object implements Logger
The standard Logger implementation returned by Logger.create().
Since:
2.10
  • Field Details

    • ENABLE_ST_CLASS_SOURCE

      public static final boolean ENABLE_ST_CLASS_SOURCE
      System property org.omegazero.common.logging.stackTraces.classSource

      Enables logging of the source directory or JAR file of the class in each stack frame in stack traces.

      Default: true

      Since:
      2.11.0
    • ENABLE_ST_CLASS_SOURCE_FULL

      public static final boolean ENABLE_ST_CLASS_SOURCE_FULL
      System property org.omegazero.common.logging.stackTraces.classSourceFull

      If ENABLE_ST_CLASS_SOURCE is true, enables logging of the full source path, instead of just the file name.

      Default: false

      Since:
      2.11.0
    • ENABLE_XST_VERBOSE

      public static final boolean ENABLE_XST_VERBOSE
      System property org.omegazero.common.logging.stackTraces.xstVerbose

      Enables verbose logging of stack frames using the co.paralleluniverse:extended-stacktrace library, if available.

      Default: false

      Since:
      2.11.0
  • Method Details

    • printStackTrace

      public static void printStackTrace(Throwable throwable, Consumer<String> println)
      Prints a stack trace of the given throwable to the given Consumer. Used by this StandardLogger to print stack traces.

      The consumer is called for each line output.

      This method has an output format similar to Throwable.printStackTrace(). It also attempts to find and output additional information about each stack frame, for example the source directory or JAR file of the class file. This behavior may be configured using system properties defined in this class, for example ENABLE_ST_CLASS_SOURCE.

      Parameters:
      throwable - The Throwable
      println - The output consumer
    • log

      public void log(LogLevel level, Object... obj)
      Description copied from interface: Logger
      Constructs a log message from the given objects and outputs it at the given log level.
      Specified by:
      log in interface Logger
      Parameters:
      level - The log level to output this message at
      obj - The objects to construct a log message from, usually strings
    • getLabel

      public String getLabel()
      Returns the label used to identify this Logger in log messages.

      This is the short name of the class this StandardLogger is bound to.

      Specified by:
      getLabel in interface Logger
      Returns:
      The label
    • isLogging

      public boolean isLogging(LogLevel level)
      Description copied from interface: Logger
      Checks if this Logger prints log messages, taking into account the configured log level and other logger settings.
      Specified by:
      isLogging in interface Logger
      Parameters:
      level - The log level to check
      Returns:
      true if this logger prints log messages on the given log level
      See Also:
    • getFullClassName

      public String getFullClassName()
      Returns the full name of the class this StandardLogger is bound to.
      Returns:
      The full class name
      Since:
      2.5