类 LogFormatUtils
java.lang.Object
cn.taketoday.util.LogFormatUtils
Utility methods for formatting and logging messages.
From Spring
- 从以下版本开始:
- 3.0
- 作者:
- TODAY 2020/12/6 18:29
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static StringformatValue(Object value, boolean limitLength) Convenience variant offormatValue(Object, int, boolean)that limits the length of a log message to 100 characters and also replaces newline and control characters iflimitLengthis set to "true".static StringformatValue(Object value, int maxLength, boolean replaceNewlinesAndControlCharacters) Format the given value viatoString(), quoting it if it is aCharSequence, truncating at the specifiedmaxLength, and compacting it into a single line whenreplaceNewLinesis set.static voidtraceDebug(Logger logger, Function<Boolean, String> messageFactory) Use this to log a message with different levels of detail (or different messages) at TRACE vs DEBUG log levels.
-
构造器详细资料
-
LogFormatUtils
public LogFormatUtils()
-
-
方法详细资料
-
formatValue
Convenience variant offormatValue(Object, int, boolean)that limits the length of a log message to 100 characters and also replaces newline and control characters iflimitLengthis set to "true".- 参数:
value- the value to formatlimitLength- whether to truncate the value at a length of 100- 返回:
- the formatted value
-
formatValue
public static String formatValue(@Nullable Object value, int maxLength, boolean replaceNewlinesAndControlCharacters) Format the given value viatoString(), quoting it if it is aCharSequence, truncating at the specifiedmaxLength, and compacting it into a single line whenreplaceNewLinesis set.- 参数:
value- the value to be formattedmaxLength- the max length, after which to truncate, or -1 for unlimitedreplaceNewlinesAndControlCharacters- whether to replace newline and control characters with placeholders- 返回:
- the formatted value
-
traceDebug
Use this to log a message with different levels of detail (or different messages) at TRACE vs DEBUG log levels. Effectively, a substitute for:if (logger.isDebugEnabled()) { String str = logger.isTraceEnabled() ? "..." : "..."; if (logger.isTraceEnabled()) { logger.trace(str); } else { logger.debug(str); } }- 参数:
logger- the logger to use to log the messagemessageFactory- function that accepts a boolean set to the value ofLogger.isTraceEnabled()
-