Package org.hcjf.log

Class Log


  • public final class Log
    extends Service<LogPrinter>
    Static class that contains the functionality in order to maintain and organize a log file with the same records format The log behavior is affected by the following system properties
    hcfj_log_path: work directory of the log, by default app work directory
    hcfj_log_initial_queue_size: initial size of the internal queue, by default 10000;
    hcfj_log_file_prefix: all the log files start with this prefix, by default hcjf
    hcfj_log_error_file: if the property is true then log create a particular file for error group only, by default false
    hcfj_log_warning_file: if the property is true then log create a particular file for warning group only, by default false
    hcfj_log_info_file: if the property is true then log create a particular file for info group only, by default false
    hcfj_log_debug_file: if the property is true then log create a particular file for debug group only, by default false
    hcfj_log_level: min level to write file, by default "I"
    hcfj_log_date_format: date format to show in the log file, by default "yyyy-mm-dd hh:mm:ss"
    Author:
    javaito
    • Method Summary

      Modifier and Type Method Description
      static void addPrinter​(LogPrinter printer)
      This method register a printer.
      static java.util.UUID d​(java.lang.String tag, java.lang.String message, java.lang.Object... params)
      Create a record with debug group ("[D]").
      static java.util.UUID d​(java.lang.String tag, java.lang.String message, java.lang.Throwable throwable, java.lang.Object... params)
      Create a record with debug group ("[D]").
      static java.util.UUID e​(java.lang.String tag, java.lang.String message, java.lang.Object... params)
      Create a record with error group ("[E]").
      static java.util.UUID e​(java.lang.String tag, java.lang.String message, java.lang.Throwable throwable, java.lang.Object... params)
      Create a record with error group ("[E]").
      static java.lang.Integer getLogQueueSize()
      Return the size of the log queue.
      static java.util.UUID i​(java.lang.String tag, java.lang.String message, java.lang.Object... params)
      Create a record with info group ("[I]").
      static java.util.UUID in​(java.lang.String tag, java.lang.String message, java.lang.Object... params)
      Create a record with info group ("[IN]").
      protected void init()
      Start the log thread.
      static java.util.UUID out​(java.lang.String tag, java.lang.String message, java.lang.Object... params)
      Create a record with info group ("[OUT]").
      void registerConsumer​(LogPrinter consumer)
      This method register a printer.
      protected void shutdown​(Service.ShutdownStage stage)
      Only valid with the stage is START
      void unregisterConsumer​(LogPrinter consumer)
      Unregister a specific consumer.
      static java.util.UUID w​(java.lang.String tag, java.lang.String message, java.lang.Object... params)
      Create a record with warning group ("[W]").
      static java.util.UUID w​(java.lang.String tag, java.lang.String message, java.lang.Throwable throwable, java.lang.Object... params)
      Create a record with warning group ("[W]").
      • Methods inherited from class java.lang.Object

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

      • registerConsumer

        public void registerConsumer​(LogPrinter consumer)
        This method register a printer.
        Specified by:
        registerConsumer in class Service<LogPrinter>
        Parameters:
        consumer - Printer.
        Throws:
        java.lang.NullPointerException - If the printer is null.
      • unregisterConsumer

        public void unregisterConsumer​(LogPrinter consumer)
        Description copied from class: Service
        Unregister a specific consumer.
        Specified by:
        unregisterConsumer in class Service<LogPrinter>
        Parameters:
        consumer - Consumer to unregister.
      • addPrinter

        public static void addPrinter​(LogPrinter printer)
        This method register a printer.
        Parameters:
        printer - Printer.
        Throws:
        java.lang.NullPointerException - If the printer is null.
      • d

        public static java.util.UUID d​(java.lang.String tag,
                                       java.lang.String message,
                                       java.lang.Object... params)
        Create a record with debug group ("[D]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • d

        public static java.util.UUID d​(java.lang.String tag,
                                       java.lang.String message,
                                       java.lang.Throwable throwable,
                                       java.lang.Object... params)
        Create a record with debug group ("[D]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        throwable - Throwable whose message will be printed as part of record
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • i

        public static java.util.UUID i​(java.lang.String tag,
                                       java.lang.String message,
                                       java.lang.Object... params)
        Create a record with info group ("[I]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • in

        public static java.util.UUID in​(java.lang.String tag,
                                        java.lang.String message,
                                        java.lang.Object... params)
        Create a record with info group ("[IN]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • out

        public static java.util.UUID out​(java.lang.String tag,
                                         java.lang.String message,
                                         java.lang.Object... params)
        Create a record with info group ("[OUT]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • w

        public static java.util.UUID w​(java.lang.String tag,
                                       java.lang.String message,
                                       java.lang.Object... params)
        Create a record with warning group ("[W]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • w

        public static java.util.UUID w​(java.lang.String tag,
                                       java.lang.String message,
                                       java.lang.Throwable throwable,
                                       java.lang.Object... params)
        Create a record with warning group ("[W]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        throwable - Throwable whose message will be printed as part of record
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • e

        public static java.util.UUID e​(java.lang.String tag,
                                       java.lang.String message,
                                       java.lang.Object... params)
        Create a record with error group ("[E]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • e

        public static java.util.UUID e​(java.lang.String tag,
                                       java.lang.String message,
                                       java.lang.Throwable throwable,
                                       java.lang.Object... params)
        Create a record with error group ("[E]"). All the places in the messages are replaced for each param in the natural order.
        Parameters:
        tag - Tag of the record
        message - Message to the record. This message use the syntax for class Formatter.
        throwable - Throwable whose message will be printed as part of record
        params - Parameters for the places in the message.
        Returns:
        Returns the id assigned to the log record created, this id could be null if the service does not generates any log records
      • getLogQueueSize

        public static java.lang.Integer getLogQueueSize()
        Return the size of the log queue.
        Returns:
        Size of the log queue.