Class DefaultLogger

  • All Implemented Interfaces:
    Logger

    public class DefaultLogger
    extends Object
    implements Logger

    Logger default implementation without cdi

    Since:
    1.1.0
    Author:
    mark.petrenyi
    • Method Detail

      • getLogger

        public static Logger getLogger​(Class<?> clazz)
        Construct a new DefaultLogger instance.
        Parameters:
        clazz - the logger category class
        Returns:
        the logger
      • getLogger

        public static Logger getLogger​(String name)
        Construct a new Logger instance.
        Parameters:
        name - the logger category name
        Returns:
        the logger
      • setLogger

        public void setLogger​(Logger logger)

        setLogger.

        Specified by:
        setLogger in interface Logger
        Parameters:
        logger - Logger instance
      • trace

        public void trace​(String msg)
        Log a message at the TRACE level.
        Specified by:
        trace in interface Logger
        Parameters:
        msg - the message string to be logged
      • trace

        public void trace​(String format,
                          Object... arguments)
        Log a message at the TRACE level according to the specified format and arguments.

        This form avoids superfluous string concatenation when the logger is disabled for the TRACE level. However, this variant incurs the hidden (and relatively small) cost of creating an Object[] before invoking the method, even if this logger is disabled for TRACE.

        Specified by:
        trace in interface Logger
        Parameters:
        format - the format string
        arguments - a list of 3 or more arguments
      • trace

        public void trace​(String msg,
                          Throwable t)
        Log an exception (throwable) at the TRACE level with an accompanying message.
        Specified by:
        trace in interface Logger
        Parameters:
        msg - the message accompanying the exception
        t - the exception (throwable) to log
      • isTraceEnabled

        public boolean isTraceEnabled()
        Is the logger instance enabled for the TRACE level?
        Specified by:
        isTraceEnabled in interface Logger
        Returns:
        True if this Logger is enabled for the TRACE level, false otherwise.
      • debug

        public void debug​(String msg)
        Log a message at the DEBUG level.
        Specified by:
        debug in interface Logger
        Parameters:
        msg - the message string to be logged
      • debug

        public void debug​(String format,
                          Object... arguments)
        Log a message at the DEBUG level according to the specified format and arguments.

        This form avoids superfluous string concatenation when the logger is disabled for the DEBUG level. However, this variant incurs the hidden (and relatively small) cost of creating an Object[] before invoking the method, even if this logger is disabled for DEBUG.

        Specified by:
        debug in interface Logger
        Parameters:
        format - the format string
        arguments - a list of 3 or more arguments
      • debug

        public void debug​(String msg,
                          Throwable t)
        Log an exception (throwable) at the DEBUG level with an accompanying message.
        Specified by:
        debug in interface Logger
        Parameters:
        msg - the message accompanying the exception
        t - the exception (throwable) to log
      • isDebugEnabled

        public boolean isDebugEnabled()
        Is the logger instance enabled for the DEBUG level?
        Specified by:
        isDebugEnabled in interface Logger
        Returns:
        True if this Logger is enabled for the DEBUG level, false otherwise.
      • info

        public void info​(String msg)
        Log a message at the INFO level.
        Specified by:
        info in interface Logger
        Parameters:
        msg - the message string to be logged
      • info

        public void info​(String format,
                         Object... arguments)
        Log a message at the INFO level according to the specified format and arguments.

        This form avoids superfluous string concatenation when the logger is disabled for the INFO level. However, this variant incurs the hidden (and relatively small) cost of creating an Object[] before invoking the method, even if this logger is disabled for INFO.

        Specified by:
        info in interface Logger
        Parameters:
        format - the format string
        arguments - a list of 3 or more arguments
      • info

        public void info​(String msg,
                         Throwable t)
        Log an exception (throwable) at the INFO level with an accompanying message.
        Specified by:
        info in interface Logger
        Parameters:
        msg - the message accompanying the exception
        t - the exception (throwable) to log
      • isInfoEnabled

        public boolean isInfoEnabled()
        Is the logger instance enabled for the INFO level?
        Specified by:
        isInfoEnabled in interface Logger
        Returns:
        True if this Logger is enabled for the INFO level, false otherwise.
      • warn

        public void warn​(String msg)
        Log a message at the WARN level.
        Specified by:
        warn in interface Logger
        Parameters:
        msg - the message string to be logged
      • warn

        public void warn​(String format,
                         Object... arguments)
        Log a message at the WARN level according to the specified format and arguments.

        This form avoids superfluous string concatenation when the logger is disabled for the WARN level. However, this variant incurs the hidden (and relatively small) cost of creating an Object[] before invoking the method, even if this logger is disabled for WARN.

        Specified by:
        warn in interface Logger
        Parameters:
        format - the format string
        arguments - a list of 3 or more arguments
      • warn

        public void warn​(String msg,
                         Throwable t)
        Log an exception (throwable) at the WARN level with an accompanying message.
        Specified by:
        warn in interface Logger
        Parameters:
        msg - the message accompanying the exception
        t - the exception (throwable) to log
      • error

        public void error​(String msg)
        Log a message at the ERROR level.
        Specified by:
        error in interface Logger
        Parameters:
        msg - the message string to be logged
      • error

        public void error​(String format,
                          Object... arguments)
        Log a message at the ERROR level according to the specified format and arguments.

        This form avoids superfluous string concatenation when the logger is disabled for the ERROR level. However, this variant incurs the hidden (and relatively small) cost of creating an Object[] before invoking the method, even if this logger is disabled for ERROR.

        Specified by:
        error in interface Logger
        Parameters:
        format - the format string
        arguments - a list of 3 or more arguments
      • error

        public void error​(String msg,
                          Throwable t)
        Log an exception (throwable) at the ERROR level with an accompanying message.
        Specified by:
        error in interface Logger
        Parameters:
        msg - the message accompanying the exception
        t - the exception (throwable) to log