org.apache.poi.util
Class POILogger

java.lang.Object
  extended by org.apache.poi.util.POILogger
Direct Known Subclasses:
CommonsLogger, NullLogger, SystemOutLogger

@Internal
public abstract class POILogger
extends java.lang.Object

A logger interface that strives to make it as easy as possible for developers to write log calls, while simultaneously making those calls as cheap as possible by performing lazy evaluation of the log message.

Author:
Marc Johnson (mjohnson at apache dot org), Glen Stampoultzis (glens at apache.org), Nicola Ken Barozzi (nicolaken at apache.org)

Field Summary
static int DEBUG
           
static int ERROR
           
static int FATAL
           
static int INFO
           
protected static java.lang.String[] LEVEL_STRINGS
          Long strings for numeric log level.
protected static java.lang.String[] LEVEL_STRINGS_SHORT
          Short strings for numeric log level.
static int WARN
           
 
Method Summary
abstract  boolean check(int level)
          Check if a logger is enabled to log at the specified level
abstract  void initialize(java.lang.String cat)
           
 void log(int level, java.lang.Object... objs)
          Log a message.
protected abstract  void log(int level, java.lang.Object obj1)
          Log a message
protected abstract  void log(int level, java.lang.Object obj1, java.lang.Throwable exception)
          Log a message
 void logFormatted(int level, java.lang.String message, java.lang.Object... unflatParams)
          Logs a formated message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final int DEBUG
See Also:
Constant Field Values

INFO

public static final int INFO
See Also:
Constant Field Values

WARN

public static final int WARN
See Also:
Constant Field Values

ERROR

public static final int ERROR
See Also:
Constant Field Values

FATAL

public static final int FATAL
See Also:
Constant Field Values

LEVEL_STRINGS_SHORT

protected static final java.lang.String[] LEVEL_STRINGS_SHORT
Short strings for numeric log level. Use level as array index.


LEVEL_STRINGS

protected static final java.lang.String[] LEVEL_STRINGS
Long strings for numeric log level. Use level as array index.

Method Detail

initialize

public abstract void initialize(java.lang.String cat)

log

protected abstract void log(int level,
                            java.lang.Object obj1)
Log a message

Parameters:
level - One of DEBUG, INFO, WARN, ERROR, FATAL
obj1 - The object to log. This is converted to a string.

log

protected abstract void log(int level,
                            java.lang.Object obj1,
                            java.lang.Throwable exception)
Log a message

Parameters:
level - One of DEBUG, INFO, WARN, ERROR, FATAL
obj1 - The object to log. This is converted to a string.
exception - An exception to be logged

check

public abstract boolean check(int level)
Check if a logger is enabled to log at the specified level

Parameters:
level - One of DEBUG, INFO, WARN, ERROR, FATAL

log

public void log(int level,
                java.lang.Object... objs)
Log a message. Lazily appends Object parameters together. If the last parameter is a Throwable it is logged specially.

Parameters:
level - One of DEBUG, INFO, WARN, ERROR, FATAL
objs - the objects to place in the message

logFormatted

public void logFormatted(int level,
                         java.lang.String message,
                         java.lang.Object... unflatParams)
Logs a formated message. The message itself may contain % characters as place holders. This routine will attempt to match the placeholder by looking at the type of parameter passed to obj1.

If the parameter is an array, it traverses the array first and matches parameters sequentially against the array items. Otherwise the parameters after message are matched in order.

If the place holder matches against a number it is printed as a whole number. This can be overridden by specifying a precision in the form %n.m where n is the padding for the whole part and m is the number of decimal places to display. n can be excluded if desired. n and m may not be more than 9.

If the last parameter (after flattening) is a Throwable it is logged specially.

Parameters:
level - One of DEBUG, INFO, WARN, ERROR, FATAL
message - The message to log.
unflatParams - The objects to match against.


Copyright 2016 The Apache Software Foundation or its licensors, as applicable.