Package elki.logging

Class LoggingUtil


  • public final class LoggingUtil
    extends java.lang.Object
    This final class contains some static convenience methods for logging.

    logExpensive(java.util.logging.Level, java.lang.String, java.lang.Throwable) allows the programmer to easily emit a log message, however the function is rather expensive and thus should not be used within loop constructs.

    Since:
    0.2
    Author:
    Erich Schubert
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private LoggingUtil()
      Private constructor.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void exception​(java.lang.String message, java.lang.Throwable e)
      Static version to log a severe exception.
      static void exception​(java.lang.Throwable e)
      Static version to log a severe exception.
      private static java.lang.String[] inferCaller()
      Infer which class has called the logging helper.
      static void logExpensive​(java.util.logging.Level level, java.lang.String message)
      Expensive logging function that is convenient, but should only be used in rare conditions.
      static void logExpensive​(java.util.logging.Level level, java.lang.String message, java.lang.Throwable e)
      Expensive logging function that is convenient, but should only be used in rare conditions.
      static void message​(java.lang.String message)
      Static version to log a 'info' message.
      static void message​(java.lang.String message, java.lang.Throwable e)
      Static version to log a 'info' message.
      static void warning​(java.lang.String message)
      Static version to log a warning message.
      static void warning​(java.lang.String message, java.lang.Throwable e)
      Static version to log a warning message.
      • Methods inherited from class java.lang.Object

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

      • LoggingUtil

        private LoggingUtil()
        Private constructor. Static methods only.
    • Method Detail

      • logExpensive

        public static void logExpensive​(java.util.logging.Level level,
                                        java.lang.String message,
                                        java.lang.Throwable e)
        Expensive logging function that is convenient, but should only be used in rare conditions.

        For 'frequent' logging, use more efficient techniques, such as explained in the logging package documentation.

        Parameters:
        level - Logging level
        message - Message to log.
        e - Exception to report.
      • logExpensive

        public static void logExpensive​(java.util.logging.Level level,
                                        java.lang.String message)
        Expensive logging function that is convenient, but should only be used in rare conditions.

        For 'frequent' logging, use more efficient techniques, such as explained in the logging package documentation.

        Parameters:
        level - Logging level
        message - Message to log.
      • exception

        public static void exception​(java.lang.Throwable e)
        Static version to log a severe exception.
        Parameters:
        e - Exception to log
      • exception

        public static void exception​(java.lang.String message,
                                     java.lang.Throwable e)
        Static version to log a severe exception.
        Parameters:
        message - Exception message, may be null (defaults to e.getMessage())
        e - causing exception
      • warning

        public static void warning​(java.lang.String message)
        Static version to log a warning message.
        Parameters:
        message - Warning message.
      • warning

        public static void warning​(java.lang.String message,
                                   java.lang.Throwable e)
        Static version to log a warning message.
        Parameters:
        message - Warning message, may be null (defaults to e.getMessage())
        e - causing exception
      • message

        public static void message​(java.lang.String message)
        Static version to log a 'info' message.
        Parameters:
        message - Warning message.
      • message

        public static void message​(java.lang.String message,
                                   java.lang.Throwable e)
        Static version to log a 'info' message.
        Parameters:
        message - Warning message, may be null (defaults to e.getMessage())
        e - causing exception
      • inferCaller

        private static java.lang.String[] inferCaller()
        Infer which class has called the logging helper.

        While this looks like duplicated code from ELKILogRecord, it is needed here to find an appropriate Logger (and check the logging level) for the calling class, not just to log the right class and method name.

        Returns:
        calling class name and calling method name