Package com.couchbase.client.core.cnc
Class DefaultLoggerFormatter
- java.lang.Object
-
- com.couchbase.client.core.cnc.DefaultLoggerFormatter
-
- All Implemented Interfaces:
LoggerFormatter
public class DefaultLoggerFormatter extends Object implements LoggerFormatter
The default implementation for theLoggerFormatter
.
-
-
Field Summary
Fields Modifier and Type Field Description static DefaultLoggerFormatter
INSTANCE
-
Constructor Summary
Constructors Constructor Description DefaultLoggerFormatter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
format(Level logLevel, String message, Throwable throwable)
Formats the inputs into a string that will be printed.protected String
logLevel(Level level)
Converts the log level enum to its string representation.protected String
timestamp()
Returns a timestamp to be included in the default output log format.
-
-
-
Field Detail
-
INSTANCE
public static final DefaultLoggerFormatter INSTANCE
-
-
Method Detail
-
format
public String format(Level logLevel, String message, @Nullable Throwable throwable)
Description copied from interface:LoggerFormatter
Formats the inputs into a string that will be printed.- Specified by:
format
in interfaceLoggerFormatter
- Parameters:
logLevel
- the log level.message
- the message.throwable
- the throwable, which can be null.- Returns:
- the formatted string that will be printed onto the console.
-
timestamp
protected String timestamp()
Returns a timestamp to be included in the default output log format.- Returns:
- a timestamp or date format, might be null or empty.
-
logLevel
protected String logLevel(Level level)
Converts the log level enum to its string representation.Note that in the default implementation, the aim is to preserve the length of the log levels so some levels are prefixed with whitespace - this is not a typo.
- Parameters:
level
- the level to convert.- Returns:
- the converted level.
-
-