public class LoggerAtLevel extends Object
In order to avoid implicit array creation when using varargs, this class provides a number overloaded version of the log method with increasing number of arguments.
log methods arguments can be of any type. If they are Suppliers, they will be called only when actually logging, thus providing lazy argument evaluation. Also see Util.lazy(Supplier).
When filtering log entries based on quantity or time, we need to generate the "call site" which is the fully qualified name of the class, plus the name of the method calling the log method, plus the line number.
Util.lazy(Supplier)| Constructor and Description |
|---|
LoggerAtLevel(BiConsumer<String,Object[]> loggerMethod,
org.fissore.slf4j.TriConsumer<org.slf4j.Marker,String,Object[]> loggerMethodWithMarker,
boolean isLocationAwareLogger,
org.slf4j.Logger logger,
int level) |
| Modifier and Type | Method and Description |
|---|---|
LoggerAtLevel |
every(int amountOfCalls)
Configures this
LoggerAtLevel to log at most every number of times
For example, say we want to log at most every 5 times. |
LoggerAtLevel |
every(long amountOfTime,
ChronoUnit unit)
Configures this
LoggerAtLevel to log at most every amount of time. |
void |
log(String message)
Logs a message with no params
|
void |
log(String format,
Object... args)
Logs a message with varying number of params
|
void |
log(String format,
Object arg)
Logs a message with one param
|
void |
log(String format,
Object arg1,
Object arg2)
Logs a message with two params
|
void |
log(String format,
Object arg1,
Object arg2,
Object arg3)
Logs a message with three params
|
void |
log(String format,
Object arg1,
Object arg2,
Object arg3,
Object arg4)
Logs a message with four params
|
void |
log(String format,
Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5)
Logs a message with five params
|
void |
log(Supplier<String> messageSupplier)
Logs a message with no params
|
void |
log(Supplier<String> formatSupplier,
Object... args)
Logs a message with varying number of params
|
void |
log(Supplier<String> formatSupplier,
Object arg)
Logs a message with one param
|
void |
log(Supplier<String> formatSupplier,
Object arg1,
Object arg2)
Logs a message with two params
|
void |
log(Supplier<String> formatSupplier,
Object arg1,
Object arg2,
Object arg3)
Logs a message with three params
|
void |
log(Supplier<String> formatSupplier,
Object arg1,
Object arg2,
Object arg3,
Object arg4)
Logs a message with four params
|
void |
log(Supplier<String> formatSupplier,
Object arg1,
Object arg2,
Object arg3,
Object arg4,
Object arg5)
Logs a message with five params
|
LoggerAtLevel |
withCause(Throwable cause)
Associates an exception to this log entry.
|
LoggerAtLevel |
withMarker(org.slf4j.Marker marker) |
public LoggerAtLevel(BiConsumer<String,Object[]> loggerMethod, org.fissore.slf4j.TriConsumer<org.slf4j.Marker,String,Object[]> loggerMethodWithMarker, boolean isLocationAwareLogger, org.slf4j.Logger logger, int level)
public LoggerAtLevel withCause(Throwable cause)
cause - the exception we want to associate this log entry toLoggerAtLevelpublic LoggerAtLevel withMarker(org.slf4j.Marker marker)
public LoggerAtLevel every(long amountOfTime, ChronoUnit unit)
LoggerAtLevel to log at most every amount of time.
For example, say we want to log at most every 2 seconds. If our code attempts to log multiple times for 5 seconds, we'll see only 3 log entries in our log files: the first one, the first one after 2 seconds, and the first one after 4 seconds.
amountOfTime - the amount of time to wait between log entriesunit - the unit of time expressed by amountOfTimeLoggerAtLevelIllegalStateException - if this LoggerAtLevel was already configured to limit logging by quantitypublic LoggerAtLevel every(int amountOfCalls)
LoggerAtLevel to log at most every number of times
For example, say we want to log at most every 5 times. If our code attempts to log 8 times, we'll see 2 log entries in our log files: the first one, and the fifth one.
amountOfCalls - the amount of calls that must be made before loggingLoggerAtLevelIllegalStateException - if this LoggerAtLevel was already configured to limit logging by timepublic void log(String message)
message - the log messagepublic void log(Supplier<String> messageSupplier)
messageSupplier - the log message supplierpublic void log(String format, Object arg)
format - the log messagearg - a log message parampublic void log(Supplier<String> formatSupplier, Object arg)
formatSupplier - the log message supplierarg - a log message parampublic void log(String format, Object arg1, Object arg2)
format - the log messagearg1 - a log message paramarg2 - a log message parampublic void log(Supplier<String> formatSupplier, Object arg1, Object arg2)
formatSupplier - the log message supplierarg1 - a log message paramarg2 - a log message parampublic void log(String format, Object arg1, Object arg2, Object arg3)
format - the log messagearg1 - a log message paramarg2 - a log message paramarg3 - a log message parampublic void log(Supplier<String> formatSupplier, Object arg1, Object arg2, Object arg3)
formatSupplier - the log message supplierarg1 - a log message paramarg2 - a log message paramarg3 - a log message parampublic void log(String format, Object arg1, Object arg2, Object arg3, Object arg4)
format - the log messagearg1 - a log message paramarg2 - a log message paramarg3 - a log message paramarg4 - a log message parampublic void log(Supplier<String> formatSupplier, Object arg1, Object arg2, Object arg3, Object arg4)
formatSupplier - the log message supplierarg1 - a log message paramarg2 - a log message paramarg3 - a log message paramarg4 - a log message parampublic void log(String format, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
format - the log messagearg1 - a log message paramarg2 - a log message paramarg3 - a log message paramarg4 - a log message paramarg5 - a log message parampublic void log(Supplier<String> formatSupplier, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5)
formatSupplier - the log message supplierarg1 - a log message paramarg2 - a log message paramarg3 - a log message paramarg4 - a log message paramarg5 - a log message parampublic void log(String format, Object... args)
format - the log messageargs - log message paramsCopyright © 2019. All rights reserved.