Package com.elvishew.xlog
Class LogConfiguration.Builder
- java.lang.Object
-
- com.elvishew.xlog.LogConfiguration.Builder
-
- Enclosing class:
- LogConfiguration
public static class LogConfiguration.Builder extends java.lang.ObjectBuilder forLogConfiguration.
-
-
Constructor Summary
Constructors Constructor Description Builder()Construct a builder with all default configurations.Builder(LogConfiguration logConfiguration)Construct a builder with all configurations from anotherLogConfiguration.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description LogConfiguration.BuilderaddInterceptor(Interceptor interceptor)Add an interceptor.<T> LogConfiguration.BuilderaddObjectFormatter(java.lang.Class<T> objectClass, ObjectFormatter<? super T> objectFormatter)Add aObjectFormatterfor specific class of object.LogConfiguration.Builderb()Deprecated.useenableBorder()instead, since 1.7.1LogConfiguration.BuilderborderFormatter(BorderFormatter borderFormatter)Set the border formatter used when logging.LogConfigurationbuild()Builds configuredLogConfigurationobject.LogConfiguration.BuilderdisableBorder()Disable border, the log content won't be surrounded by a border.LogConfiguration.BuilderdisableStackTrace()Disable stack trace, the stack trace won't be printed with the log message.LogConfiguration.BuilderdisableThreadInfo()Disable thread info, the thread info won't be printed with the log message.LogConfiguration.BuilderenableBorder()Enable border, the border would surround the entire log content, and separate the log message, thread info and stack trace.LogConfiguration.BuilderenableStackTrace(int depth)Enable stack trace, the stack trace would be printed with the log message.LogConfiguration.BuilderenableStackTrace(java.lang.String stackTraceOrigin, int depth)Enable stack trace, the stack trace would be printed with the log message.LogConfiguration.BuilderenableThreadInfo()Enable thread info, the thread info would be printed with the log message.LogConfiguration.BuilderjsonFormatter(JsonFormatter jsonFormatter)Set the JSON formatter used when log a JSON string.LogConfiguration.BuilderlogLevel(int logLevel)Set the log level, the logs below of which would not be printed.LogConfiguration.Buildernb()Deprecated.usedisableBorder()instead, since 1.7.1LogConfiguration.Buildernst()Deprecated.usedisableStackTrace()instead, since 1.7.1LogConfiguration.Buildernt()Deprecated.usedisableThreadInfo()instead, since 1.7.1LogConfiguration.Builderst(int depth)Deprecated.useenableStackTrace(int)instead, since 1.7.1LogConfiguration.Builderst(java.lang.String stackTraceOrigin, int depth)Deprecated.useenableStackTrace(String, int)instead, since 1.7.1LogConfiguration.BuilderstackTraceFormatter(StackTraceFormatter stackTraceFormatter)Set the stack trace formatter used when logging.LogConfiguration.Buildert()Deprecated.useenableThreadInfo()instead, since 1.7.1LogConfiguration.Buildertag(java.lang.String tag)Set the tag string used when log.LogConfiguration.BuilderthreadFormatter(ThreadFormatter threadFormatter)Set the thread formatter used when logging.LogConfiguration.BuilderthrowableFormatter(ThrowableFormatter throwableFormatter)Set the throwable formatter used when log a message with throwable.LogConfiguration.BuilderxmlFormatter(XmlFormatter xmlFormatter)Set the XML formatter used when log a XML string.
-
-
-
Constructor Detail
-
Builder
public Builder()
Construct a builder with all default configurations.
-
Builder
public Builder(LogConfiguration logConfiguration)
Construct a builder with all configurations from anotherLogConfiguration.- Parameters:
logConfiguration- theLogConfigurationto copy configurations from
-
-
Method Detail
-
logLevel
public LogConfiguration.Builder logLevel(int logLevel)
Set the log level, the logs below of which would not be printed.- Parameters:
logLevel- the log level- Returns:
- the builder
- Since:
- 1.3.0
-
tag
public LogConfiguration.Builder tag(java.lang.String tag)
Set the tag string used when log.- Parameters:
tag- the tag string used when log- Returns:
- the builder
-
t
public LogConfiguration.Builder t()
Deprecated.useenableThreadInfo()instead, since 1.7.1Enable thread info.- Returns:
- the builder
-
enableThreadInfo
public LogConfiguration.Builder enableThreadInfo()
Enable thread info, the thread info would be printed with the log message.- Returns:
- the builder
- Since:
- 1.7.1
- See Also:
ThreadFormatter
-
nt
public LogConfiguration.Builder nt()
Deprecated.usedisableThreadInfo()instead, since 1.7.1Disable thread info.- Returns:
- the builder
-
disableThreadInfo
public LogConfiguration.Builder disableThreadInfo()
Disable thread info, the thread info won't be printed with the log message.- Returns:
- the builder
- Since:
- 1.7.1
-
st
public LogConfiguration.Builder st(int depth)
Deprecated.useenableStackTrace(int)instead, since 1.7.1Enable stack trace.- Parameters:
depth- the number of stack trace elements we should log, 0 if no limitation- Returns:
- the builder
-
enableStackTrace
public LogConfiguration.Builder enableStackTrace(int depth)
Enable stack trace, the stack trace would be printed with the log message.- Parameters:
depth- the number of stack trace elements we should log, 0 if no limitation- Returns:
- the builder
- Since:
- 1.7.1
- See Also:
StackTraceFormatter
-
st
public LogConfiguration.Builder st(java.lang.String stackTraceOrigin, int depth)
Deprecated.useenableStackTrace(String, int)instead, since 1.7.1Enable stack trace.- Parameters:
stackTraceOrigin- the origin of stack trace elements from which we should NOT log when logging with stack trace, it can be a package name like "com.elvishew.xlog", a class name like "com.yourdomain.logWrapper", or something else between package name and class name, like "com.yourdomain.". It is mostly used when you are using a logger wrapperdepth- the number of stack trace elements we should log, 0 if no limitation- Returns:
- the builder
- Since:
- 1.4.0
-
enableStackTrace
public LogConfiguration.Builder enableStackTrace(java.lang.String stackTraceOrigin, int depth)
Enable stack trace, the stack trace would be printed with the log message.- Parameters:
stackTraceOrigin- the origin of stack trace elements from which we should NOT log when logging with stack trace, it can be a package name like "com.elvishew.xlog", a class name like "com.yourdomain.logWrapper", or something else between package name and class name, like "com.yourdomain.". It is mostly used when you are using a logger wrapperdepth- the number of stack trace elements we should log, 0 if no limitation- Returns:
- the builder
- Since:
- 1.7.1
- See Also:
StackTraceFormatter
-
nst
public LogConfiguration.Builder nst()
Deprecated.usedisableStackTrace()instead, since 1.7.1Disable stack trace.- Returns:
- the builder
-
disableStackTrace
public LogConfiguration.Builder disableStackTrace()
Disable stack trace, the stack trace won't be printed with the log message.- Returns:
- the builder
- Since:
- 1.7.1
- See Also:
StackTraceFormatter
-
b
public LogConfiguration.Builder b()
Deprecated.useenableBorder()instead, since 1.7.1Enable border.- Returns:
- the builder
-
enableBorder
public LogConfiguration.Builder enableBorder()
Enable border, the border would surround the entire log content, and separate the log message, thread info and stack trace.- Returns:
- the builder
- Since:
- 1.7.1
- See Also:
BorderFormatter
-
nb
public LogConfiguration.Builder nb()
Deprecated.usedisableBorder()instead, since 1.7.1Disable border.- Returns:
- the builder
-
disableBorder
public LogConfiguration.Builder disableBorder()
Disable border, the log content won't be surrounded by a border.- Returns:
- the builder
- Since:
- 1.7.1
-
jsonFormatter
public LogConfiguration.Builder jsonFormatter(JsonFormatter jsonFormatter)
Set the JSON formatter used when log a JSON string.- Parameters:
jsonFormatter- the JSON formatter used when log a JSON string- Returns:
- the builder
-
xmlFormatter
public LogConfiguration.Builder xmlFormatter(XmlFormatter xmlFormatter)
Set the XML formatter used when log a XML string.- Parameters:
xmlFormatter- the XML formatter used when log a XML string- Returns:
- the builder
-
throwableFormatter
public LogConfiguration.Builder throwableFormatter(ThrowableFormatter throwableFormatter)
Set the throwable formatter used when log a message with throwable.- Parameters:
throwableFormatter- the throwable formatter used when log a message with throwable- Returns:
- the builder
-
threadFormatter
public LogConfiguration.Builder threadFormatter(ThreadFormatter threadFormatter)
Set the thread formatter used when logging.- Parameters:
threadFormatter- the thread formatter used when logging- Returns:
- the builder
-
stackTraceFormatter
public LogConfiguration.Builder stackTraceFormatter(StackTraceFormatter stackTraceFormatter)
Set the stack trace formatter used when logging.- Parameters:
stackTraceFormatter- the stack trace formatter used when logging- Returns:
- the builder
-
borderFormatter
public LogConfiguration.Builder borderFormatter(BorderFormatter borderFormatter)
Set the border formatter used when logging.- Parameters:
borderFormatter- the border formatter used when logging- Returns:
- the builder
-
addObjectFormatter
public <T> LogConfiguration.Builder addObjectFormatter(java.lang.Class<T> objectClass, ObjectFormatter<? super T> objectFormatter)
Add aObjectFormatterfor specific class of object.- Type Parameters:
T- the type of object- Parameters:
objectClass- the class of objectobjectFormatter- the object formatter to add- Returns:
- the builder
- Since:
- 1.1.0
-
addInterceptor
public LogConfiguration.Builder addInterceptor(Interceptor interceptor)
Add an interceptor.- Parameters:
interceptor- the interceptor to add- Returns:
- the builder
- Since:
- 1.3.0
-
build
public LogConfiguration build()
Builds configuredLogConfigurationobject.- Returns:
- the built configured
LogConfigurationobject
-
-