Package discord4j.common
Class LogUtil
java.lang.Object
discord4j.common.LogUtil
Utility to support logging details.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
format
(ContextView context, String msg) Format a message by unwrapping certainContextView
values as metadata, and if they exist, prepend them to the given message.static String
formatValue
(Object value, int maxLength) static void
traceDebug
(Logger logger, Function<Boolean, String> messageFactory) Log a message depending on the enabled level for a givenLogger
.
-
Field Details
-
KEY_BUCKET_ID
- See Also:
-
KEY_REQUEST_ID
- See Also:
-
KEY_GATEWAY_ID
- See Also:
-
KEY_SHARD_ID
- See Also:
-
KEY_GUILD_ID
- See Also:
-
-
Constructor Details
-
LogUtil
public LogUtil()
-
-
Method Details
-
format
Format a message by unwrapping certainContextView
values as metadata, and if they exist, prepend them to the given message.- Parameters:
context
- a Reactor context to enrich the logging messagemsg
- the logging message- Returns:
- a formatted log message
-
formatValue
- Parameters:
value
- the value to formatmaxLength
- maximum length of the formatted value if positive or impose no limit otherwise.- Returns:
- a formatted value
-
traceDebug
Log a message depending on the enabled level for a givenLogger
. The supplied message factory will be applied withtrue
if the logger has trace level enabled, given byLogger.isTraceEnabled()
, ofalse
otherwise.- Parameters:
logger
- the logger instance used for logging a messagemessageFactory
- aFunction
that takestrue
value if the given logger has trace level enabled,false
otherwise, and produces a message to log.
-
clearContext
-