Class Logger


  • public abstract class Logger
    extends Object
    Logging API.
    Since:
    20.06
    Author:
    Aleks Seovic 2020.05.18
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALWAYS
      Severity 0 will always be logged.
      static int CONFIG
      Severity 4 indicates configuration related log message.
      static int ERROR
      Severity 1 indicates an error.
      static int FINE
      Severity 5 indicates an essential debug message.
      static int FINER
      Severity 6 indicates a non-essential debug message.
      static int FINEST
      Severity 7 indicates a very low-level, non-essential debug message or a tracing message.
      static int INFO
      Severity 3 indicates information that should likely be logged.
      static int WARNING
      Severity 2 indicates a warning.
    • Constructor Summary

      Constructors 
      Constructor Description
      Logger()  
    • Field Detail

      • ALWAYS

        public static final int ALWAYS
        Severity 0 will always be logged.
        See Also:
        Constant Field Values
      • WARNING

        public static final int WARNING
        Severity 2 indicates a warning.
        See Also:
        Constant Field Values
      • INFO

        public static final int INFO
        Severity 3 indicates information that should likely be logged.
        See Also:
        Constant Field Values
      • CONFIG

        public static final int CONFIG
        Severity 4 indicates configuration related log message.
        See Also:
        Constant Field Values
      • FINE

        public static final int FINE
        Severity 5 indicates an essential debug message.
        See Also:
        Constant Field Values
      • FINER

        public static final int FINER
        Severity 6 indicates a non-essential debug message.
        See Also:
        Constant Field Values
      • FINEST

        public static final int FINEST
        Severity 7 indicates a very low-level, non-essential debug message or a tracing message.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Logger

        public Logger()
    • Method Detail

      • isEnabled

        public static boolean isEnabled​(int nSeverity)
        Return true if the specified severity level should be logged.
        Parameters:
        nSeverity - the severity level
        Returns:
        true if the specified severity level should be logged; false otherwise
      • log

        public static void log​(String sMessage,
                               int nSeverity)
        Log the specified message at the specified severity level.
        Parameters:
        sMessage - the message to log
        nSeverity - the severity level
      • log

        public static void log​(Supplier<String> supplierMessage,
                               int nSeverity)
        Log the specified message at the specified severity level. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        nSeverity - the severity level
      • log

        public static void log​(String sMessage,
                               Throwable e,
                               int nSeverity)
        Log the specified message and the exception stack trace at the specified severity level.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
        nSeverity - the severity level
      • log

        public static void log​(Supplier<String> supplierMessage,
                               Throwable e,
                               int nSeverity)
        Log the specified message and the exception stack trace at the specified severity level. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
        nSeverity - the severity level
      • log

        public static void log​(Throwable e,
                               int nSeverity)
        Log the specified exception information (message and stack trace) at the specified severity level.
        Parameters:
        e - the exception to log
        nSeverity - the severity level
      • out

        public static void out​(String sMessage)
        Log the specified message with ALWAYS severity.
        Parameters:
        sMessage - the message to log
      • out

        public static void out​(Supplier<String> supplierMessage)
        Log the specified message with ALWAYS severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
      • out

        public static void out​(String sMessage,
                               Throwable e)
        Log the specified message and the exception stack trace with ALWAYS severity.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
      • out

        public static void out​(Supplier<String> supplierMessage,
                               Throwable e)
        Log the specified message and the exception stack trace with ALWAYS severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
      • out

        public static void out​(Throwable e)
        Log the specified exception information (message and stack trace) with ALWAYS severity.
        Parameters:
        e - the exception to log
      • err

        public static void err​(String sMessage)
        Log the specified message with ERROR severity.
        Parameters:
        sMessage - the message to log
      • err

        public static void err​(Supplier<String> supplierMessage)
        Log the specified message with ERROR severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
      • err

        public static void err​(String sMessage,
                               Throwable e)
        Log the specified message and the exception stack trace with ERROR severity.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
      • err

        public static void err​(Supplier<String> supplierMessage,
                               Throwable e)
        Log the specified message and the exception stack trace with ERROR severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
      • err

        public static void err​(Throwable e)
        Log the specified exception information (message and stack trace) with ERROR severity.
        Parameters:
        e - the exception to log
      • warn

        public static void warn​(String sMessage)
        Log the specified message with WARNING severity.
        Parameters:
        sMessage - the message to log
      • warn

        public static void warn​(Supplier<String> supplierMessage)
        Log the specified message with WARNING severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
      • warn

        public static void warn​(String sMessage,
                                Throwable e)
        Log the specified message and the exception stack trace with WARNING severity.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
      • warn

        public static void warn​(Supplier<String> supplierMessage,
                                Throwable e)
        Log the specified message and the exception stack trace with WARNING severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
      • warn

        public static void warn​(Throwable e)
        Log the specified exception information (message and stack trace) with WARNING severity.
        Parameters:
        e - the exception to log
      • info

        public static void info​(String sMessage)
        Log the specified message with INFO severity.
        Parameters:
        sMessage - the message to log
      • info

        public static void info​(Supplier<String> supplierMessage)
        Log the specified message with INFO severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
      • info

        public static void info​(String sMessage,
                                Throwable e)
        Log the specified message and the exception stack trace with INFO severity.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
      • info

        public static void info​(Supplier<String> supplierMessage,
                                Throwable e)
        Log the specified message and the exception stack trace with INFO severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
      • info

        public static void info​(Throwable e)
        Log the specified exception information (message and stack trace) with INFO severity.
        Parameters:
        e - the exception to log
      • config

        public static void config​(String sMessage)
        Log the specified message with CONFIG severity.
        Parameters:
        sMessage - the message to log
      • config

        public static void config​(Supplier<String> supplierMessage)
        Log the specified message with CONFIG severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
      • config

        public static void config​(String sMessage,
                                  Throwable e)
        Log the specified message and the exception stack trace with CONFIG severity.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
      • config

        public static void config​(Supplier<String> supplierMessage,
                                  Throwable e)
        Log the specified message and the exception stack trace with CONFIG severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
      • config

        public static void config​(Throwable e)
        Log the specified exception information (message and stack trace) with CONFIG severity.
        Parameters:
        e - the exception to log
      • fine

        public static void fine​(String sMessage)
        Log the specified message with FINE severity.
        Parameters:
        sMessage - the message to log
      • fine

        public static void fine​(Supplier<String> supplierMessage)
        Log the specified message with FINE severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
      • fine

        public static void fine​(String sMessage,
                                Throwable e)
        Log the specified message and the exception stack trace with FINE severity.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
      • fine

        public static void fine​(Supplier<String> supplierMessage,
                                Throwable e)
        Log the specified message and the exception stack trace with FINE severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
      • fine

        public static void fine​(Throwable e)
        Log the specified exception information (message and stack trace) with FINE severity.
        Parameters:
        e - the exception to log
      • finer

        public static void finer​(String sMessage)
        Log the specified message with FINER severity.
        Parameters:
        sMessage - the message to log
      • finer

        public static void finer​(Supplier<String> supplierMessage)
        Log the specified message with FINER severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
      • finer

        public static void finer​(String sMessage,
                                 Throwable e)
        Log the specified message and the exception stack trace with FINER severity.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
      • finer

        public static void finer​(Supplier<String> supplierMessage,
                                 Throwable e)
        Log the specified message and the exception stack trace with FINER severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
      • finer

        public static void finer​(Throwable e)
        Log the specified exception information (message and stack trace) with FINER severity.
        Parameters:
        e - the exception to log
      • finest

        public static void finest​(String sMessage)
        Log the specified message with FINEST severity.
        Parameters:
        sMessage - the message to log
      • finest

        public static void finest​(Supplier<String> supplierMessage)
        Log the specified message with FINEST severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
      • finest

        public static void finest​(String sMessage,
                                  Throwable e)
        Log the specified message and the exception stack trace with FINEST severity.
        Parameters:
        sMessage - the message to log
        e - the exception to log the stack trace for
      • finest

        public static void finest​(Supplier<String> supplierMessage,
                                  Throwable e)
        Log the specified message and the exception stack trace with FINEST severity. The message is provided by the Supplier, which will only be evaluated if the messages should be logged at the specified severity level. This avoids potentially expensive message construction if the message isn't going to be logged.
        Parameters:
        supplierMessage - the supplier of the message to log; only evaluated if the specified severity level should be logged
        e - the exception to log the stack trace for
      • finest

        public static void finest​(Throwable e)
        Log the specified exception information (message and stack trace) with FINEST severity.
        Parameters:
        e - the exception to log
      • entering

        public static void entering​(Class<?> clz,
                                    String sMethod,
                                    Object... params)
        Entry logging.
        Parameters:
        clz - the source Class
        sMethod - the source method
        params - zero or more parameters to log
        Throws:
        NullPointerException - if either clz or sMethod are null
        Since:
        22.06
      • exiting

        public static void exiting​(Class<?> clz,
                                   String sMethod)
        Exit logging.
        Parameters:
        clz - the source Class
        sMethod - the source method
        Throws:
        NullPointerException - if either clz or sMethod are null
        Since:
        22.06
      • exiting

        public static void exiting​(Class<?> clz,
                                   String sMethod,
                                   Object result,
                                   Object... additionalInfo)
        Exit logging.
        Parameters:
        clz - the source Class
        sMethod - the source method
        result - the result returned by the exiting method
        additionalInfo - zero or more additional state details at the time of exit
        Throws:
        NullPointerException - if either clz or sMethod are null
        Since:
        22.06
      • throwing

        public static void throwing​(Class<?> clz,
                                    String sMethod,
                                    Throwable throwable,
                                    Object... additionalInfo)
        Throwable logging.
        Parameters:
        clz - the source Class
        sMethod - the source method
        throwable - the Exception being thrown
        additionalInfo - zero or more additional state details at the time of exit
        Throws:
        NullPointerException - if any arguments are null
        Since:
        22.06
      • setLoggingLevel

        public static void setLoggingLevel​(int nSeverity)
        Set the logging level.
        Parameters:
        nSeverity - the severity level
        Since:
        22.09