Package dev.prozilla.pine.common.logging
Class Logger
java.lang.Object
dev.prozilla.pine.common.logging.Logger
- All Implemented Interfaces:
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 booleanprotected booleanprotected booleanprotected LogHandlerprotected LogHandlerprotected Stringstatic final LoggerThe 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 TypeMethodDescriptionprotected StringCreates a timestamp.voidLogs an error message.voidLogs an error message and a stack trace.static StringformatBadge(String label) static StringformatBadge(String label, String color) static StringformatCollection(Collection<?> collection) static StringformatHeader(String header) static StringformatPath(String path) protected booleanprotected booleanvoidlog()Logs an empty line.voidlog(boolean x) voidlog(char x) voidlog(char[] x) voidlog(double x) voidlog(float x) voidlog(int x) voidlog(long x) voidvoidLogs a string of text.voidlogCollection(Collection<?> collection) voidlogCollection(Collection<?> list, String label) voidLogs a formatted string of text.voidvoidvoidRedirects logs from one log level to another.setEnabled(boolean enabled) Enables or disables this logger.Sets the prefix of this logger.voidLogs plain text without applying the logger's format.voidLogs the current time.voidLogs the current time.voidLogs the stack trace of a throwable.
-
Field Details
-
enabled
protected boolean enabled -
prefix
-
enableAnsi
protected boolean enableAnsi -
enableTimestamps
protected boolean enableTimestamps -
outputLogHandler
-
errorLogHandler
-
system
The global system logger for writing things to the console. Equivalent ofSystem.outandSystem.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
-
error
Logs an error message and a stack trace. -
trace
Logs the stack trace of a throwable. -
error
Logs an error message. -
logPath
-
logPath
-
logHeader
-
logCollection
-
logCollection
-
timestamp
Logs the current time. -
timestamp
public void timestamp()Logs the current time. -
log
public void log()Description copied from interface:LogHandlerLogs an empty line.- Specified by:
login interfaceLogHandler
-
log
public void log(boolean x) - Specified by:
login interfaceLogHandler
-
log
public void log(char x) - Specified by:
login interfaceLogHandler
-
log
public void log(int x) - Specified by:
login interfaceLogHandler
-
log
public void log(long x) - Specified by:
login interfaceLogHandler
-
log
public void log(float x) - Specified by:
login interfaceLogHandler
-
log
public void log(double x) - Specified by:
login interfaceLogHandler
-
log
public void log(char[] x) - Specified by:
login interfaceLogHandler
-
log
- Specified by:
login interfaceLogHandler
-
logf
Description copied from interface:LogHandlerLogs a formatted string of text.- Specified by:
logfin interfaceLogHandler
-
text
Logs plain text without applying the logger's format.- Parameters:
text- The text to log
-
log
Description copied from interface:LogHandlerLogs a string of text.- Specified by:
login interfaceLogHandler
-
createTimestamp
Creates a timestamp. -
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
-
formatHeader
-
formatCollection
-