Class LoggerImpl

java.lang.Object
de.craftsblock.craftsnet.logging.impl.LoggerImpl
All Implemented Interfaces:
Logger

public class LoggerImpl extends Object implements Logger
The LoggerImpl class provides a simple logging mechanism for displaying log messages in the console with different log levels. It supports INFO, WARNING, ERROR, and DEBUG log levels. Log messages are displayed with colored output, and the logger can be configured to include or exclude DEBUG messages based on the debug mode setting. Additionally, the class provides helper methods to log error messages along with exception stack traces. The log messages include timestamps, log levels, thread names, and the actual log text to help with debugging and tracking application behavior.
Since:
3.0.5-SNAPSHOT
  • Constructor Details

    • LoggerImpl

      public LoggerImpl(boolean debug)
      Constructs a Logger with the specified debug mode.
      Parameters:
      debug - If set to true, debug messages will be printed; otherwise, they will be ignored.
  • Method Details

    • info

      public void info(@Nullable @Nullable String text)
      Logs an informational message.
      Specified by:
      info in interface Logger
      Parameters:
      text - The text of the informational message to log. It can be null.
    • warning

      public void warning(@Nullable @Nullable String text)
      Logs a warning message.
      Specified by:
      warning in interface Logger
      Parameters:
      text - The text of the warning message to log. It can be null.
    • error

      public void error(@Nullable @Nullable String text)
      Logs an error message.
      Specified by:
      error in interface Logger
      Parameters:
      text - The text of the error message to log. It can be null.
    • error

      public void error(@NotNull @NotNull Throwable throwable)
      Logs an error message along with the associated throwable.
      Specified by:
      error in interface Logger
      Parameters:
      throwable - The Throwable object representing the error. Must not be null.
    • error

      public void error(@Nullable @Nullable String message, @NotNull @NotNull Throwable throwable)
      Logs an error message along with the associated throwable.
      Specified by:
      error in interface Logger
      Parameters:
      message - A descriptive message for the error. It can be null.
      throwable - The Throwable object representing the error. Must not be null.
      Since:
      3.5.2
    • debug

      public void debug(@Nullable @Nullable String text)
      Logs a debug message.
      Specified by:
      debug in interface Logger
      Parameters:
      text - The text of the debug message to log. It can be null.
    • cloneWithName

      public Logger cloneWithName(String name)
      Creates a clone of this Logger with a specified name.
      Specified by:
      cloneWithName in interface Logger
      Parameters:
      name - The name for the cloned logger.
      Returns:
      A new Logger instance cloned from this logger with the given name.