Package fr.diskmth.loggy
Class LoggyFormatter
java.lang.Object
fr.diskmth.loggy.LoggyFormatter
An abstract class for formatting log messages using ANSI codes for color and style.
- Since:
- Loggy 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LoggyFormatterThe default LoggyFormatter with predefined ANSI codes for each log level. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract Stringformat(LoggyLevel level, String loggy, String message) Formats a log message using ANSI codes.Returns a LoggyFormatter that clears all ANSI codes from the parent LoggyFormatter's output.abstract HashMap<LoggyLevel,List<ANSI>> Returns the ANSI codes for each log level.static FormattertoJavaFormatter(LoggyFormatter formatter) Converts a LoggyFormatter to a Java Formatter.
-
Field Details
-
DEFAULT
The default LoggyFormatter with predefined ANSI codes for each log level.
-
-
Constructor Details
-
LoggyFormatter
public LoggyFormatter()
-
-
Method Details
-
toJavaFormatter
Converts a LoggyFormatter to a Java Formatter.- Parameters:
formatter- the LoggyFormatter to convert- Returns:
- a Java Formatter with the same formatting as the given LoggyFormatter
-
levelsFormat
Returns the ANSI codes for each log level.- Returns:
- a HashMap of LoggyLevel to a List of ANSI codes
-
format
Formats a log message using ANSI codes.- Parameters:
level- the log levelloggy- the logger namemessage- the log message- Returns:
- the formatted log message as a String
-
getFileFormatter
Returns a LoggyFormatter that clears all ANSI codes from the parent LoggyFormatter's output.- Returns:
- a LoggyFormatter that does not use ANSI codes
-