java.lang.Object
com.dua3.utility.logging.ConsoleHandler
- All Implemented Interfaces:
LogEntryHandler
The ConsoleHandler class is an implementation of the LogEntryHandler interface.
It handles log entries by writing them to the console.
-
Constructor Summary
ConstructorsConstructorDescriptionConsoleHandler(PrintStream out, boolean colored) Constructs a ConsoleHandler with the specified PrintStream and colored flag. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the filter for log entries.voidhandleEntry(LogEntry entry) Handles a log entry.booleanCheck if colored output is enabled.voidsetColored(boolean colored) Enable/Disable colored output using ANSI codes.voidsetFilter(LogEntryFilter filter) Sets the filter for log entries.
-
Constructor Details
-
ConsoleHandler
Constructs a ConsoleHandler with the specified PrintStream and colored flag.- Parameters:
out- the PrintStream to which log messages will be writtencolored- flag indicating whether to use colored brackets for different log levels
-
-
Method Details
-
handleEntry
Description copied from interface:LogEntryHandlerHandles a log entry.- Specified by:
handleEntryin interfaceLogEntryHandler- 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
Sets the filter for log entries.- Parameters:
filter- the LogEntryFilter to be set as the filter for log entries
-
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.
-