Class AcceptingLogHandler
java.lang.Object
java.util.logging.Handler
eu.cloudnetservice.common.log.AbstractHandler
eu.cloudnetservice.common.log.defaults.AcceptingLogHandler
A log handler which automatically formats the given log record and notifies the provided message handler.
- Since:
- 4.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateAcceptingLogHandler(@NonNull Consumer<String> handler) Constructs a new accepting log handler instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull AcceptingLogHandlernewInstance(@NonNull Consumer<String> handler) Constructs a new accepting log handler instance.voidwithFormatter(@NonNull Formatter formatter) Sets the formatter of this handler and returns the same instance as used to call the method, for chaining.Methods inherited from class eu.cloudnetservice.common.log.AbstractHandler
close, flushMethods inherited from class java.util.logging.Handler
getEncoding, getErrorManager, getFilter, getFormatter, getLevel, isLoggable, reportError, setEncoding, setErrorManager, setFilter, setFormatter, setLevel
-
Field Details
-
handler
-
-
Constructor Details
-
AcceptingLogHandler
Constructs a new accepting log handler instance.- Parameters:
handler- the consumer to post loggable, formatted log records to.- Throws:
NullPointerException- if the given handler is null.
-
-
Method Details
-
newInstance
@NonNull public static @NonNull AcceptingLogHandler newInstance(@NonNull @NonNull Consumer<String> handler) Constructs a new accepting log handler instance.- Parameters:
handler- the consumer to post loggable, formatted log records to.- Throws:
NullPointerException- if the given handler is null.
-
publish
-
withFormatter
Sets the formatter of this handler and returns the same instance as used to call the method, for chaining.- Parameters:
formatter- the formatter to use for this handler.- Returns:
- the same instance as used to call the method, for chaining.
- Throws:
NullPointerException- if the given formatter is null.
-