Package jmri.util
Class LoggingUtil
java.lang.Object
jmri.util.LoggingUtil
Basic utilities for logging special messages.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voiddeprecationWarning(org.slf4j.Logger logger, String methodName) Warn that a deprecated method has been invoked.static booleanEmit a particular INFO-level message just once.static <T extends Throwable>
TshortenStacktrace(T t) Shorten a stack trace to start with the first JMRI method.static <T extends Throwable>
TshortenStacktrace(T t, int len) Shorten a stack trace to a fixed length.static booleanEmit a particular WARNING-level message just once.
-
Field Details
-
warnedOnce
-
infodOnce
-
logDeprecations
-
-
Constructor Details
-
LoggingUtil
public LoggingUtil()
-
-
Method Details
-
warnOnce
public static boolean warnOnce(@Nonnull org.slf4j.Logger logger, @Nonnull String msg, Object... args) Emit a particular WARNING-level message just once.Goal is to be lightweight and fast; this will only be used in a few places, and only those should appear in data structure.
- Parameters:
logger- the source of the warningmsg- warning messageargs- message arguments- Returns:
- true if the log was emitted this time
-
infoOnce
public static boolean infoOnce(@Nonnull org.slf4j.Logger logger, @Nonnull String msg, Object... args) Emit a particular INFO-level message just once.Goal is to be lightweight and fast; this will only be used in a few places, and only those should appear in data structure.
- Parameters:
logger- the source of the warningmsg- info messageargs- message arguments- Returns:
- true if the log was emitted this time
-
deprecationWarning
Warn that a deprecated method has been invoked.Can also be used to warn of some deprecated condition, i.e. obsolete-format input data.
The logging is turned off by default during testing to simplify updating tests when warnings are added.
- Parameters:
logger- The Logger to warn.methodName- method name.
-
shortenStacktrace
Shorten a stack trace to start with the first JMRI method.When logged, the stack trace will be more focused.
- Type Parameters:
T- the type of Throwable- Parameters:
t- the Throwable containing the stack trace to truncate- Returns:
- t with truncated stack trace
-
shortenStacktrace
Shorten a stack trace to a fixed length.When logged, the stack trace will be more focused.
- Type Parameters:
T- the type of Throwable- Parameters:
t- the Throwable containing the stack trace to truncatelen- length of stack trace to retain- Returns:
- t with truncated stack trace
-