org.opennms.bb.common.components
Class Log

java.lang.Object
  |
  +--org.opennms.bb.common.components.Log

public class Log
extends Object

Log is an utility class that allows an application to print logs and errors either to the standard out or to output file

Author:
Sowmya

Field Summary
static int DEBUG
           
static int ERROR
           
static int FATAL
          Log levels: A 'INFORMATIONAL'(default) indicates that all output log statements are put out A 'WARNING' indicates that only statements of the loglevel 'WARNING' or lower are to be printed A 'ERROR' indicates that only statements of the loglevel 'ERROR' or lower are to be printed A 'FATAL' indicates that only statements indicating fatal errors are to be printed
static int INFORMATIONAL
           
private static boolean m_bLog
          Boolean flag that allows logging to be turned on or off
private static int m_level
          the log level
private static String[] m_levelText
           
private static PrintStream m_printStreamOut
          The actual print stream - is set to standard out by default but can be set to point to a file
static int SPILLGUTS
           
static int WARNING
           
 
Constructor Summary
private Log()
          Disallow instantiating this class
 
Method Summary
static void disable()
          Sets the logging off
static void enable()
          Sets the logging on
static void print(int level, Exception e)
          Prints the exeception to the log, including the stack trace from the exception.
static void print(int level, Object obj)
          Print to stdout or to the output file
static void print(int level, String outline)
          Print to stdout or to the output file
static void setLevel(int level)
          Sets log level
static void setOut(PrintStream output)
          Sets the printstream passed as the output stream
static void setOut(String fileName)
          Sets the output stream so as to send output to the filename
private static String showLevel(int lvl)
          Returns the levels textual level!
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

FATAL

public static final int FATAL
Log levels:
 A 'INFORMATIONAL'(default) indicates that all output log 
 statements  are put out

 A 'WARNING' indicates that only statements of the
 loglevel 'WARNING' or lower are to be printed

 A 'ERROR' indicates that only statements of the
 loglevel 'ERROR' or lower are to be printed

 A 'FATAL' indicates that only statements indicating fatal 
 errors are to be printed

ERROR

public static final int ERROR

WARNING

public static final int WARNING

INFORMATIONAL

public static final int INFORMATIONAL

DEBUG

public static final int DEBUG

SPILLGUTS

public static final int SPILLGUTS

m_levelText

private static final String[] m_levelText

m_level

private static int m_level
the log level

m_bLog

private static boolean m_bLog
Boolean flag that allows logging to be turned on or off

m_printStreamOut

private static PrintStream m_printStreamOut
The actual print stream - is set to standard out by default but can be set to point to a file
Constructor Detail

Log

private Log()
     throws UnsupportedOperationException
Disallow instantiating this class
Method Detail

showLevel

private static String showLevel(int lvl)

Returns the levels textual level!


setOut

public static void setOut(String fileName)
                   throws IOException
Sets the output stream so as to send output to the filename
Parameters:
fileName - name of the file to which output is to be redirected

setOut

public static void setOut(PrintStream output)
Sets the printstream passed as the output stream
Parameters:
output - print stream to be set as output stream

enable

public static void enable()
Sets the logging on

disable

public static void disable()
Sets the logging off

setLevel

public static void setLevel(int level)
Sets log level
Parameters:
level - level to set the logging to
Throws:
IOException - thrown if level is not recognized

print

public static void print(int level,
                         String outline)
Print to stdout or to the output file
Parameters:
outline - String to be printed out

print

public static void print(int level,
                         Exception e)

Prints the exeception to the log, including the stack trace from the exception.

Parameters:
level - The log level of the exception.
e - The exception and its stack trace to log.

print

public static void print(int level,
                         Object obj)
Print to stdout or to the output file
Parameters:
obj - Object to be printed out