public final class LoggingUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Consumer<T> |
debugClosure(org.slf4j.Logger logger) |
static <T> Consumer<T> |
debugClosure(org.slf4j.Logger logger,
Throwable thrown) |
static <T> Consumer<T> |
errorClosure(org.slf4j.Logger logger) |
static <T> Consumer<T> |
errorClosure(org.slf4j.Logger logger,
Throwable thrown) |
static NavigableMap<Integer,String> |
generateMnemonicMap(Class<?> clazz,
Predicate<? super Field> acceptor)
Scans using reflection API for all numeric
public static final fields that are also accepted by
the predicate. |
static NavigableMap<Integer,String> |
generateMnemonicMap(Class<?> clazz,
String commonPrefix)
Scans using reflection API for all fields that are
public static final that start with the given common
prefix (case sensitive) and are of type Number. |
static Map<String,Integer> |
getAmbiguousMenmonics(Class<?> clazz,
Predicate<? super Field> acceptor)
Scans using reflection API for all numeric
public static final fields that are also accepted by
the predicate and whose value is used by several of the other matching fields |
static Map<String,Integer> |
getAmbiguousMenmonics(Class<?> clazz,
String commonPrefix)
Scans using reflection API for all numeric
public static final fields that have a common prefix
and whose value is used by several of the other matching fields |
static Collection<Field> |
getMnemonicFields(Class<?> clazz,
Predicate<? super Field> acceptor)
Scans using reflection API for all numeric
public static final fields that are also accepted by
the predicate. |
static <T> Consumer<T> |
infoClosure(org.slf4j.Logger logger) |
static <T> Consumer<T> |
infoClosure(org.slf4j.Logger logger,
Throwable thrown) |
static boolean |
isLoggable(Level level,
Level threshold)
Verifies if the given level is above the required threshold for logging.
|
static boolean |
isLoggable(org.slf4j.Logger logger,
Level level) |
static <T> Consumer<T> |
loggingClosure(org.slf4j.Logger logger,
Level level) |
static <T> Consumer<T> |
loggingClosure(org.slf4j.Logger logger,
Level level,
Throwable t) |
static void |
logMessage(org.slf4j.Logger logger,
Level level,
Object message,
Throwable t) |
static <T> Consumer<T> |
nologClosure(org.slf4j.Logger logger) |
static <T> Consumer<T> |
traceClosure(org.slf4j.Logger logger) |
static <T> Consumer<T> |
traceClosure(org.slf4j.Logger logger,
Throwable thrown) |
static <T> Consumer<T> |
warnClosure(org.slf4j.Logger logger) |
static <T> Consumer<T> |
warnClosure(org.slf4j.Logger logger,
Throwable thrown) |
static SimplifiedLog |
wrap(org.slf4j.Logger logger) |
public static NavigableMap<Integer,String> generateMnemonicMap(Class<?> clazz, String commonPrefix)
public static final that start with the given common
prefix (case sensitive) and are of type Number.clazz - The Class to querycommonPrefix - The expected common prefixNavigableMap of all the matching fields, where key=the field's Integer
value and mapping=the field's namegenerateMnemonicMap(Class, Predicate)public static NavigableMap<Integer,String> generateMnemonicMap(Class<?> clazz, Predicate<? super Field> acceptor)
public static final fields that are also accepted by
the predicate. Any field that is not such or fail to retrieve its value, or has a duplicate value is
silently skipped.clazz - The Class to queryacceptor - The Predicate used to decide whether to process the Field (besides being a
Number and public static final).NavigableMap of all the matching fields, where key=the field's Integer value
and mapping=the field's namegetMnemonicFields(Class, Predicate)public static Map<String,Integer> getAmbiguousMenmonics(Class<?> clazz, String commonPrefix)
public static final fields that have a common prefix
and whose value is used by several of the other matching fieldsclazz - The Class to querycommonPrefix - The expected common prefixMap of all the mnemonic fields names whose value is the same as other fields in
this map. The key is the field's name and value is its associated opcode.getAmbiguousMenmonics(Class, Predicate)public static Map<String,Integer> getAmbiguousMenmonics(Class<?> clazz, Predicate<? super Field> acceptor)
public static final fields that are also accepted by
the predicate and whose value is used by several of the other matching fieldsclazz - The Class to queryacceptor - The Predicate used to decide whether to process the Field (besides being a
Number and public static final).Map of all the mnemonic fields names whose value is the same as other fields in this
map. The key is the field's name and value is its associated opcode.getMnemonicFields(Class, Predicate)public static Collection<Field> getMnemonicFields(Class<?> clazz, Predicate<? super Field> acceptor)
public static final fields that are also accepted by
the predicate.clazz - The Class to queryacceptor - The Predicate used to decide whether to process the Field (besides being a
Number and public static final).Collection of all the fields that have satisfied all conditionspublic static boolean isLoggable(Level level, Level threshold)
level - The Level to evaluatethreshold - The threshold Leveltrue if the evaluated level is above the required threshold.
Note(s):
If either argument is null then result is false.
If the evaluated level is Level.OFF then result is false regardless of the
threshold.
If the threshold is Level.ALL and the evaluated level is not Level.OFF
the result is true.
Otherwise, the evaluated level Level.intValue() must be greater or equal to the
threshold.
public static SimplifiedLog wrap(org.slf4j.Logger logger)
public static void logMessage(org.slf4j.Logger logger,
Level level,
Object message,
Throwable t)
public static boolean isLoggable(org.slf4j.Logger logger,
Level level)
logger - The Logger instance - ignored if nulllevel - The validate log Level - ignored if null
true if the level is enabled for the logger. The mapping of the level to the logger is as
follows:
Level.OFF always returns falseLevel.SEVERE returns Logger.isErrorEnabled()Level.WARNING returns Logger.isWarnEnabled()Level.INFO and Level.ALL returns Logger.isInfoEnabled()Level.CONFIG and Level.FINE returns Logger.isDebugEnabled()Logger.isTraceEnabled()public static <T> Consumer<T> loggingClosure(org.slf4j.Logger logger, Level level)
T - Generic message type consumerlogger - The Logger instance to uselevel - The log Level mapped as follows:
Consumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if the specific level is enabledpublic static <T> Consumer<T> loggingClosure(org.slf4j.Logger logger, Level level, Throwable t)
public static <T> Consumer<T> nologClosure(org.slf4j.Logger logger)
T - Generic message type consumerlogger - The Logger instance to useConsumer.accept(Object) method logs nothing when invokedpublic static <T> Consumer<T> errorClosure(org.slf4j.Logger logger)
T - Generic message type consumerlogger - The Logger instance to useConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isErrorEnabled()public static <T> Consumer<T> errorClosure(org.slf4j.Logger logger, Throwable thrown)
T - Generic message type consumerlogger - The Logger instance to usethrown - A Throwable to attach to the message - ignored if nullConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isErrorEnabled()public static <T> Consumer<T> warnClosure(org.slf4j.Logger logger)
T - Generic message type consumerlogger - The Logger instance to useConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isWarnEnabled()public static <T> Consumer<T> warnClosure(org.slf4j.Logger logger, Throwable thrown)
T - Generic message type consumerlogger - The Logger instance to usethrown - A Throwable to attach to the message - ignored if nullConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isWarnEnabled()public static <T> Consumer<T> infoClosure(org.slf4j.Logger logger)
T - Generic message type consumerlogger - The Logger instance to useConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isInfoEnabled()public static <T> Consumer<T> infoClosure(org.slf4j.Logger logger, Throwable thrown)
T - Generic message type consumerlogger - The Logger instance to usethrown - A Throwable to attach to the message - ignored if nullConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isInfoEnabled()public static <T> Consumer<T> debugClosure(org.slf4j.Logger logger)
T - Generic message type consumerlogger - The Logger instance to useConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isDebugEnabled()public static <T> Consumer<T> debugClosure(org.slf4j.Logger logger, Throwable thrown)
T - Generic message type consumerlogger - The Logger instance to usethrown - A Throwable to attach to the message - ignored if nullConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isDebugEnabled()public static <T> Consumer<T> traceClosure(org.slf4j.Logger logger)
T - Generic message type consumerlogger - The Logger instance to useConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isTraceEnabled()public static <T> Consumer<T> traceClosure(org.slf4j.Logger logger, Throwable thrown)
T - Generic message type consumerlogger - The Logger instance to usethrown - A Throwable to attach to the message - ignored if nullConsumer.accept(Object) method logs the String.valueOf(Object)
value of its argument if Logger.isTraceEnabled()Copyright © 2018–2020 The Apache Software Foundation. All rights reserved.