public class BaseLogger extends java.lang.Object implements LogService
LogService to provide logging tailored to a particular service.| Constructor and Description |
|---|
BaseLogger(LogService service)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
debug(java.lang.Object site,
java.util.function.Consumer<java.io.PrintWriter> messageWriter)
Logs a debug message.
|
void |
error(java.lang.Object site,
java.util.function.Consumer<java.io.PrintWriter> messageWriter)
Logs an error.
|
static java.lang.String |
fieldsToString(java.util.stream.Stream<util.object.Pair<java.lang.Object,java.lang.Object>> fields)
Prints the given name-value pairs, one per line, into a string.
|
static java.util.function.Consumer<java.io.PrintWriter> |
fieldsWriter(java.lang.String header,
java.util.stream.Stream<util.object.Pair<java.lang.Object,java.lang.Object>>... fields)
Builds a consumer that writes the given name-value pairs to a
PrintWriter buffer using the fieldsToString method. |
void |
info(java.lang.Object site,
java.util.function.Consumer<java.io.PrintWriter> messageWriter)
Logs an informational message.
|
void |
transientError(java.lang.Object site,
java.util.Optional<java.lang.Throwable>... maybeE)
Logs a warning containing a summary of the error and a debug message
with the entire exception's stack trace for each non-empty optional
in the list.
|
void |
transientError(java.lang.Object site,
java.lang.Throwable error)
Logs a warning containing a summary of the error and a debug message
with the entire exception's stack trace.
|
void |
warn(java.lang.Object site,
java.util.function.Consumer<java.io.PrintWriter> messageWriter)
Logs a warning.
|
public BaseLogger(LogService service)
service - the underlying log service.java.lang.NullPointerException - if the argument is null.public static java.lang.String fieldsToString(java.util.stream.Stream<util.object.Pair<java.lang.Object,java.lang.Object>> fields)
>>> name: value".fields - the pairs to print.java.lang.NullPointerException - if the argument is null.@SafeVarargs
public static java.util.function.Consumer<java.io.PrintWriter> fieldsWriter(java.lang.String header,
java.util.stream.Stream<util.object.Pair<java.lang.Object,java.lang.Object>>... fields)
PrintWriter buffer using the fieldsToString method.header - the first line to output.fields - the name-value pairs to output.java.lang.NullPointerException - if any argument is null.public void debug(java.lang.Object site,
java.util.function.Consumer<java.io.PrintWriter> messageWriter)
LogServicedebug in interface LogServicesite - where the event occurred or the object the event is
associated to.messageWriter - writes the content of the log message.public void info(java.lang.Object site,
java.util.function.Consumer<java.io.PrintWriter> messageWriter)
LogServiceinfo in interface LogServicesite - where the event occurred or the object the event is
associated to.messageWriter - writes the content of the log message.public void warn(java.lang.Object site,
java.util.function.Consumer<java.io.PrintWriter> messageWriter)
LogServicewarn in interface LogServicesite - where the event occurred or the object the event is
associated to.messageWriter - writes the content of the log message.public void error(java.lang.Object site,
java.util.function.Consumer<java.io.PrintWriter> messageWriter)
LogServiceerror in interface LogServicesite - where the event occurred or the object the event is
associated to.messageWriter - writes the content of the log message.public void transientError(java.lang.Object site,
java.lang.Throwable error)
site - where the error was detected.error - the error that was caught.java.lang.NullPointerException - if any argument is null.@SafeVarargs
public final void transientError(java.lang.Object site,
java.util.Optional<java.lang.Throwable>... maybeE)
site - where the error was detected.maybeE - errors that were caught, possibly none. If the array is
null, nothing is logged. Any null or
empty element will be skipped.java.lang.NullPointerException - if the site argument is null.