net.directj.jlogger
Class JLogger

java.lang.Object
  |
  +--java.lang.Thread
        |
        +--net.directj.jlogger.JLogger
All Implemented Interfaces:
java.lang.Runnable

public final class JLogger
extends java.lang.Thread

This class is the logging tool class. See the package documentation for how to use it.

Version:
0.2.3
Author:
CARTAPANIS Alexandre <earendil@jprolog.net>
To do:
Choose the best method to prevent the buffer to overflow (in the log method).

Field Summary
static int ALL
          The ALL logging level.
private  java.util.ArrayList buffer
          The String buffer that contains the debugging text.
static int BUFFER_MAXIMUM_SIZE
          The maximum buffer size.
private  int bufferSize
          The maximum size of the buffer.
static int DEBUG
          The DEBUG logging level.
static int DEBUG_TYPE
          The DEBUG logging information's type.
static int ERROR
          The ERROR logging level.
static int ERROR_TYPE
          The ERROR logging information's type.
static int FATAL
          The FATAL logging level.
static int FATAL_TYPE
          The FATAL logging information's type
static int INFO
          The INFO logging level.
static int INFO_TYPE
          The INFO logging information's type.
private  java.lang.String loggerName
          The logger name.
private  java.util.ArrayList managers
          The log manager list.
private  int nbrManager
          The number of manager associated with the logger.
static int OFF
          The OFF logging level.
static int WARNING
          The WARNING logging level.
static int WARNING_TYPE
          The WARNING logging information's type.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
protected JLogger(java.lang.String _name)
          Creates a new Logger, with a specified name.
protected JLogger(java.lang.String _name, int _bufferSize)
          Creates a new Logger, with a specified name.
 
Method Summary
 void addLogManager(LogManager _manager)
          Adds a new LogManager to the list of manager.
 void debug(java.lang.String _message)
          Prints information with a DEBUG type.
 void debug(java.lang.String _message, java.lang.Throwable _excp)
          Prints information with a DEBUG type, then print the exception.
 void error(java.lang.String _message)
          Prints information with a ERROR type.
 void error(java.lang.String _message, java.lang.Throwable _excp)
          Prints information with a ERROR type, then print the exception.
 void exception(int _lvl, java.lang.Throwable _excp)
          Prints an exception or an error, with an specified type.
 void fatal(java.lang.String _message)
          Prints information with a FATAL type.
 void fatal(java.lang.String _message, java.lang.Throwable _excp)
          Prints information with a FATAL type, then print the exception.
 java.util.Collection getAllLogManager()
          Returns a collection that contain all the log manager
 java.lang.String getLoggerName()
          Returns the name of this logger instance.
 LogManager getLogManager(int _index)
          Returns the _indexth log manager.
 void info(java.lang.String _message)
          Prints information with a INFO type.
 void info(java.lang.String _message, java.lang.Throwable _excp)
          Prints information with a DEBUG type, then print the exception.
 void log(int _type, java.lang.String _msg)
          This is the method that is used to publish the informations.
 void removeLogManager(LogManager _manager)
          Removes the specified LogManager to the list of manager.
 void warning(java.lang.String _message)
          Prints information with a WARNING type.
 void warning(java.lang.String _message, java.lang.Throwable _excp)
          Prints information with a WARNING type, then print the exception.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALL

public static final int ALL
The ALL logging level.

See Also:
Constant Field Values

DEBUG

public static final int DEBUG
The DEBUG logging level.

See Also:
Constant Field Values

INFO

public static final int INFO
The INFO logging level.

See Also:
Constant Field Values

WARNING

public static final int WARNING
The WARNING logging level.

See Also:
Constant Field Values

ERROR

public static final int ERROR
The ERROR logging level.

See Also:
Constant Field Values

FATAL

public static final int FATAL
The FATAL logging level.

See Also:
Constant Field Values

OFF

public static final int OFF
The OFF logging level.

See Also:
Constant Field Values

DEBUG_TYPE

public static final int DEBUG_TYPE
The DEBUG logging information's type.

See Also:
Constant Field Values

INFO_TYPE

public static final int INFO_TYPE
The INFO logging information's type.

See Also:
Constant Field Values

WARNING_TYPE

public static final int WARNING_TYPE
The WARNING logging information's type.

See Also:
Constant Field Values

ERROR_TYPE

public static final int ERROR_TYPE
The ERROR logging information's type.

See Also:
Constant Field Values

FATAL_TYPE

public static final int FATAL_TYPE
The FATAL logging information's type

See Also:
Constant Field Values

BUFFER_MAXIMUM_SIZE

public static final int BUFFER_MAXIMUM_SIZE
The maximum buffer size.

See Also:
Constant Field Values

managers

private java.util.ArrayList managers
The log manager list.


buffer

private java.util.ArrayList buffer
The String buffer that contains the debugging text.


loggerName

private java.lang.String loggerName
The logger name.


nbrManager

private int nbrManager
The number of manager associated with the logger.


bufferSize

private int bufferSize
The maximum size of the buffer.

Constructor Detail

JLogger

protected JLogger(java.lang.String _name)
Creates a new Logger, with a specified name. This constructor normally cannot be called, you have to use the JLoggerFactory.getLogger() method.

Parameters:
_name - The logger name.
See Also:
JLoggerFactory.getLogger(String)

JLogger

protected JLogger(java.lang.String _name,
                  int _bufferSize)
Creates a new Logger, with a specified name. This constructor normally cannot be called, you have to use the JLoggerFactory.getLogger() method.

Parameters:
_name - The logger name.
_bufferSize - The maximum size of the trace buffer.
See Also:
JLoggerFactory.getLogger(String)
Method Detail

addLogManager

public final void addLogManager(LogManager _manager)
Adds a new LogManager to the list of manager.

Parameters:
_manager - The LogManager to add.

removeLogManager

public final void removeLogManager(LogManager _manager)
Removes the specified LogManager to the list of manager.

Parameters:
_manager - The LogManager to remove.

getAllLogManager

public final java.util.Collection getAllLogManager()
Returns a collection that contain all the log manager

Returns:
Collection - The managers collection.

getLogManager

public final LogManager getLogManager(int _index)
Returns the _indexth log manager. If the specified rank is not valid (_index < 0 || _index >= size()), then returns null.

Parameters:
_index - The rank of the manager we want.
Returns:
LogManager - The _indexth log manager, or null.

getLoggerName

public final java.lang.String getLoggerName()
Returns the name of this logger instance.

Returns:
String - The logger name.

log

public final void log(int _type,
                      java.lang.String _msg)
This is the method that is used to publish the informations. It create a log record, store the informations into a buffer, transform and publish them. If the logger is not running, then the informations are stored into the buffer, but thay are not publish.

Parameters:
_type - The logging information level.
_msg - The logging information.

exception

public void exception(int _lvl,
                      java.lang.Throwable _excp)
Prints an exception or an error, with an specified type. Used by all the debug, warning, info, error and fatal method.

Parameters:
_lvl - The level of the exception.
_excp - The catched throwable object.

debug

public void debug(java.lang.String _message)
Prints information with a DEBUG type.

Parameters:
_message - The information.

debug

public void debug(java.lang.String _message,
                  java.lang.Throwable _excp)
Prints information with a DEBUG type, then print the exception.

Parameters:
_message - The information.
_excp - The exception that justify the message.

info

public void info(java.lang.String _message)
Prints information with a INFO type.

Parameters:
_message - The information.

info

public void info(java.lang.String _message,
                 java.lang.Throwable _excp)
Prints information with a DEBUG type, then print the exception.

Parameters:
_message - The information.
_excp - The exception that justify the message.

warning

public void warning(java.lang.String _message)
Prints information with a WARNING type.

Parameters:
_message - The information.

warning

public void warning(java.lang.String _message,
                    java.lang.Throwable _excp)
Prints information with a WARNING type, then print the exception.

Parameters:
_message - The information.
_excp - The exception that justify the message.

error

public void error(java.lang.String _message)
Prints information with a ERROR type.

Parameters:
_message - The information.

error

public void error(java.lang.String _message,
                  java.lang.Throwable _excp)
Prints information with a ERROR type, then print the exception.

Parameters:
_message - The information.
_excp - The exception that justify the message.

fatal

public void fatal(java.lang.String _message)
Prints information with a FATAL type.

Parameters:
_message - The information.

fatal

public void fatal(java.lang.String _message,
                  java.lang.Throwable _excp)
Prints information with a FATAL type, then print the exception.

Parameters:
_message - The information.
_excp - The exception that justify the message.


Copyright 2002 CARTAPANIS Alexandre
This page was last updated on May 10 2003