Class ConsoleHandler

java.lang.Object
com.dua3.utility.logging.ConsoleHandler
All Implemented Interfaces:
LogEntryHandler

public final class ConsoleHandler extends Object implements LogEntryHandler
The ConsoleHandler class is an implementation of the LogEntryHandler interface. It handles log entries by writing them to the console.
  • Constructor Details

    • ConsoleHandler

      public ConsoleHandler(PrintStream out, boolean colored)
      Constructs a ConsoleHandler with the specified PrintStream and colored flag.
      Parameters:
      out - the PrintStream to which log messages will be written
      colored - flag indicating whether to use colored brackets for different log levels
  • Method Details

    • handleEntry

      public void handleEntry(LogEntry entry)
      Description copied from interface: LogEntryHandler
      Handles a log entry.
      Specified by:
      handleEntry in interface LogEntryHandler
      Parameters:
      entry - the log entry to be handled
    • setColored

      public void setColored(boolean colored)
      Enable/Disable colored output using ANSI codes.
      Parameters:
      colored - true, if output use colors
    • isColored

      public boolean isColored()
      Check if colored output is enabled.
      Returns:
      true, if colored output is enabled
    • setFilter

      public void setFilter(LogEntryFilter filter)
      Sets the filter for log entries.
      Parameters:
      filter - the LogEntryFilter to be set as the filter for log entries
    • getFilter

      public LogEntryFilter getFilter()
      Retrieves the filter for log entries.

      This method returns the current filter that is being used to determine if a log entry should be included or excluded.

      Returns:
      the LogEntryFilter that is currently set as the filter for log entries.