Package com.guinetik.corefun
Interface Loggable.Logger
- Enclosing interface:
- Loggable
public static interface Loggable.Logger
A simple, framework-agnostic logger interface.
Logger provides a minimal set of logging methods that can be implemented by delegating to any logging framework. Factory methods are provided for common use cases.
- Since:
- 0.1.0
- Author:
- Guinetik <guinetik@gmail.com>
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidLogs a debug message.voidLogs an error message.voidLogs an error message with an exception.voidLogs an informational message.static Loggable.Loggernoop()Creates a no-op Logger that discards all messages.static Loggable.LoggerCreates a Logger from individual log functions.static Loggable.Loggerof(Consumer<String> info, Consumer<String> warn, Consumer<String> error, BiConsumer<String, Throwable> errorWithThrowable) Creates a Logger with error-with-throwable support.static Loggable.Loggerprintln()Creates a Logger that prints to stdout/stderr.static Loggable.Loggertagged(String tag, Loggable.Logger delegate) Creates a Logger that prefixes all messages with a tag.default voidLogs a trace message.voidLogs a warning message.
-
Method Details
-
info
Logs an informational message.- Parameters:
message- the message to log
-
warn
Logs a warning message.- Parameters:
message- the message to log
-
error
Logs an error message.- Parameters:
message- the message to log
-
error
Logs an error message with an exception.- Parameters:
message- the message to logthrowable- the exception to log
-
debug
Logs a debug message.- Parameters:
message- the message to log
-
trace
Logs a trace message.- Parameters:
message- the message to log
-
of
Creates a Logger from individual log functions.- Parameters:
info- function for info messageswarn- function for warn messageserror- function for error messages- Returns:
- a configured Logger
-
of
static Loggable.Logger of(Consumer<String> info, Consumer<String> warn, Consumer<String> error, BiConsumer<String, Throwable> errorWithThrowable) Creates a Logger with error-with-throwable support.- Parameters:
info- function for info messageswarn- function for warn messageserror- function for error messageserrorWithThrowable- function for error messages with throwables- Returns:
- a configured Logger
-
println
Creates a Logger that prints to stdout/stderr.- Returns:
- a println-based Logger
-
noop
Creates a no-op Logger that discards all messages.- Returns:
- a silent Logger
-
tagged
Creates a Logger that prefixes all messages with a tag.- Parameters:
tag- the prefix tag (typically class name)delegate- the Logger to delegate to- Returns:
- a tagged Logger
-