Class LogUtils


  • public class LogUtils
    extends java.lang.Object
    Utilities for convenience.
    Since:
    1.2.0
    • Constructor Summary

      Constructors 
      Constructor Description
      LogUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String addBorder​(java.lang.String[] segments)
      Add border to string segments using default border formatter.
      static void compress​(java.lang.String folderPath, java.lang.String zipFilePath)
      Compress all files under the specific folder to a single zip file.
      static java.lang.String formatJson​(java.lang.String json)
      Format a JSON string using default JSON formatter.
      static java.lang.String formatStackTrace​(java.lang.StackTraceElement[] stackTrace)
      Format a stack trace using default stack trace formatter.
      static java.lang.String formatThread​(java.lang.Thread thread)
      Format a thread using default thread formatter.
      static java.lang.String formatThrowable​(java.lang.Throwable throwable)
      Format a throwable using default throwable formatter.
      static java.lang.String formatXml​(java.lang.String xml)
      Format an XML string using default XML formatter.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LogUtils

        public LogUtils()
    • Method Detail

      • formatJson

        public static java.lang.String formatJson​(java.lang.String json)
        Format a JSON string using default JSON formatter.
        Parameters:
        json - the JSON string to format
        Returns:
        the formatted string
      • formatXml

        public static java.lang.String formatXml​(java.lang.String xml)
        Format an XML string using default XML formatter.
        Parameters:
        xml - the XML string to format
        Returns:
        the formatted string
      • formatThrowable

        public static java.lang.String formatThrowable​(java.lang.Throwable throwable)
        Format a throwable using default throwable formatter.
        Parameters:
        throwable - the throwable to format
        Returns:
        the formatted string
      • formatThread

        public static java.lang.String formatThread​(java.lang.Thread thread)
        Format a thread using default thread formatter.
        Parameters:
        thread - the thread to format
        Returns:
        the formatted string
      • formatStackTrace

        public static java.lang.String formatStackTrace​(java.lang.StackTraceElement[] stackTrace)
        Format a stack trace using default stack trace formatter.
        Parameters:
        stackTrace - the stack trace to format
        Returns:
        the formatted string
      • addBorder

        public static java.lang.String addBorder​(java.lang.String[] segments)
        Add border to string segments using default border formatter.
        Parameters:
        segments - the string segments to add border to
        Returns:
        the bordered string segments
      • compress

        public static void compress​(java.lang.String folderPath,
                                    java.lang.String zipFilePath)
                             throws java.io.IOException
        Compress all files under the specific folder to a single zip file.

        Should be call in background thread.

        Parameters:
        folderPath - the specific folder path
        zipFilePath - the zip file path
        Throws:
        java.io.IOException - if any error occurs
        Since:
        1.4.0