org.lsst.ccs.utilities.logging
Class Logger

java.lang.Object
  extended by org.lsst.ccs.utilities.logging.Logger

public class Logger
extends Object

Just a wrapper class around java.util.Logger to add specific logging methods. The instances are not cached (so better have only one per package)
Most methods allow "multi-dimensional" logging (log the same data to various loggers).
Many of those are intended to replace log4j invocations by just changing the import directives. The mapping from log4J Levels is operated this way

 finest -> finest
 trace -> finer
 debug-> fine
 info -> info
 warn -> warning
 error -> severe
 fatal -> severe
 

Logging methods that return a boolean can be used through assert calls (they always return true).

Do not use this Logger for admin purpose (setting a level, a Filter, a Formatter or a Handler): use the corresponding java.util.logging.Logger instead.

Author:
bamade

Method Summary
 LogRecord createLogRecord(Level level, String message)
          creates a simple log record.
 boolean debug(Object message, String... concerns)
          logs a message at FINE Level
 void debug(Object message, Throwable throwable, String... concerns)
          logs a message at FINE Level
 void error(Object message, String... concerns)
          logs a message at SEVERE Level (use preferably the error method that uses a Throwable parameter)
 void error(Object message, Throwable throwable, String... concerns)
          logs a message at SEVERE Level
 void fatal(Object message, String... concerns)
          logs a message at SEVERE Level (use preferably the fatal method that uses a Throwable parameter)
 void fatal(Object message, Throwable throwable, String... concerns)
          logs a message at SEVERE Level
 boolean fine(Object message, String... concerns)
          logs a message at FINE Level
 boolean finer(Object message, String... concerns)
          logs a message at FINER level
 boolean finest(Object message, String... concerns)
          logs a message at FINEST level
 Level getLevel()
           
static Logger getLogger(String name)
          factory method to obtain a Logger proxy.
static Logger getLogger(String name, String resourceBundleName)
          factory method to obtain a Logger proxy.
 String getName()
           
 boolean info(Object message, String... concerns)
          logs a message at INFO Level
 void info(Object message, Throwable throwable, String... concerns)
          logs a message at INFO Level
 boolean isDebugEnabled()
          tells if the FINE level is activated for the corresponding JUL Logger.
 boolean isInfoEnabled()
          tells if the INFO level is activated for the corresponding JUL Logger.
 boolean isLoggable(Level level)
          tells if the corresponding JUL level is activated for the corresponding JUL Logger.
 boolean log(Level level, String message, Object[] arguments, String... concerns)
          does the same as the equivalent standard JUL method but forwards also to other Loggers.
 boolean log(Level level, String message, Object argument, String... concerns)
          does the same as the equivalent standard JUL method but forwards also to other Loggers.
 void log(Level level, String message, Throwable throwable, String... concerns)
          does the same as the equivalent standard JUL method but forwards also to other Loggers.
 void log(LogRecord record, String... concerns)
          utility method to send a LogRecord to the corresponding JUL logger and to a list of other loggers.
protected  boolean logMessage(Level level, Object message, String... concerns)
          utility method to log a message with a Level
protected  void logSimpleThrowable(Level level, Object message, Throwable throwable, String... concerns)
          utility method to forward a Throwable and a message to the loggers.
 void severe(Object message, String... concerns)
          logs a message at SEVERE Level (use preferably the severe method that uses a Throwable parameter)
 void severe(Object message, Throwable throwable, String... concerns)
          logs a message at SEVERE Level
 void throwing(String sourceClass, String sourceMethod, Throwable throwable)
          invokes the throwing method on the corresponding JUL logger.
 boolean trace(Object message, String... concerns)
          logs a message at FINER level
 boolean warn(Object message, String... concerns)
          logs a message at WARNING Level
 void warn(Object message, Throwable throwable, String... concerns)
          logs a message at WARNING Level
 boolean warning(Object message, String... concerns)
          logs a message at WARNING Level
 void warning(Object message, Throwable throwable, String... concerns)
          logs a message at WARNING Level
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getLogger

public static Logger getLogger(String name)
factory method to obtain a Logger proxy.

Parameters:
name - usually a package name (top of hierarchy is "" empty String)
Returns:

getLogger

public static Logger getLogger(String name,
                               String resourceBundleName)
factory method to obtain a Logger proxy.

Parameters:
name - usually a package name (top of hierarchy is "" empty String)
resourceBundleName -
Returns:

getName

public String getName()
Returns:
the name of the Logger

getLevel

public Level getLevel()
Returns:
the level of the associated JUL logger

createLogRecord

public LogRecord createLogRecord(Level level,
                                 String message)
creates a simple log record. This factory manipulates the caller information (className, method Name) by getting rid of any information coming from a package that contains "logging" (or "log4j").
note that the LogRecord is automatically marked with a sequenceNumber that can be used by Handlers that want to detect duplicate publications.

Parameters:
level - JUL Level
message - (avoid null values)
Returns:
a simple LogRecord

logMessage

protected boolean logMessage(Level level,
                             Object message,
                             String... concerns)
utility method to log a message with a Level

Parameters:
level - JUL level
message - (avoid null values)
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

finest

public boolean finest(Object message,
                      String... concerns)
logs a message at FINEST level

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

trace

public boolean trace(Object message,
                     String... concerns)
logs a message at FINER level

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

finer

public boolean finer(Object message,
                     String... concerns)
logs a message at FINER level

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

debug

public boolean debug(Object message,
                     String... concerns)
logs a message at FINE Level

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

fine

public boolean fine(Object message,
                    String... concerns)
logs a message at FINE Level

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

info

public boolean info(Object message,
                    String... concerns)
logs a message at INFO Level

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

warn

public boolean warn(Object message,
                    String... concerns)
logs a message at WARNING Level

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

warning

public boolean warning(Object message,
                       String... concerns)
logs a message at WARNING Level

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

error

public void error(Object message,
                  String... concerns)
logs a message at SEVERE Level (use preferably the error method that uses a Throwable parameter)

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

fatal

public void fatal(Object message,
                  String... concerns)
logs a message at SEVERE Level (use preferably the fatal method that uses a Throwable parameter)

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

severe

public void severe(Object message,
                   String... concerns)
logs a message at SEVERE Level (use preferably the severe method that uses a Throwable parameter)

Parameters:
message -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

isDebugEnabled

public boolean isDebugEnabled()
tells if the FINE level is activated for the corresponding JUL Logger. (to be used if a subsequent logging call is costly)

Returns:

isInfoEnabled

public boolean isInfoEnabled()
tells if the INFO level is activated for the corresponding JUL Logger. (to be used if a subsequent logging call is costly)

Returns:

logSimpleThrowable

protected void logSimpleThrowable(Level level,
                                  Object message,
                                  Throwable throwable,
                                  String... concerns)
utility method to forward a Throwable and a message to the loggers.

Parameters:
level - JUL level
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

fatal

public void fatal(Object message,
                  Throwable throwable,
                  String... concerns)
logs a message at SEVERE Level

Parameters:
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

severe

public void severe(Object message,
                   Throwable throwable,
                   String... concerns)
logs a message at SEVERE Level

Parameters:
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

error

public void error(Object message,
                  Throwable throwable,
                  String... concerns)
logs a message at SEVERE Level

Parameters:
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

warn

public void warn(Object message,
                 Throwable throwable,
                 String... concerns)
logs a message at WARNING Level

Parameters:
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

warning

public void warning(Object message,
                    Throwable throwable,
                    String... concerns)
logs a message at WARNING Level

Parameters:
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

throwing

public void throwing(String sourceClass,
                     String sourceMethod,
                     Throwable throwable)
invokes the throwing method on the corresponding JUL logger.

Parameters:
sourceClass -
sourceMethod -
throwable -

info

public void info(Object message,
                 Throwable throwable,
                 String... concerns)
logs a message at INFO Level

Parameters:
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

debug

public void debug(Object message,
                  Throwable throwable,
                  String... concerns)
logs a message at FINE Level

Parameters:
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

isLoggable

public boolean isLoggable(Level level)
tells if the corresponding JUL level is activated for the corresponding JUL Logger. (to be used if a subsequent logging call is costly)

Returns:

log

public void log(LogRecord record,
                String... concerns)
utility method to send a LogRecord to the corresponding JUL logger and to a list of other loggers.

Parameters:
record - (should be created with the createLogRecord factory :otherwise stack information will be wrong)
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)

log

public boolean log(Level level,
                   String message,
                   Object argument,
                   String... concerns)
does the same as the equivalent standard JUL method but forwards also to other Loggers.

Parameters:
level - JUL level
message -
argument -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

log

public boolean log(Level level,
                   String message,
                   Object[] arguments,
                   String... concerns)
does the same as the equivalent standard JUL method but forwards also to other Loggers.

Parameters:
level - JUL level
message -
arguments -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)
Returns:
true

log

public void log(Level level,
                String message,
                Throwable throwable,
                String... concerns)
does the same as the equivalent standard JUL method but forwards also to other Loggers.

Parameters:
level - JUL level
message -
throwable -
concerns - a list of additional JUL loggers name (such as "INIT", "CONFIG" ,...)


Copyright © 2013 LSST. All Rights Reserved.