Class Log

java.lang.Object
org.jline.utils.Log

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

The Log class provides a simple logging facility for JLine components, using Java's standard logging API (java.util.logging) 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.

This class uses a single logger named "org.jline" for all JLine components. The actual log level can be configured through the standard Java logging configuration mechanisms, such as logging.properties files or programmatic configuration of the java.util.logging framework.

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
  • Constructor Details

    • Log

      public Log()
  • Method Details

    • trace

      public static void trace(Object... messages)
    • trace

      public static void trace(Supplier<String> supplier)
    • debug

      public static void debug(Supplier<String> supplier)
    • debug

      public static void debug(Object... messages)
    • info

      public static void info(Object... messages)
    • warn

      public static void warn(Object... messages)
    • error

      public static void error(Object... messages)
    • isDebugEnabled

      public static boolean isDebugEnabled()