© 2002 BEA Systems, Inc.


com.bea.commerce.ebusiness.discount.util
Class Log

java.lang.Object
  |
  +--com.bea.commerce.ebusiness.discount.util.Log

public class Log
extends java.lang.Object

This class provides some very simple logging interfaces. Everything is static, so just call Log.info(), etc. All static methods for this Singleton service.


Field Summary
static boolean consoleMode
          flag for logging to console in addition to log file
static java.lang.String logDir
          Directory holding log output
static java.lang.String logFile
          The name of the file holding log output
static java.io.PrintWriter logWriter
          output for stderr console logging
static java.io.PrintWriter stderrWriter
          output for stderr console logging
static java.io.PrintWriter stdoutWriter
          output for stdout console logging
static java.lang.String T_SEP
           
 
Constructor Summary
Log()
           
 
Method Summary
static void clearConsole()
          Sets the consoleMode flag to false stopping logging to the tty.
static java.lang.String currentTime()
           
static void debug(java.lang.Object o, java.lang.String s)
          Sends string (prepended with class name) to debug log with newline
static void debug(java.lang.String s)
          Sends string to debug log with newline
static void debug(java.lang.String s, boolean newline)
          Sends string to debug log with optional newline
static void debug(java.lang.Throwable e)
          Prints a stackTrace for the given exception to error log
static void error(java.lang.Object o, java.lang.String s)
          Sends string (prepended with class name) to error log with newline
static void error(java.lang.String s)
          Sends string to error log with newline
static void error(java.lang.String s, boolean newline)
          Sends string to error log with optional newline
static void error(java.lang.Throwable e)
          Prints a stackTrace for the given exception to error log
static void exception(java.lang.Throwable e)
          Prints a stackTrace for the given exception to error log
static void fatal(java.lang.String s, int exitVal)
          WARNING: calls System.exit() to kill the VM
static void fatal(java.lang.Throwable e, int exitVal)
          WARNING: calls System.exit() to kill the VM
static java.io.PrintWriter getPrintWriter()
          Synchronize on this writer if used in a multi-threaded environment.
static java.lang.String getStackTrace(java.lang.Throwable e)
           
static java.io.PrintWriter getStderrWriter()
          Synchronize on this writer if used in a multi-threaded environment.
static java.io.PrintWriter getStdoutWriter()
          Synchronize on this writer if used in a multi-threaded environment.
static void info(java.lang.String s)
          Sends string to info log with newline
static void info(java.lang.String s, boolean newline)
          Sends string to info log with optional newline
static void printCurrentTime(java.io.PrintWriter out)
           
static void printCurrentTime(java.io.PrintWriter out, boolean showThread)
           
static long profileFinish(java.lang.String taskName, long startTime)
          Logs the start, finished, and elapsed time for the given task For example,
static long profileFinish(java.lang.String taskName, long startTime, long finishTime, boolean verbose)
           
static long profileStart()
           
static void setConsole()
          Sets the console flag to true causing all logging to be sent to the tty
static void setConsole(boolean value)
          Sets the consoleMode flag controlling logging to the tty.
static java.io.PrintWriter setPrintWriter(java.io.PrintWriter writer)
          Synchronize on this writer if used in a multi-threaded environment.
static void stackTrace()
          Prints a stackTrace marking the current stack to error log
static void warn(java.lang.String s)
          Sends string to warn log with newline
static void warn(java.lang.String s, boolean newline)
          Sends string to warn log with optional newline
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logDir

public static java.lang.String logDir
Directory holding log output

logFile

public static java.lang.String logFile
The name of the file holding log output

stdoutWriter

public static java.io.PrintWriter stdoutWriter
output for stdout console logging

stderrWriter

public static java.io.PrintWriter stderrWriter
output for stderr console logging

logWriter

public static java.io.PrintWriter logWriter
output for stderr console logging

consoleMode

public static boolean consoleMode
flag for logging to console in addition to log file

T_SEP

public static final java.lang.String T_SEP
Constructor Detail

Log

public Log()
Method Detail

setConsole

public static void setConsole()
Sets the console flag to true causing all logging to be sent to the tty

clearConsole

public static void clearConsole()
Sets the consoleMode flag to false stopping logging to the tty.

setConsole

public static void setConsole(boolean value)
Sets the consoleMode flag controlling logging to the tty.

getStdoutWriter

public static java.io.PrintWriter getStdoutWriter()
Synchronize on this writer if used in a multi-threaded environment.

getStderrWriter

public static java.io.PrintWriter getStderrWriter()
Synchronize on this writer if used in a multi-threaded environment.

getPrintWriter

public static java.io.PrintWriter getPrintWriter()
Synchronize on this writer if used in a multi-threaded environment.

setPrintWriter

public static java.io.PrintWriter setPrintWriter(java.io.PrintWriter writer)
Synchronize on this writer if used in a multi-threaded environment.

profileStart

public static long profileStart()

Returns:
the startTime used in profileFinish

profileFinish

public static long profileFinish(java.lang.String taskName,
                                 long startTime)
Logs the start, finished, and elapsed time for the given task For example,
 long startTime = Log.profileStart();
 ...do some stuff...
 Log.profileFinish("MyApp.TaskName", startTime);
 

Parameters:
taskName - A short name for the task -- no spaces
startTime - from profileStart

profileFinish

public static long profileFinish(java.lang.String taskName,
                                 long startTime,
                                 long finishTime,
                                 boolean verbose)

info

public static void info(java.lang.String s)
Sends string to info log with newline

info

public static void info(java.lang.String s,
                        boolean newline)
Sends string to info log with optional newline

debug

public static void debug(java.lang.Throwable e)
Prints a stackTrace for the given exception to error log

debug

public static void debug(java.lang.Object o,
                         java.lang.String s)
Sends string (prepended with class name) to debug log with newline

debug

public static void debug(java.lang.String s)
Sends string to debug log with newline

debug

public static void debug(java.lang.String s,
                         boolean newline)
Sends string to debug log with optional newline

error

public static void error(java.lang.Object o,
                         java.lang.String s)
Sends string (prepended with class name) to error log with newline

error

public static void error(java.lang.String s)
Sends string to error log with newline

error

public static void error(java.lang.String s,
                         boolean newline)
Sends string to error log with optional newline

stackTrace

public static void stackTrace()
Prints a stackTrace marking the current stack to error log

exception

public static void exception(java.lang.Throwable e)
Prints a stackTrace for the given exception to error log

error

public static void error(java.lang.Throwable e)
Prints a stackTrace for the given exception to error log

fatal

public static void fatal(java.lang.Throwable e,
                         int exitVal)
WARNING: calls System.exit() to kill the VM

fatal

public static void fatal(java.lang.String s,
                         int exitVal)
WARNING: calls System.exit() to kill the VM

getStackTrace

public static java.lang.String getStackTrace(java.lang.Throwable e)

Returns:
String with stack trace information for given exception

warn

public static void warn(java.lang.String s)
Sends string to warn log with newline

warn

public static void warn(java.lang.String s,
                        boolean newline)
Sends string to warn log with optional newline

currentTime

public static java.lang.String currentTime()

Returns:
The current time and thread name formatted for logging

printCurrentTime

public static void printCurrentTime(java.io.PrintWriter out)

printCurrentTime

public static void printCurrentTime(java.io.PrintWriter out,
                                    boolean showThread)

© 2002 BEA Systems, Inc.

Copyright © 2002 BEA Systems, Inc. All Rights Reserved