@FunctionalInterface public interface LogSink
This interface is intended to act as a tiny wrapper around calls to the underlying logging subsystem.
A typical implementation is:
Logger logger = LoggerFactory.getLogger(...);
LogSink sink = new LogSink() {
public boolean isEnabled() {
return logger.isInfoEnabled();
}
public void accept(String message, Object... args) {
logger.info(message, args);
}
};
| Modifier and Type | Method and Description |
|---|---|
void |
accept(String message,
Object... args)
Process the given message by (possibly) logging it.
|
static LogSink |
buildFrom(Supplier<Boolean> enablementSupplier,
BiConsumer<String,Object[]> messageConsumer)
Creates a new sink with the given enablement supplier and given message consumer.
|
default boolean |
isEnabled()
Whether the sink will effectively process the message (i.e., log it) or not.
|
static LogSink buildFrom(Supplier<Boolean> enablementSupplier, BiConsumer<String,Object[]> messageConsumer)
A typical invocation of this method is:
Logger logger = LoggerFactory.getLogger(...); LogSink sink = LogSink.buildFrom(logger::isInfoEnabled, logger::info);
enablementSupplier - an enablement supplier.messageConsumer - a message consumer.default boolean isEnabled()
Copyright © 2017–2021 DataStax. All rights reserved.