Class XLog

    • Method Detail

      • init

        public static void init()
        Initialize log system, should be called only once.
        Since:
        1.3.0
      • init

        public static void init​(int logLevel)
        Initialize log system, should be called only once.
        Parameters:
        logLevel - the log level, logs with a lower level than which would not be printed
      • init

        @Deprecated
        public static void init​(int logLevel,
                                LogConfiguration logConfiguration)
        Deprecated.
        the log level is part of log configuration now, use init(LogConfiguration) instead, since 1.3.0
        Initialize log system, should be called only once.
        Parameters:
        logLevel - the log level, logs with a lower level than which would not be printed
        logConfiguration - the log configuration
      • init

        public static void init​(LogConfiguration logConfiguration)
        Initialize log system, should be called only once.
        Parameters:
        logConfiguration - the log configuration
        Since:
        1.3.0
      • init

        public static void init​(Printer... printers)
        Initialize log system, should be called only once.
        Parameters:
        printers - the printers, each log would be printed by all of the printers
        Since:
        1.3.0
      • init

        public static void init​(int logLevel,
                                Printer... printers)
        Initialize log system, should be called only once.
        Parameters:
        logLevel - the log level, logs with a lower level than which would not be printed
        printers - the printers, each log would be printed by all of the printers
      • init

        @Deprecated
        public static void init​(int logLevel,
                                LogConfiguration logConfiguration,
                                Printer... printers)
        Deprecated.
        the log level is part of log configuration now, use init(LogConfiguration, Printer...) instead, since 1.3.0
        Initialize log system, should be called only once.
        Parameters:
        logLevel - the log level, logs with a lower level than which would not be printed
        logConfiguration - the log configuration
        printers - the printers, each log would be printed by all of the printers
      • init

        public static void init​(LogConfiguration logConfiguration,
                                Printer... printers)
        Initialize log system, should be called only once.
        Parameters:
        logConfiguration - the log configuration
        printers - the printers, each log would be printed by all of the printers
        Since:
        1.3.0
      • logLevel

        public static Logger.Builder logLevel​(int logLevel)
        Start to customize a Logger and set the log level.
        Parameters:
        logLevel - the log level to customize
        Returns:
        the Logger.Builder to build the Logger
        Since:
        1.3.0
      • disableThreadInfo

        public static Logger.Builder disableThreadInfo()
        Start to customize a Logger and disable thread info, the thread info won't be printed with the log message.
        Returns:
        the Logger.Builder to build the Logger
        Since:
        1.7.0
      • st

        @Deprecated
        public static Logger.Builder st​(int depth)
        Deprecated.
        use enableStackTrace(int) instead, since 1.7.0
        Start to customize a Logger and enable stack trace.
        Parameters:
        depth - the number of stack trace elements we should log, 0 if no limitation
        Returns:
        the Logger.Builder to build the Logger
      • enableStackTrace

        public static Logger.Builder enableStackTrace​(int depth)
        Start to customize a Logger and 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 Logger.Builder to build the Logger
        Since:
        1.7.0
        See Also:
        StackTraceFormatter
      • st

        @Deprecated
        public static Logger.Builder st​(java.lang.String stackTraceOrigin,
                                        int depth)
        Deprecated.
        use enableStackTrace(String, int) instead, since 1.7.0
        Start to customize a Logger and enable stack trace.
        Parameters:
        stackTraceOrigin - the origin of stack trace elements from which we should NOT log, 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 Logger.Builder to build the Logger
        Since:
        1.4.0
      • enableStackTrace

        public static Logger.Builder enableStackTrace​(java.lang.String stackTraceOrigin,
                                                      int depth)
        Start to customize a Logger and 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, 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 Logger.Builder to build the Logger
        Since:
        1.7.0
        See Also:
        StackTraceFormatter
      • disableStackTrace

        public static Logger.Builder disableStackTrace()
        Start to customize a Logger and disable stack trace, the stack trace won't be printed with the log message.
        Returns:
        the Logger.Builder to build the Logger
        Since:
        1.7.0
      • enableBorder

        public static Logger.Builder enableBorder()
        Start to customize a Logger and enable border, the border would surround the entire log content, and separate the log message, thread info and stack trace.
        Returns:
        the Logger.Builder to build the Logger
        Since:
        1.7.0
        See Also:
        BorderFormatter
      • disableBorder

        public static Logger.Builder disableBorder()
        Start to customize a Logger and disable border, the log content won't be surrounded by a border.
        Returns:
        the Logger.Builder to build the Logger
        Since:
        1.7.0
      • addObjectFormatter

        public static <T> Logger.Builder addObjectFormatter​(java.lang.Class<T> objectClass,
                                                            ObjectFormatter<? super T> objectFormatter)
        Start to customize a Logger and add an object formatter 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 Logger.Builder to build the Logger
        Since:
        1.1.0
      • v

        public static void v​(java.lang.Object[] array)
        Log an array with level LogLevel.VERBOSE.
        Parameters:
        array - the array to log
      • v

        public static void v​(java.lang.String format,
                             java.lang.Object... args)
        Log a message with level LogLevel.VERBOSE.
        Parameters:
        format - the format of the message to log
        args - the arguments of the message to log
      • v

        public static void v​(java.lang.String msg)
        Log a message with level LogLevel.VERBOSE.
        Parameters:
        msg - the message to log
      • v

        public static void v​(java.lang.String msg,
                             java.lang.Throwable tr)
        Log a message and a throwable with level LogLevel.VERBOSE.
        Parameters:
        msg - the message to log
        tr - the throwable to be log
      • d

        public static void d​(java.lang.Object[] array)
        Log an array with level LogLevel.DEBUG.
        Parameters:
        array - the array to log
      • d

        public static void d​(java.lang.String format,
                             java.lang.Object... args)
        Log a message with level LogLevel.DEBUG.
        Parameters:
        format - the format of the message to log
        args - the arguments of the message to log
      • d

        public static void d​(java.lang.String msg)
        Log a message with level LogLevel.DEBUG.
        Parameters:
        msg - the message to log
      • d

        public static void d​(java.lang.String msg,
                             java.lang.Throwable tr)
        Log a message and a throwable with level LogLevel.DEBUG.
        Parameters:
        msg - the message to log
        tr - the throwable to be log
      • i

        public static void i​(java.lang.Object[] array)
        Log an array with level LogLevel.INFO.
        Parameters:
        array - the array to log
      • i

        public static void i​(java.lang.String format,
                             java.lang.Object... args)
        Log a message with level LogLevel.INFO.
        Parameters:
        format - the format of the message to log
        args - the arguments of the message to log
      • i

        public static void i​(java.lang.String msg)
        Log a message with level LogLevel.INFO.
        Parameters:
        msg - the message to log
      • i

        public static void i​(java.lang.String msg,
                             java.lang.Throwable tr)
        Log a message and a throwable with level LogLevel.INFO.
        Parameters:
        msg - the message to log
        tr - the throwable to be log
      • w

        public static void w​(java.lang.Object[] array)
        Log an array with level LogLevel.WARN.
        Parameters:
        array - the array to log
      • w

        public static void w​(java.lang.String format,
                             java.lang.Object... args)
        Log a message with level LogLevel.WARN.
        Parameters:
        format - the format of the message to log
        args - the arguments of the message to log
      • w

        public static void w​(java.lang.String msg)
        Log a message with level LogLevel.WARN.
        Parameters:
        msg - the message to log
      • w

        public static void w​(java.lang.String msg,
                             java.lang.Throwable tr)
        Log a message and a throwable with level LogLevel.WARN.
        Parameters:
        msg - the message to log
        tr - the throwable to be log
      • e

        public static void e​(java.lang.Object[] array)
        Log an array with level LogLevel.ERROR.
        Parameters:
        array - the array to log
      • e

        public static void e​(java.lang.String format,
                             java.lang.Object... args)
        Log a message with level LogLevel.ERROR.
        Parameters:
        format - the format of the message to log
        args - the arguments of the message to log
      • e

        public static void e​(java.lang.String msg)
        Log a message with level LogLevel.ERROR.
        Parameters:
        msg - the message to log
      • e

        public static void e​(java.lang.String msg,
                             java.lang.Throwable tr)
        Log a message and a throwable with level LogLevel.ERROR.
        Parameters:
        msg - the message to log
        tr - the throwable to be log
      • log

        public static void log​(int logLevel,
                               java.lang.Object[] array)
        Log an array with specific log level.
        Parameters:
        logLevel - the specific log level
        array - the array to log
        Since:
        1.4.0
      • log

        public static void log​(int logLevel,
                               java.lang.String format,
                               java.lang.Object... args)
        Log a message with specific log level.
        Parameters:
        logLevel - the specific log level
        format - the format of the message to log
        args - the arguments of the message to log
        Since:
        1.4.0
      • log

        public static void log​(int logLevel,
                               java.lang.String msg)
        Log a message with specific log level.
        Parameters:
        logLevel - the specific log level
        msg - the message to log
        Since:
        1.4.0
      • log

        public static void log​(int logLevel,
                               java.lang.String msg,
                               java.lang.Throwable tr)
        Log a message and a throwable with specific log level.
        Parameters:
        logLevel - the specific log level
        msg - the message to log
        tr - the throwable to be log
        Since:
        1.4.0
      • json

        public static void json​(java.lang.String json)
        Log a JSON string, with level LogLevel.DEBUG by default.
        Parameters:
        json - the JSON string to log
      • xml

        public static void xml​(java.lang.String xml)
        Log a XML string, with level LogLevel.DEBUG by default.
        Parameters:
        xml - the XML string to log