Class Log


  • public final class Log
    extends java.lang.Object
    Internal logging utility for JLine components.

    The Log class provides a simple logging facility for JLine components, using the System.Logger API under the hood. It offers methods for logging at various levels (trace, debug, info, warn, error) and supports both direct message logging and lazy evaluation through suppliers.

    Using System.Logger keeps JLine free of any compile-time dependency on the java.logging module, which is desirable for consumers building trimmed runtime images with jlink. When the java.logging module is present at runtime, the default System.Logger implementation routes to java.util.logging.

    This class uses a single logger named "org.jline" for all JLine components. The actual log level can be configured through whichever logging backend the running JVM provides a System.LoggerFinder for.

    Key features include:

    • Simple static methods for different log levels
    • Support for multiple message objects that are concatenated
    • Lazy evaluation of log messages using Supplier interfaces
    • Automatic exception handling with stack trace logging
    • Performance optimization to avoid string concatenation when logging is disabled

    Example usage:

     // Simple logging
     Log.debug("Processing command: ", command);
    
     // Logging with lazy evaluation
     Log.trace(() -> "Expensive computation result: " + computeResult());
    
     // Logging exceptions
     try {
         // Some operation
     } catch (Exception e) {
         Log.error("Failed to process: ", e);
     }
     
    Since:
    2.0
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void debug​(java.lang.Object... messages)  
      static void debug​(java.util.function.Supplier<java.lang.String> supplier)  
      static void error​(java.lang.Object... messages)  
      static void info​(java.lang.Object... messages)  
      static boolean isDebugEnabled()  
      static void trace​(java.lang.Object... messages)  
      static void trace​(java.util.function.Supplier<java.lang.String> supplier)  
      static void warn​(java.lang.Object... messages)  
      • Methods inherited from class java.lang.Object

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

      • trace

        public static void trace​(java.lang.Object... messages)
      • trace

        public static void trace​(java.util.function.Supplier<java.lang.String> supplier)
      • debug

        public static void debug​(java.util.function.Supplier<java.lang.String> supplier)
      • debug

        public static void debug​(java.lang.Object... messages)
      • info

        public static void info​(java.lang.Object... messages)
      • warn

        public static void warn​(java.lang.Object... messages)
      • error

        public static void error​(java.lang.Object... messages)
      • isDebugEnabled

        public static boolean isDebugEnabled()