Package dev.prozilla.pine.common.logging
Class Logger
java.lang.Object
dev.prozilla.pine.common.logging.Logger
- All Implemented Interfaces:
Lifecycle
,LogHandler
- Direct Known Subclasses:
AppLogger
Represents the main access points for logging.
Manages different log levels, each with their own log handler, and formats logs.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected boolean
protected boolean
protected LogHandler
protected LogHandler
protected String
static final Logger
The global system logger for writing things to the console. -
Constructor Summary
ConstructorsConstructorDescriptionLogger()
Creates a logger without any log handlers.Logger
(LogHandler outputLogHandler) Creates a logger with an output log handler.Logger
(LogHandler outputLogHandler, LogHandler errorLogHandler) Creates a logger with an output and error log handler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Logs an error message.void
Logs an error message and a stack trace.static String
formatBadge
(String label) static String
formatBadge
(String label, String color) static String
formatPath
(String path) protected boolean
protected boolean
void
log()
Logs an empty line.void
log
(boolean x) void
log
(char x) void
log
(char[] x) void
log
(double x) void
log
(float x) void
log
(int x) void
log
(long x) void
void
Logs a string of text.void
Logs a formatted string of text.void
Redirects logs from one log level to another.setEnabled
(boolean enabled) Enables or disables this logger.Sets the prefix of this logger.void
Logs the stack trace of a throwable.
-
Field Details
-
enabled
protected boolean enabled -
prefix
-
enableAnsi
protected boolean enableAnsi -
outputLogHandler
-
errorLogHandler
-
system
The global system logger for writing things to the console. Equivalent ofSystem.out
andSystem.err
.
-
-
Constructor Details
-
Logger
public Logger()Creates a logger without any log handlers. -
Logger
Creates a logger with an output log handler. -
Logger
Creates a logger with an output and error log handler.
-
-
Method Details
-
log
public void log()Description copied from interface:LogHandler
Logs an empty line.- Specified by:
log
in interfaceLogHandler
-
log
public void log(boolean x) - Specified by:
log
in interfaceLogHandler
-
log
public void log(char x) - Specified by:
log
in interfaceLogHandler
-
log
public void log(int x) - Specified by:
log
in interfaceLogHandler
-
log
public void log(long x) - Specified by:
log
in interfaceLogHandler
-
log
public void log(float x) - Specified by:
log
in interfaceLogHandler
-
log
public void log(double x) - Specified by:
log
in interfaceLogHandler
-
log
public void log(char[] x) - Specified by:
log
in interfaceLogHandler
-
log
- Specified by:
log
in interfaceLogHandler
-
logf
Description copied from interface:LogHandler
Logs a formatted string of text.- Specified by:
logf
in interfaceLogHandler
-
log
Description copied from interface:LogHandler
Logs a string of text.- Specified by:
log
in interfaceLogHandler
-
error
Logs an error message and a stack trace. -
error
Logs an error message. -
trace
Logs the stack trace of a throwable. -
logPath
-
isOutputActive
protected boolean isOutputActive() -
isErrorActive
protected boolean isErrorActive() -
redirect
Redirects logs from one log level to another.- Parameters:
from
- Log level to redirect logs fromto
- Log level to redirect logs to
-
setEnabled
Enables or disables this logger.- Parameters:
enabled
- Iftrue
, the logger will be enabled.
-
setPrefix
Sets the prefix of this logger.- Parameters:
prefix
- Prefix to add to all logged strings.
-
enableAnsi
-
disableAnsi
-
formatPath
-
formatBadge
-
formatBadge
-