Module aeonics.core

Class Logger

  • All Implemented Interfaces:
    Exportable, Snapshotable

    public abstract class Logger
    extends Manager.Type
    This entity manages the logs of the entire system. From anywhere, just call one of the log() variants. Manager.of(Logger.class).log(...);
    • Constructor Detail

      • Logger

        public Logger()
    • Method Detail

      • manager

        public final java.lang.Class<? extends Manager.Type> manager()
        Hardcoded manager type
        Specified by:
        manager in class Manager.Type
        Returns:
        the type of manager
      • level

        public int level()
        Returns the current log level
        Returns:
        the current log level
      • level

        public void level​(int value)
        Sets the current log level
        Parameters:
        value - the current log level
      • log

        public void log​(int level,
                        java.lang.Class<?> type,
                        java.lang.Object o)
        Log the specified object if the current level is smaller or equal to the specified level. Alias of log(int, Class, String, Object...) with level SEVERE
        Parameters:
        level - the log level for this entry
        type - the class type this log entry relates to
        o - the object to log
      • log

        public void log​(int level,
                        java.lang.Class<?> type,
                        java.lang.Throwable t)
        Log the specified exception if the current level is smaller or equal to the specified level.
        Parameters:
        level - the log level for this entry
        type - the class type this log entry relates to
        t - the exception to log
      • log

        public void log​(int level,
                        java.lang.Class<?> type,
                        java.lang.String message,
                        java.lang.Object... params)
        Log the specified message and optional other parameters if the current level is smaller or equal to the specified level. By convention, the optional parameters are substituted in the message where "{}" is encountered, by order of appearance.
        Parameters:
        level - the log level for this entry
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • log

        public void log​(int level,
                        java.lang.String type,
                        java.lang.Object o)
        Log the specified object if the current level is smaller or equal to the specified level.
        Parameters:
        level - the log level for this entry
        type - the textual context this log entry relates to
        o - the object to log
      • log

        public void log​(int level,
                        java.lang.String type,
                        java.lang.Throwable t)
        Log the specified exception if the current level is smaller or equal to the specified level.
        Parameters:
        level - the log level for this entry
        type - the textual context this log entry relates to
        t - the exception to log
      • log

        public void log​(int level,
                        java.lang.String type,
                        java.lang.String message,
                        java.lang.Object... params)
        Log the specified message and optional other parameters if the current level is smaller or equal to the specified level. By convention, the optional parameters are substituted in the message where "{}" is encountered, by order of appearance.
        Parameters:
        level - the log level for this entry
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • log

        public void log​(int level,
                        java.lang.Class<?> type,
                        java.lang.String message,
                        java.util.function.Supplier<java.lang.Object[]> supplier)
        Log the specified message and optional other parameters if the current level is smaller or equal to the specified level. By convention, the optional parameters are substituted in the message where "{}" is encountered, by order of appearance.
        Parameters:
        level - the log level for this entry
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        supplier - function that provides the optional parameters as an Object[]
      • log

        public void log​(int level,
                        java.lang.String type,
                        java.lang.String message,
                        java.util.function.Supplier<java.lang.Object[]> supplier)
        Log the specified message and optional other parameters if the current level is smaller or equal to the specified level. By convention, the optional parameters are substituted in the message where "{}" is encountered, by order of appearance.
        Parameters:
        level - the log level for this entry
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        supplier - function that provides the optional parameters as an Object[]
      • severe

        public void severe​(java.lang.Class<?> type,
                           java.lang.String message,
                           java.lang.Object... params)
        Parameters:
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • severe

        public void severe​(java.lang.String type,
                           java.lang.String message,
                           java.lang.Object... params)
        Parameters:
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • warning

        public void warning​(java.lang.Class<?> type,
                            java.lang.String message,
                            java.lang.Object... params)
        Parameters:
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • warning

        public void warning​(java.lang.String type,
                            java.lang.String message,
                            java.lang.Object... params)
        Parameters:
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • info

        public void info​(java.lang.Class<?> type,
                         java.lang.String message,
                         java.lang.Object... params)
        Parameters:
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • info

        public void info​(java.lang.String type,
                         java.lang.String message,
                         java.lang.Object... params)
        Parameters:
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • config

        public void config​(java.lang.Class<?> type,
                           java.lang.String message,
                           java.lang.Object... params)
        Parameters:
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • config

        public void config​(java.lang.String type,
                           java.lang.String message,
                           java.lang.Object... params)
        Parameters:
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • fine

        public void fine​(java.lang.Class<?> type,
                         java.lang.String message,
                         java.lang.Object... params)
        Parameters:
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • fine

        public void fine​(java.lang.String type,
                         java.lang.String message,
                         java.lang.Object... params)
        Parameters:
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • finer

        public void finer​(java.lang.Class<?> type,
                          java.lang.String message,
                          java.lang.Object... params)
        Parameters:
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • finer

        public void finer​(java.lang.String type,
                          java.lang.String message,
                          java.lang.Object... params)
        Parameters:
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • finest

        public void finest​(java.lang.Class<?> type,
                           java.lang.String message,
                           java.lang.Object... params)
        Parameters:
        type - the class type this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • finest

        public void finest​(java.lang.String type,
                           java.lang.String message,
                           java.lang.Object... params)
        Parameters:
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • handle

        protected abstract void handle​(int level,
                                       java.lang.String type,
                                       java.lang.String message,
                                       java.lang.Object... params)
        Implementations should override this method for actual logging. This method *should* only be called if the entry log level matches the current level
        Parameters:
        level - the log level for this entry
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
      • toJson

        protected java.lang.String toJson​(int level,
                                          java.lang.String type,
                                          java.lang.String message,
                                          java.lang.Object... params)
        Converts the logging parameters to a JSON string representation by substituting optional parameters in the message. This method is typically called from the handle(int, String, String, Object...) method.
        Parameters:
        level - the log level for this entry
        type - the textual context this log entry relates to
        message - the message to log (substitution placeholder is "{}")
        params - optional additional parameters to log
        Returns:
        the JSON string representation of this log entry
      • bindMessage

        protected java.lang.String bindMessage​(java.lang.String message,
                                               java.lang.Object... params)
        Substitutes {} in the message by the string representation of the parameters provided.
        Parameters:
        message - the input message
        params - the substitution parameters
        Returns:
        the formatted message
      • printStackTrace

        protected java.lang.String printStackTrace​(java.lang.Throwable t)
        Generates a string stack trace that omits all java.* or aeonics.* frames unless the current log level is ALL.
        Parameters:
        t - the exception for which to print the stack trace
        Returns:
        the stack trace