Class Log


  • public class Log
    extends java.lang.Object
    Aether Logger - powerful logging system with context support, filtering and formatting. Main features: - Logging with levels (TRACE, DEBUG, INFO, WARN, ERROR) - Contextual logging with automatic lifecycle management - Log filtering by various criteria - Colored console output support - Wrappers for code execution in logging context - Thread safety
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Log.Level
      Log levels
      static interface  Log.LogAutoClose
      AutoCloseable interface for logging contexts
      static interface  Log.Tag
      Annotation for tagging loggers
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.text.DateFormat DATE_FORMAT  
      static boolean ENABLED
      Global enabled/disabled state of the logger
      static java.lang.String EXCEPTION_STR  
      static LogFilter filter
      Global logger filter for all log messages
      static java.lang.String LEVEL  
      static java.lang.String MSG  
      static java.lang.String SYSTEM_COMPONENT  
      static java.lang.String TIME  
      static boolean TRACE  
    • Constructor Summary

      Constructors 
      Constructor Description
      Log()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addFilter​(APredicate<LNode> p)
      Adds a positive filter (includes only logs that match the predicate)
      static void addFilterNot​(APredicate<LNode> p)
      Adds a negative filter (excludes logs that match the predicate)
      static java.lang.AutoCloseable addListener​(LogFilter filter, AConsumer<LNode> consumer)
      Adds a listener for log events with filtering
      static Log.LogAutoClose context​(LNode n)
      Creates a context from a single LNode
      static Log.LogAutoClose context​(LNode... nn)
      Creates a context from multiple LNodes
      static Log.LogAutoClose context​(LNode parent, java.lang.Object... addData)
      Creates a context with a parent node and additional data
      static Log.LogAutoClose context​(java.lang.Object... data)
      Creates an auto-closeable context that will be automatically popped when closed
      static LNode createContext()
      Creates a context from the current stack only
      static LNode createContext​(LNode... data)
      Creates a new logging context by combining current context with additional nodes
      static LNode createContext​(java.lang.Object... data)
      Creates a new logging context by combining current context with additional data
      static LNode debug​(ToString msg, java.lang.Object... data)
      Logs a DEBUG level message with formatted object
      static LNode debug​(java.lang.String msg, LNode data)
      Logs a DEBUG level message with string and single LNode
      static LNode debug​(java.lang.String msg, LNode... data)
      Logs a DEBUG level message with string and LNode data
      static LNode debug​(java.lang.String msg, java.lang.Object... data)
      Logs a DEBUG level message with string and key-value pairs
      static LNode error​(java.lang.String msg, java.lang.Object... data)
      Logs an ERROR level message without exception
      static LNode error​(java.lang.String msg, java.lang.Throwable throwable, java.lang.Object... data)
      Logs an ERROR level message with exception
      static LNode error​(java.lang.Throwable throwable, java.lang.Object... data)
      Logs an ERROR level message from exception
      static LNode get()
      Gets the current context from the stack
      static java.util.Deque<LNode> getStack()
      Gets the current context stack for the current thread
      static LNode info​(ToString msg, java.lang.Object... data)
      Logs an INFO level message with formatted object
      static LNode info​(java.lang.String msg, LNode data)
      Logs an INFO level message with string and single LNode
      static LNode info​(java.lang.String msg, LNode... data)
      Logs an INFO level message with string and LNode data
      static LNode info​(java.lang.String msg, java.lang.Object... data)
      Logs an INFO level message with string and key-value pairs
      static void log​(LNode node)
      Logs a custom LNode
      static void loggerOff()
      Disables all logging globally
      static void loggerOn()
      Enables all logging globally
      static LNode of​(LNode data)
      Returns the LNode as-is (identity operation)
      static LNode of​(LNode... data)
      Creates a composite LNode from multiple LNodes
      static LNode of​(java.lang.Object... data)
      Creates an LNode from key-value pairs
      static LNode of2​(java.lang.Object[] keys, java.lang.Object[] vals)
      Creates an LNode from separate key and value arrays
      static LNode of2​(java.util.List<? extends java.lang.CharSequence> keys, java.util.List<?> vals)
      Creates an LNode from separate key and value lists
      static LNode ofMap​(java.util.Map<java.lang.String,​?> vals)
      Creates an LNode from a Map
      static void pop​(LNode n)
      Pops a node from the context stack
      static LogPrinter printConsoleColored()
      Creates a colored console printer with default filter
      static LogPrinter printConsoleColored​(LogFilter filter)
      Creates a colored console printer with custom filter
      static LogPrinter printPlainConsole​(LogFilter filter)
      Creates a plain console printer with custom filter
      static void push​(LNode n)
      Pushes a node onto the context stack
      static void setStored​(java.lang.String nameNode, java.lang.String key, java.lang.Object value)
      Sets a value in a previously stored named node
      static void storeNode​(java.lang.String name, LNode n)
      Stores a named node for later retrieval and modification
      static LNode trace​(ToString msg, java.lang.Object... data)
      Logs a TRACE level message with formatted object
      static LNode trace​(java.lang.String msg, LNode data)
      Logs a TRACE level message with string and single LNode
      static LNode trace​(java.lang.String msg, LNode... data)
      Logs a TRACE level message with string and LNode data
      static LNode trace​(java.lang.String msg, java.lang.Object... data)
      Logs a TRACE level message with string and key-value pairs
      static LNode warn​(ToString msg, java.lang.Object... data)
      Logs a WARN level message with formatted object
      static LNode warn​(java.lang.String msg, LNode data)
      Logs a WARN level message with string and single LNode
      static LNode warn​(java.lang.String msg, LNode... data)
      Logs a WARN level message with string and LNode data
      static LNode warn​(java.lang.String msg, java.lang.Object... data)
      Logs a WARN level message with string and key-value pairs
      static LNode warn​(java.lang.String msg, java.lang.Throwable throwable, java.lang.Object... data)
      Logs a WARN level message with exception
      static <T,​T2>
      ABiConsumer<T,​T2>
      wrap​(ABiConsumer<T,​T2> t)
      Wraps a BiConsumer with current logging context
      static <T> AConsumer<T> wrap​(AConsumer<T> t)
      Wraps a Consumer with current logging context
      static <T,​R>
      AFunction<T,​R>
      wrap​(AFunction<T,​R> t)
      Wraps a Function with current logging context
      static ARunnable wrap​(ARunnable t)
      Wraps a Runnable with current logging context
      static <T> ASupplier<T> wrap​(ASupplier<T> t)
      Wraps a Supplier with current logging context
      static java.util.concurrent.Executor wrapExecutor​(java.util.concurrent.Executor executor)
      Wraps an Executor to preserve logging context in executed tasks
      static ARunnable wrapRunnable​(ARunnable t, java.lang.Object... data)
      Wraps a Runnable with logging context
      static <T> ASupplier<T> wrapSupplier​(ASupplier<T> t)
      Wraps a Supplier with current logging context
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • SYSTEM_COMPONENT

        public static final java.lang.String SYSTEM_COMPONENT
        See Also:
        Constant Field Values
      • filter

        public static final LogFilter filter
        Global logger filter for all log messages
      • DATE_FORMAT

        public static final java.text.DateFormat DATE_FORMAT
      • ENABLED

        public static boolean ENABLED
        Global enabled/disabled state of the logger
    • Constructor Detail

      • Log

        public Log()
    • Method Detail

      • storeNode

        public static void storeNode​(java.lang.String name,
                                     LNode n)
        Stores a named node for later retrieval and modification
        Parameters:
        name - Unique name for the node
        n - LNode to store
      • setStored

        public static void setStored​(java.lang.String nameNode,
                                     java.lang.String key,
                                     java.lang.Object value)
        Sets a value in a previously stored named node
        Parameters:
        nameNode - Name of the stored node
        key - Key to set
        value - Value to set
      • getStack

        public static java.util.Deque<LNode> getStack()
        Gets the current context stack for the current thread
        Returns:
        Deque of LNodes representing the context stack
      • createContext

        public static LNode createContext​(java.lang.Object... data)
        Creates a new logging context by combining current context with additional data
        Parameters:
        data - Key-value pairs for the context
        Returns:
        Combined LNode context
      • createContext

        public static LNode createContext​(LNode... data)
        Creates a new logging context by combining current context with additional nodes
        Parameters:
        data - LNodes to combine with current context
        Returns:
        Combined LNode context
      • createContext

        public static LNode createContext()
        Creates a context from the current stack only
        Returns:
        Current context LNode
      • context

        public static Log.LogAutoClose context​(java.lang.Object... data)
        Creates an auto-closeable context that will be automatically popped when closed
        Parameters:
        data - Key-value pairs for the context
        Returns:
        AutoCloseable context that should be used in try-with-resources
      • context

        public static Log.LogAutoClose context​(LNode parent,
                                               java.lang.Object... addData)
        Creates a context with a parent node and additional data
        Parameters:
        parent - Parent LNode
        addData - Additional key-value pairs
        Returns:
        AutoCloseable context
      • context

        public static Log.LogAutoClose context​(LNode... nn)
        Creates a context from multiple LNodes
        Parameters:
        nn - Array of LNodes to form the context
        Returns:
        AutoCloseable context
      • context

        public static Log.LogAutoClose context​(LNode n)
        Creates a context from a single LNode
        Parameters:
        n - LNode to use as context
        Returns:
        AutoCloseable context
      • push

        public static void push​(LNode n)
        Pushes a node onto the context stack
        Parameters:
        n - LNode to push
      • get

        public static LNode get()
        Gets the current context from the stack
        Returns:
        Current context LNode (combination of all nodes in stack)
      • pop

        public static void pop​(LNode n)
        Pops a node from the context stack
        Parameters:
        n - Expected node to pop (for validation)
      • log

        public static void log​(LNode node)
        Logs a custom LNode
        Parameters:
        node - LNode to log
      • trace

        public static LNode trace​(ToString msg,
                                  java.lang.Object... data)
        Logs a TRACE level message with formatted object
        Parameters:
        msg - Message implementing ToString interface
        data - Additional key-value pairs
        Returns:
        Created LNode
      • trace

        public static LNode trace​(java.lang.String msg,
                                  LNode... data)
        Logs a TRACE level message with string and LNode data
        Parameters:
        msg - Message string
        data - LNodes with additional data
        Returns:
        Created LNode
      • trace

        public static LNode trace​(java.lang.String msg,
                                  LNode data)
        Logs a TRACE level message with string and single LNode
        Parameters:
        msg - Message string
        data - LNode with additional data
        Returns:
        Created LNode
      • trace

        public static LNode trace​(java.lang.String msg,
                                  java.lang.Object... data)
        Logs a TRACE level message with string and key-value pairs
        Parameters:
        msg - Message string
        data - Key-value pairs
        Returns:
        Created LNode
      • debug

        public static LNode debug​(ToString msg,
                                  java.lang.Object... data)
        Logs a DEBUG level message with formatted object
        Parameters:
        msg - Message implementing ToString interface
        data - Additional key-value pairs
        Returns:
        Created LNode
      • debug

        public static LNode debug​(java.lang.String msg,
                                  java.lang.Object... data)
        Logs a DEBUG level message with string and key-value pairs
        Parameters:
        msg - Message string
        data - Key-value pairs
        Returns:
        Created LNode
      • debug

        public static LNode debug​(java.lang.String msg,
                                  LNode... data)
        Logs a DEBUG level message with string and LNode data
        Parameters:
        msg - Message string
        data - LNodes with additional data
        Returns:
        Created LNode
      • debug

        public static LNode debug​(java.lang.String msg,
                                  LNode data)
        Logs a DEBUG level message with string and single LNode
        Parameters:
        msg - Message string
        data - LNode with additional data
        Returns:
        Created LNode
      • info

        public static LNode info​(ToString msg,
                                 java.lang.Object... data)
        Logs an INFO level message with formatted object
        Parameters:
        msg - Message implementing ToString interface
        data - Additional key-value pairs
        Returns:
        Created LNode
      • info

        public static LNode info​(java.lang.String msg,
                                 java.lang.Object... data)
        Logs an INFO level message with string and key-value pairs
        Parameters:
        msg - Message string
        data - Key-value pairs
        Returns:
        Created LNode
      • info

        public static LNode info​(java.lang.String msg,
                                 LNode... data)
        Logs an INFO level message with string and LNode data
        Parameters:
        msg - Message string
        data - LNodes with additional data
        Returns:
        Created LNode
      • info

        public static LNode info​(java.lang.String msg,
                                 LNode data)
        Logs an INFO level message with string and single LNode
        Parameters:
        msg - Message string
        data - LNode with additional data
        Returns:
        Created LNode
      • warn

        public static LNode warn​(ToString msg,
                                 java.lang.Object... data)
        Logs a WARN level message with formatted object
        Parameters:
        msg - Message implementing ToString interface
        data - Additional key-value pairs
        Returns:
        Created LNode
      • warn

        public static LNode warn​(java.lang.String msg,
                                 java.lang.Object... data)
        Logs a WARN level message with string and key-value pairs
        Parameters:
        msg - Message string
        data - Key-value pairs
        Returns:
        Created LNode
      • warn

        public static LNode warn​(java.lang.String msg,
                                 LNode... data)
        Logs a WARN level message with string and LNode data
        Parameters:
        msg - Message string
        data - LNodes with additional data
        Returns:
        Created LNode
      • warn

        public static LNode warn​(java.lang.String msg,
                                 LNode data)
        Logs a WARN level message with string and single LNode
        Parameters:
        msg - Message string
        data - LNode with additional data
        Returns:
        Created LNode
      • warn

        public static LNode warn​(java.lang.String msg,
                                 java.lang.Throwable throwable,
                                 java.lang.Object... data)
        Logs a WARN level message with exception
        Parameters:
        msg - Message string
        throwable - Exception to log
        data - Additional key-value pairs
        Returns:
        Created LNode
      • error

        public static LNode error​(java.lang.String msg,
                                  java.lang.Throwable throwable,
                                  java.lang.Object... data)
        Logs an ERROR level message with exception
        Parameters:
        msg - Message string
        throwable - Exception to log
        data - Additional key-value pairs
        Returns:
        Created LNode
      • error

        public static LNode error​(java.lang.String msg,
                                  java.lang.Object... data)
        Logs an ERROR level message without exception
        Parameters:
        msg - Message string
        data - Additional key-value pairs
        Returns:
        Created LNode
      • error

        public static LNode error​(java.lang.Throwable throwable,
                                  java.lang.Object... data)
        Logs an ERROR level message from exception
        Parameters:
        throwable - Exception to log
        data - Additional key-value pairs
        Returns:
        Created LNode
      • addFilterNot

        public static void addFilterNot​(APredicate<LNode> p)
        Adds a negative filter (excludes logs that match the predicate)
        Parameters:
        p - Predicate to exclude matching logs
      • addFilter

        public static void addFilter​(APredicate<LNode> p)
        Adds a positive filter (includes only logs that match the predicate)
        Parameters:
        p - Predicate to include matching logs
      • printConsoleColored

        public static LogPrinter printConsoleColored()
        Creates a colored console printer with default filter
        Returns:
        LogPrinter instance for colored console output
      • printConsoleColored

        public static LogPrinter printConsoleColored​(LogFilter filter)
        Creates a colored console printer with custom filter
        Parameters:
        filter - Custom filter for the printer
        Returns:
        LogPrinter instance for colored console output
      • printPlainConsole

        public static LogPrinter printPlainConsole​(LogFilter filter)
        Creates a plain console printer with custom filter
        Parameters:
        filter - Custom filter for the printer
        Returns:
        LogPrinter instance for plain console output
      • of

        public static LNode of​(java.lang.Object... data)
        Creates an LNode from key-value pairs
        Parameters:
        data - Alternating key-value pairs
        Returns:
        Created LNode
      • of

        public static LNode of​(LNode data)
        Returns the LNode as-is (identity operation)
        Parameters:
        data - LNode to return
        Returns:
        Same LNode
      • of2

        public static LNode of2​(java.lang.Object[] keys,
                                java.lang.Object[] vals)
        Creates an LNode from separate key and value arrays
        Parameters:
        keys - Array of keys
        vals - Array of values
        Returns:
        Created LNode
      • of2

        public static LNode of2​(java.util.List<? extends java.lang.CharSequence> keys,
                                java.util.List<?> vals)
        Creates an LNode from separate key and value lists
        Parameters:
        keys - List of keys
        vals - List of values
        Returns:
        Created LNode
      • ofMap

        public static LNode ofMap​(java.util.Map<java.lang.String,​?> vals)
        Creates an LNode from a Map
        Parameters:
        vals - Map with key-value pairs
        Returns:
        Created LNode
      • of

        public static LNode of​(LNode... data)
        Creates a composite LNode from multiple LNodes
        Parameters:
        data - Array of LNodes to combine
        Returns:
        Composite LNode
      • wrapExecutor

        public static java.util.concurrent.Executor wrapExecutor​(java.util.concurrent.Executor executor)
        Wraps an Executor to preserve logging context in executed tasks
        Parameters:
        executor - Original executor to wrap
        Returns:
        Wrapped executor that preserves logging context
      • wrapRunnable

        public static ARunnable wrapRunnable​(ARunnable t,
                                             java.lang.Object... data)
        Wraps a Runnable with logging context
        Parameters:
        t - Runnable to wrap
        data - Context data for the wrapper
        Returns:
        Wrapped Runnable
      • wrapSupplier

        public static <T> ASupplier<T> wrapSupplier​(ASupplier<T> t)
        Wraps a Supplier with current logging context
        Parameters:
        t - Supplier to wrap
        Returns:
        Wrapped Supplier
      • wrap

        public static <T> ASupplier<T> wrap​(ASupplier<T> t)
        Wraps a Supplier with current logging context
        Parameters:
        t - Supplier to wrap
        Returns:
        Wrapped Supplier
      • wrap

        public static ARunnable wrap​(ARunnable t)
        Wraps a Runnable with current logging context
        Parameters:
        t - Runnable to wrap
        Returns:
        Wrapped Runnable
      • wrap

        public static <T> AConsumer<T> wrap​(AConsumer<T> t)
        Wraps a Consumer with current logging context
        Parameters:
        t - Consumer to wrap
        Returns:
        Wrapped Consumer
      • wrap

        public static <T,​T2> ABiConsumer<T,​T2> wrap​(ABiConsumer<T,​T2> t)
        Wraps a BiConsumer with current logging context
        Parameters:
        t - BiConsumer to wrap
        Returns:
        Wrapped BiConsumer
      • wrap

        public static <T,​R> AFunction<T,​R> wrap​(AFunction<T,​R> t)
        Wraps a Function with current logging context
        Parameters:
        t - Function to wrap
        Returns:
        Wrapped Function
      • loggerOff

        public static void loggerOff()
        Disables all logging globally
      • loggerOn

        public static void loggerOn()
        Enables all logging globally
      • addListener

        public static java.lang.AutoCloseable addListener​(LogFilter filter,
                                                          AConsumer<LNode> consumer)
        Adds a listener for log events with filtering
        Parameters:
        filter - Filter for which events to receive
        consumer - Consumer to handle log events
        Returns:
        AutoCloseable to remove the listener