Package discord4j.common
Class LogUtil
java.lang.Object
discord4j.common.LogUtil
Utility to support logging details.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringformat(ContextView context, String msg) Format a message by unwrapping certainContextViewvalues as metadata, and if they exist, prepend them to the given message.static StringformatValue(Object value, int maxLength) static voidtraceDebug(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 certainContextViewvalues 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 withtrueif the logger has trace level enabled, given byLogger.isTraceEnabled(), ofalseotherwise.- Parameters:
logger- the logger instance used for logging a messagemessageFactory- aFunctionthat takestruevalue if the given logger has trace level enabled,falseotherwise, and produces a message to log.
-
clearContext
-