Class LogConfiguration.Builder

    • Constructor Detail

      • Builder

        public Builder()
        Construct a builder with all default configurations.
    • 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
      • 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
      • 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.
        use enableStackTrace(int) instead, since 1.7.1
        Enable 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.
        use enableStackTrace(String, int) instead, since 1.7.1
        Enable 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 wrapper
        depth - 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 wrapper
        depth - the number of stack trace elements we should log, 0 if no limitation
        Returns:
        the builder
        Since:
        1.7.1
        See Also:
        StackTraceFormatter
      • 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
      • 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 a ObjectFormatter for specific class of object.
        Type Parameters:
        T - the type of object
        Parameters:
        objectClass - the class of object
        objectFormatter - 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