Class Log

java.lang.Object
br.net.dd.netherwingcore.common.logging.Log

public class Log extends Object
Provides functionalities for logging messages to various log files with different severity levels. The logging framework supports structured messages with details like logging level and file targets. This class handles the construction, formatting, and writing of log messages.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    debug(String message, Object... parameters)
    Logs a debug message with optional parameters for formatting.
    void
    error(String message, Object... parameters)
    Logs an error message with optional parameters for formatting.
    void
    fatal(String message, Object... parameters)
    Logs a fatal error message with optional parameters for formatting.
    static Log
    getLogger(String className)
    Factory method to obtain a logger instance for a specific class.
    void
    info(String message, Object... parameters)
    Logs an informational message with optional parameters for formatting.
    boolean
    Getters and setters for the debugEnabled field, which indicates whether debug logging is enabled.
    void
    log(Detail... details)
    Logs a message with additional details such as logging level and target files.
    void
    log(String message, Object... parameters)
    Logs a simple informational message.
    void
    setDebugEnabled(boolean debugEnabled)
    Sets the debugEnabled field to enable or disable debug logging.
    void
    trace(String message, Object... parameters)
    Logs a trace message with optional parameters for formatting.
    void
    warn(String message, Object... parameters)
    Logs a warning message with optional parameters for formatting.

    Methods inherited from class Object

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

    • getLogger

      public static Log getLogger(String className)
      Factory method to obtain a logger instance for a specific class. This method creates and returns a new Log instance associated with the provided class name.
      Parameters:
      className - The name of the class for which the logger is being created. This is typically the simple name of the class (e.g., MyClass.class.getSimpleName()).
      Returns:
      A new Log instance that can be used for logging messages related to the specified class.
    • log

      public void log(String message, Object... parameters)
      Logs a simple informational message. By default, the message is logged with the Level.INFORMATION severity.
      Parameters:
      message - A string message to log.
    • info

      public void info(String message, Object... parameters)
      Logs an informational message with optional parameters for formatting. The message is formatted using the provided parameters if any are given.
      Parameters:
      message - The informational message to log, which should be an instance of InformationMessage.
      parameters - Optional parameters to format the message. If provided, the message will be formatted using these parameters before logging.
    • warn

      public void warn(String message, Object... parameters)
      Logs a warning message with optional parameters for formatting. The message is formatted using the provided parameters if any are given.
      Parameters:
      message - The warning message to log, which should be an instance of WarningMessage.
      parameters - Optional parameters to format the message. If provided, the message will be formatted using these parameters before logging.
    • error

      public void error(String message, Object... parameters)
      Logs an error message with optional parameters for formatting. The message is formatted using the provided parameters if any are given.
      Parameters:
      message - The error message to log, which should be an instance of ErrorMessage.
      parameters - Optional parameters to format the message. If provided, the message will be formatted using these parameters before logging.
    • fatal

      public void fatal(String message, Object... parameters)
      Logs a fatal error message with optional parameters for formatting. The message is formatted using the provided parameters if any are given.
      Parameters:
      message - The fatal error message to log, which should be an instance of FatalErrorMessage.
      parameters - Optional parameters to format the message. If provided, the message will be formatted using these parameters before logging.
    • debug

      public void debug(String message, Object... parameters)
      Logs a debug message with optional parameters for formatting. The message is formatted using the provided parameters if any are given.
      Parameters:
      message - The debug message to log, which should be an instance of DebugMessage.
      parameters - Optional parameters to format the message. If provided, the message will be formatted using these parameters before logging.
    • trace

      public void trace(String message, Object... parameters)
      Logs a trace message with optional parameters for formatting. The message is formatted using the provided parameters if any are given.
      Parameters:
      message - The trace message to log, which should be an instance of TraceMessage.
      parameters - Optional parameters to format the message. If provided, the message will be formatted using these parameters before logging.
    • log

      public void log(Detail... details)
      Logs a message with additional details such as logging level and target files. This method processes an array of Detail objects to determine the message, severity level, and the files where the logs will be written.

      For example: - Message can specify the log message and its Level. - LogFile provides paths to target log files.

      Parameters:
      details - Varargs of Detail providing additional context for the log message. Supported details are Message and LogFile.
    • isDebugEnabled

      public boolean isDebugEnabled()
      Getters and setters for the debugEnabled field, which indicates whether debug logging is enabled. This allows for dynamic control over the logging level, enabling or disabling debug messages as needed.
    • setDebugEnabled

      public void setDebugEnabled(boolean debugEnabled)
      Sets the debugEnabled field to enable or disable debug logging.
      Parameters:
      debugEnabled - A boolean value indicating whether debug logging should be enabled (true) or disabled (false).