irssibot.util.log
Class Log

java.lang.Object
  |
  +--irssibot.util.log.Log

public class Log
extends java.lang.Object

Logging system for IrssiBot.

Version:
$Name: $ $Revision: 1.8 $
Author:
Matti Dahlbom

Field Summary
static int DEBUG_HIGH
           
static int DEBUG_LOW
           
static int DEBUG_NORMAL
           
static int DEBUG_OFF
           
private static int debugLevel
          Current debug level
private static CommonLog logger
          Current logger
private static java.text.SimpleDateFormat sdf
          Date formatter for log messages
 
Constructor Summary
private Log()
          Disallow instantiating this class
 
Method Summary
static void debug(java.lang.Object obj, java.lang.String message)
          Prints a debug message to log with default debug level.
static void debug(java.lang.Object obj, java.lang.String message, int level)
          Prints a debug message via current logger with given debug level.
static void error(java.lang.Object obj, java.lang.String message)
          Prints an error message to log.
static java.lang.String getDateFormatString()
          Returns the current date format string.
static int getDebugLevel()
          Returns the current debug level.
static CommonLog getLogger()
          Returns the current logger.
static void info(java.lang.Object obj, java.lang.String message)
          Prints an info message to log.
static void init(CommonLog logger, java.lang.String dateFormatString)
          Initializes logging system with a given logger.
static void log(java.lang.Object obj, java.lang.Throwable t)
          Prints an error description to the log based on a Throwable causing the error.
private static void logMessage(java.lang.Object obj, java.lang.String prefix, java.lang.String message)
          Prints a logging message via current logger.
static void server(java.lang.String message)
          Prints a server message to log.
static int setDebugLevel(int level)
          Sets the debug level.
static void stop()
          Stops the current logger and deinits logging.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG_LOW

public static int DEBUG_LOW

DEBUG_NORMAL

public static int DEBUG_NORMAL

DEBUG_HIGH

public static int DEBUG_HIGH

DEBUG_OFF

public static int DEBUG_OFF

debugLevel

private static int debugLevel
Current debug level


sdf

private static java.text.SimpleDateFormat sdf
Date formatter for log messages


logger

private static CommonLog logger
Current logger

Constructor Detail

Log

private Log()
Disallow instantiating this class

Method Detail

init

public static void init(CommonLog logger,
                        java.lang.String dateFormatString)
Initializes logging system with a given logger.

Parameters:
logger - logger object to use

getLogger

public static CommonLog getLogger()
Returns the current logger.


getDateFormatString

public static java.lang.String getDateFormatString()
Returns the current date format string.


stop

public static void stop()
Stops the current logger and deinits logging.


setDebugLevel

public static int setDebugLevel(int level)
Sets the debug level.

Parameters:
level - new debug level
Returns:
old logging level
Throws:
java.lang.IllegalArgumentException - if level is out of range

getDebugLevel

public static int getDebugLevel()
Returns the current debug level.

Returns:
current debug level

logMessage

private static void logMessage(java.lang.Object obj,
                               java.lang.String prefix,
                               java.lang.String message)
Prints a logging message via current logger.

Parameters:
obj - the source of this log message
prefix - log message prefix
message - log message

debug

public static void debug(java.lang.Object obj,
                         java.lang.String message,
                         int level)
Prints a debug message via current logger with given debug level.

Parameters:
obj - the source of this log message
message - log message
level - log level to use
Throws:
java.lang.IllegalArgumentException - if level is out of range

debug

public static void debug(java.lang.Object obj,
                         java.lang.String message)
Prints a debug message to log with default debug level.

Parameters:
obj - the source of this log message
message - log message

info

public static void info(java.lang.Object obj,
                        java.lang.String message)
Prints an info message to log.

Parameters:
obj - the source of this log message
message - log message

error

public static void error(java.lang.Object obj,
                         java.lang.String message)
Prints an error message to log.

Parameters:
obj - the source of this log message
message - log message

server

public static void server(java.lang.String message)
Prints a server message to log. This must only be used by the bot core.

Parameters:
message - log message

log

public static void log(java.lang.Object obj,
                       java.lang.Throwable t)
Prints an error description to the log based on a Throwable causing the error. Use this method to log all uncatched exceptions.

Parameters:
obj - the source of this log message
t - the Throwable causing the error


IrssiBot (c) 2000-2002 Matti Dahlbom