Package elki.logging

Class Logging


  • public class Logging
    extends java.lang.Object
    This class is a wrapper around Logger and LogManager offering additional convenience functions. If a class keeps a static reference to the appropriate Logging object, performance penalty compared to standard logging should be minimal. However when using LogRecord directly instead of ELKILogRecord, the use of the log(LogRecord) method will result in incorrectly logged cause location. Therefore, use ELKILogRecord!
    Since:
    0.2
    Author:
    Erich Schubert
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  Logging.Level
      Logging Level class.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.logging.Logger logger
      Wrapped logger of this instance - not static!
      private static java.util.HashMap<java.lang.String,​Logging> loggers
      HashMap to keep track of loggers.
    • Constructor Summary

      Constructors 
      Constructor Description
      Logging​(java.util.logging.Logger logger)
      Constructor, wrapping a logger.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beginStep​(StepProgress prog, int step, java.lang.String title)
      Begin a new algorithm step (unless null).
      void debug​(java.lang.CharSequence message)
      Log a message at the 'fine' debugging level.
      void debug​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'fine' debugging level.
      void debugFine​(java.lang.CharSequence message)
      Log a message at the 'fine' debugging level.
      void debugFine​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'fine' debugging level.
      void debugFiner​(java.lang.CharSequence message)
      Log a message at the 'finer' debugging level.
      void debugFiner​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'finer' debugging level.
      void debugFinest​(java.lang.CharSequence message)
      Log a message at the 'finest' debugging level.
      void debugFinest​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'finest' debugging level.
      void ensureCompleted​(FiniteProgress prog)
      Increment a progress (unless null).
      void error​(java.lang.CharSequence message)
      Log a message at the 'severe' level.
      void error​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'severe' level.
      void exception​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message with exception at the 'severe' level.
      void exception​(java.lang.Throwable e)
      Log an exception at the 'severe' level.
      void fine​(java.lang.CharSequence message)
      Log a message at the 'fine' debugging level.
      void fine​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'fine' debugging level.
      void finer​(java.lang.CharSequence message)
      Log a message at the 'finer' debugging level.
      void finer​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'finer' debugging level.
      void finest​(java.lang.CharSequence message)
      Log a message at the 'finest' debugging level.
      void finest​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'finest' debugging level.
      static Logging getLogger​(java.lang.Class<?> c)
      Retrieve logging utility for a particular class.
      static Logging getLogger​(java.lang.String name)
      Retrieve logging utility for a particular class.
      void incrementProcessed​(AbstractProgress prog)
      Increment a progress (unless null).
      void info​(java.lang.CharSequence message)
      Log a message at the 'info' ('verbose') level.
      void info​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'info' ('verbose') level.
      boolean isDebugging()
      Test whether to log 'debug' at 'FINE' level.
      boolean isDebuggingFine()
      Test whether to log 'debug' at 'FINE' level This is the same as isDebugging()
      boolean isDebuggingFiner()
      Test whether to log 'debug' at 'FINER' level
      boolean isDebuggingFinest()
      Test whether to log 'debug' at 'FINEST' level
      boolean isInfo()
      Test whether to log 'info' aka 'verbose'.
      boolean isLoggable​(java.util.logging.Level lev)
      Verify if logging is enabled at that particular level.
      boolean isStatistics()
      Test whether to log 'statistics'.
      boolean isVerbose()
      Test whether to log 'verbose' aka 'info'.
      boolean isVeryVerbose()
      Test whether to log 'veryverbose'.
      void log​(java.util.logging.Level level, java.lang.CharSequence message)
      Log a log message at the given level.
      void log​(java.util.logging.Level level, java.lang.CharSequence message, java.lang.Throwable e)
      Log a log message and exception at the given level.
      void log​(java.util.logging.LogRecord rec)
      Log a given log record (should be a ELKILogRecord)
      Counter newCounter​(java.lang.String key)
      Generate a new counter.
      Duration newDuration​(java.lang.String key)
      Generate a new duration statistic.
      void progress​(Progress pgr)
      Log a Progress object.
      void setCompleted​(IndefiniteProgress prog)
      Finish a progress (unless null).
      void setCompleted​(StepProgress prog)
      Finish a progress (unless null).
      void statistics​(Statistic stats)
      Log a statistics object.
      void statistics​(java.lang.CharSequence message)
      Log a message at the 'STATISTICS' level.
      void statistics​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'STATISTICS' level.
      java.lang.String toString()  
      void verbose​(java.lang.CharSequence message)
      Log a message at the 'info' ('verbose') level.
      void verbose​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'info' ('verbose') level.
      void veryverbose​(java.lang.CharSequence message)
      Log a message at the 'veryverbose' level.
      void veryverbose​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'veryverbose' level.
      void warning​(java.lang.CharSequence message)
      Log a message at the 'warning' level.
      void warning​(java.lang.CharSequence message, java.lang.Throwable e)
      Log a message at the 'warning' level.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • loggers

        private static java.util.HashMap<java.lang.String,​Logging> loggers
        HashMap to keep track of loggers.
      • logger

        private final java.util.logging.Logger logger
        Wrapped logger of this instance - not static!
    • Constructor Detail

      • Logging

        public Logging​(java.util.logging.Logger logger)
        Constructor, wrapping a logger.
        Parameters:
        logger - Logger to wrap.
    • Method Detail

      • getLogger

        public static Logging getLogger​(java.lang.Class<?> c)
        Retrieve logging utility for a particular class.
        Parameters:
        c - Class to retrieve logging for
        Returns:
        Logger
      • getLogger

        public static Logging getLogger​(java.lang.String name)
        Retrieve logging utility for a particular class.
        Parameters:
        name - Class name
        Returns:
        Logger
      • isLoggable

        public boolean isLoggable​(java.util.logging.Level lev)
        Verify if logging is enabled at that particular level.
        Parameters:
        lev - Logging level
        Returns:
        status
      • isStatistics

        public boolean isStatistics()
        Test whether to log 'statistics'.
        Returns:
        true if logging statistics
      • isVerbose

        public boolean isVerbose()
        Test whether to log 'verbose' aka 'info'.
        Returns:
        true if verbose
      • isInfo

        public boolean isInfo()
        Test whether to log 'info' aka 'verbose'.
        Returns:
        true if verbose
      • isVeryVerbose

        public boolean isVeryVerbose()
        Test whether to log 'veryverbose'.
        Returns:
        true if extra verbose
      • isDebugging

        public boolean isDebugging()
        Test whether to log 'debug' at 'FINE' level. This is the same as isDebuggingFine()
        Returns:
        true if debug logging enabled
      • isDebuggingFine

        public boolean isDebuggingFine()
        Test whether to log 'debug' at 'FINE' level This is the same as isDebugging()
        Returns:
        true if debug logging enabled
      • isDebuggingFiner

        public boolean isDebuggingFiner()
        Test whether to log 'debug' at 'FINER' level
        Returns:
        true if debug logging enabled
      • isDebuggingFinest

        public boolean isDebuggingFinest()
        Test whether to log 'debug' at 'FINEST' level
        Returns:
        true if debug logging enabled
      • log

        public void log​(java.util.logging.Level level,
                        java.lang.CharSequence message)
        Log a log message at the given level.
        Parameters:
        level - Level to log at.
        message - Message to log.
      • log

        public void log​(java.util.logging.Level level,
                        java.lang.CharSequence message,
                        java.lang.Throwable e)
        Log a log message and exception at the given level.
        Parameters:
        level - Level to log at.
        message - Message to log.
        e - Exception
      • log

        public void log​(java.util.logging.LogRecord rec)
        Log a given log record (should be a ELKILogRecord)
        Parameters:
        rec - Log record to log.
      • error

        public void error​(java.lang.CharSequence message,
                          java.lang.Throwable e)
        Log a message at the 'severe' level.
        Parameters:
        message - Warning log message.
        e - Exception
      • error

        public void error​(java.lang.CharSequence message)
        Log a message at the 'severe' level.
        Parameters:
        message - Warning log message.
      • warning

        public void warning​(java.lang.CharSequence message,
                            java.lang.Throwable e)
        Log a message at the 'warning' level.
        Parameters:
        message - Warning log message.
        e - Exception
      • warning

        public void warning​(java.lang.CharSequence message)
        Log a message at the 'warning' level.
        Parameters:
        message - Warning log message.
      • statistics

        public void statistics​(java.lang.CharSequence message,
                               java.lang.Throwable e)
        Log a message at the 'STATISTICS' level. You should check isTime() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • statistics

        public void statistics​(java.lang.CharSequence message)
        Log a message at the 'STATISTICS' level. You should check isTime() before building the message.
        Parameters:
        message - Informational log message.
      • verbose

        public void verbose​(java.lang.CharSequence message,
                            java.lang.Throwable e)
        Log a message at the 'info' ('verbose') level. You should check isVerbose() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • verbose

        public void verbose​(java.lang.CharSequence message)
        Log a message at the 'info' ('verbose') level. You should check isVerbose() before building the message.
        Parameters:
        message - Informational log message.
      • info

        public void info​(java.lang.CharSequence message,
                         java.lang.Throwable e)
        Log a message at the 'info' ('verbose') level. You should check isVerbose() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • info

        public void info​(java.lang.CharSequence message)
        Log a message at the 'info' ('verbose') level. You should check isVerbose() before building the message.
        Parameters:
        message - Informational log message.
      • veryverbose

        public void veryverbose​(java.lang.CharSequence message,
                                java.lang.Throwable e)
        Log a message at the 'veryverbose' level. You should check isVeryVerbose() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • veryverbose

        public void veryverbose​(java.lang.CharSequence message)
        Log a message at the 'veryverbose' level. You should check isVeryVerbose() before building the message.
        Parameters:
        message - Informational log message.
      • debug

        public void debug​(java.lang.CharSequence message,
                          java.lang.Throwable e)
        Log a message at the 'fine' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • debug

        public void debug​(java.lang.CharSequence message)
        Log a message at the 'fine' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
      • debugFine

        public void debugFine​(java.lang.CharSequence message,
                              java.lang.Throwable e)
        Log a message at the 'fine' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • debugFine

        public void debugFine​(java.lang.CharSequence message)
        Log a message at the 'fine' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
      • fine

        public void fine​(java.lang.CharSequence message,
                         java.lang.Throwable e)
        Log a message at the 'fine' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • fine

        public void fine​(java.lang.CharSequence message)
        Log a message at the 'fine' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
      • debugFiner

        public void debugFiner​(java.lang.CharSequence message,
                               java.lang.Throwable e)
        Log a message at the 'finer' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • debugFiner

        public void debugFiner​(java.lang.CharSequence message)
        Log a message at the 'finer' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
      • finer

        public void finer​(java.lang.CharSequence message,
                          java.lang.Throwable e)
        Log a message at the 'finer' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • finer

        public void finer​(java.lang.CharSequence message)
        Log a message at the 'finer' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
      • debugFinest

        public void debugFinest​(java.lang.CharSequence message,
                                java.lang.Throwable e)
        Log a message at the 'finest' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • debugFinest

        public void debugFinest​(java.lang.CharSequence message)
        Log a message at the 'finest' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
      • finest

        public void finest​(java.lang.CharSequence message,
                           java.lang.Throwable e)
        Log a message at the 'finest' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
        e - Exception
      • finest

        public void finest​(java.lang.CharSequence message)
        Log a message at the 'finest' debugging level. You should check isDebugging() before building the message.
        Parameters:
        message - Informational log message.
      • exception

        public void exception​(java.lang.CharSequence message,
                              java.lang.Throwable e)
        Log a message with exception at the 'severe' level.
        Parameters:
        message - Error log message.
        e - Exception
      • exception

        public void exception​(java.lang.Throwable e)
        Log an exception at the 'severe' level.
        Parameters:
        e - Exception
      • progress

        public void progress​(Progress pgr)
        Log a Progress object.
        Parameters:
        pgr - Progress to log.
      • newCounter

        public Counter newCounter​(java.lang.String key)
        Generate a new counter.
        Parameters:
        key - Key to use
        Returns:
        Counter.
      • newDuration

        public Duration newDuration​(java.lang.String key)
        Generate a new duration statistic.
        Parameters:
        key - Key to use
        Returns:
        Duration statistic.
      • incrementProcessed

        public void incrementProcessed​(AbstractProgress prog)
        Increment a progress (unless null).
        Parameters:
        prog - Progress to increment, may be null.
      • ensureCompleted

        public void ensureCompleted​(FiniteProgress prog)
        Increment a progress (unless null).
        Parameters:
        prog - Progress to complete, may be null.
      • beginStep

        public void beginStep​(StepProgress prog,
                              int step,
                              java.lang.String title)
        Begin a new algorithm step (unless null). Important: Do not use this method when the parameter are not static. In these cases, check whether logging is enabled first, to avoid computing method parameters!
        Parameters:
        prog - Progress to increment, may be null.
        step - Step number
        title - Step title
      • setCompleted

        public void setCompleted​(StepProgress prog)
        Finish a progress (unless null).
        Parameters:
        prog - Progress to complete, may be null.
      • setCompleted

        public void setCompleted​(IndefiniteProgress prog)
        Finish a progress (unless null).
        Parameters:
        prog - Progress to complete, may be null.
      • statistics

        public void statistics​(Statistic stats)
        Log a statistics object.
        Parameters:
        stats - Statistics object to report.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object