org.mozilla.util
Class Log

java.lang.Object
  extended by org.mozilla.util.Log

public class Log
extends java.lang.Object

Logging facility.

Version:
$Id: Log.java,v 1.4 2007/01/17 11:43:43 edburns%acm.org Exp $
Author:
Keith Bernstein

Field Summary
static java.lang.String LOG
           
static java.lang.String LOG_STRINGS
           
static java.util.logging.Logger LOGGER
           
 
Constructor Summary
Log()
           
 
Method Summary
protected static java.lang.Object applicationNameWithTimeStamp()
           
static void enableTimestampPrefix(boolean enable)
          Incrememnts or decrements whether or not to prefix logged messages with a timestamp.
static java.lang.String getApplicationName()
          Returns the applicationName set by "setApplicationName()"
static java.lang.String getApplicationVersion()
          Returns the applicationVersion set by "setApplicationVersion()"
static java.lang.String getApplicationVersionDate()
          Returns the applicationVersion set by "setApplicationVersionDate()"
static java.util.logging.Logger getLogger(java.lang.String loggerName)
           
static void log(java.lang.Object infoMessage)
          Writes "infoMessage" to stdout, prefixed by the string "ApplicationName: "
static void logDebugMessage(java.lang.Object debugMessage)
          Equivalent to calling "logDebugMessage(debugMessage, "ALL")".
static void logDebugMessage(java.lang.Object debugMessage, boolean aCondition)
          Log a message when "aCondition" is true, otherwise be silent.
static void logDebugMessage(java.lang.Object anInstance, java.lang.Object debugMessage)
          Equivalent to calling "logDebugMessage(anInstance, debugMessage, "ALL")".
static void logDebugMessage(java.lang.Object anInstance, java.lang.Object debugMessage, boolean aCondition)
          Log a message when "aCondition" is true, otherwise be silent.
static void logDebugMessage(java.lang.Object anInstance, java.lang.Object debugMessage, java.lang.String debugFilter)
          Writes "debugMessage" to stderr, prefixed by the string "ApplicationName: ClassName[0xhashCode]: " *
static void logDebugMessage(java.lang.Object debugMessage, java.lang.String debugFilter)
          Funnel-point method for printing debug messages.
static void logError(java.lang.Object errorMessage)
          Writes "errorMessage" to stderr, prefixed by the string "ApplicationName error: "
static void logErrorMessage(java.lang.Object errorMessage)
          Writes "errorMessage" to stderr, prefixed by the string "ApplicationName: "
static void setApplicationName(java.lang.String newApplicationName)
          This string will be prepended to all output from this class.
static void setApplicationVersion(java.lang.String newApplicationVersion)
           
static void setApplicationVersionDate(java.lang.String newApplicationVersionDate)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_STRINGS

public static final java.lang.String LOG_STRINGS
See Also:
Constant Field Values

LOG

public static final java.lang.String LOG
See Also:
Constant Field Values

LOGGER

public static final java.util.logging.Logger LOGGER
Constructor Detail

Log

public Log()
Method Detail

getLogger

public static java.util.logging.Logger getLogger(java.lang.String loggerName)

setApplicationName

public static void setApplicationName(java.lang.String newApplicationName)

This string will be prepended to all output from this class.

This string is usually the application name, e.g. "JavaPlan".

It is useful because it includes a timestamp and the base string (usually the application name), so that if two apps are launched from the same commandline (for example), with "&", or one app invokes another, it is clear who the message is comming from. The time stamp can help see how long operations took, etc.

If you don't want your messages prefixed with anything (no time stamp or name), you must pass "null" for "applicationName".

If this method is never called, "applicationName" will default to: "APPLICATION NAME UNKNOWN [call setApplicationName from main]"


getApplicationName

public static java.lang.String getApplicationName()
Returns the applicationName set by "setApplicationName()"


setApplicationVersion

public static void setApplicationVersion(java.lang.String newApplicationVersion)

getApplicationVersion

public static java.lang.String getApplicationVersion()
Returns the applicationVersion set by "setApplicationVersion()"


setApplicationVersionDate

public static void setApplicationVersionDate(java.lang.String newApplicationVersionDate)

getApplicationVersionDate

public static java.lang.String getApplicationVersionDate()
Returns the applicationVersion set by "setApplicationVersionDate()"


applicationNameWithTimeStamp

protected static java.lang.Object applicationNameWithTimeStamp()

enableTimestampPrefix

public static void enableTimestampPrefix(boolean enable)
Incrememnts or decrements whether or not to prefix logged messages with a timestamp. Two (or "n") calls with a value of "false" must be followed by two (or "n") calls with a value of "true" to reenable timestamp prefixes.


log

public static void log(java.lang.Object infoMessage)
Writes "infoMessage" to stdout, prefixed by the string "ApplicationName: "


logError

public static void logError(java.lang.Object errorMessage)
Writes "errorMessage" to stderr, prefixed by the string "ApplicationName error: "


logErrorMessage

public static void logErrorMessage(java.lang.Object errorMessage)
Writes "errorMessage" to stderr, prefixed by the string "ApplicationName: "


logDebugMessage

public static void logDebugMessage(java.lang.Object debugMessage,
                                   java.lang.String debugFilter)

Funnel-point method for printing debug messages.

Writes "debugMessage" to stderr, prefixed by the string "ApplicationName:"

This method only works if the debugFilter string is found in Debug's list of filter strings (which you can normally set on the commandline, see JDApplication), or if the "ALL" filter has been set into Debug's list of filters, or if the passed in filter is "", which is considered to always be "set", and will print a line with "[DEBUG]" listed as the filter.

This method may be called with a "null" debugMessage. A debugMessage is sometimes unneccesary since the matched filter string is printed with the output anyway, and that is frequently enough information.


logDebugMessage

public static void logDebugMessage(java.lang.Object debugMessage)
Equivalent to calling "logDebugMessage(debugMessage, "ALL")".


logDebugMessage

public static void logDebugMessage(java.lang.Object debugMessage,
                                   boolean aCondition)
Log a message when "aCondition" is true, otherwise be silent. Equivalent to calling "if (aCondition) logDebugMessage(debugMessage, "")".


logDebugMessage

public static void logDebugMessage(java.lang.Object anInstance,
                                   java.lang.Object debugMessage,
                                   boolean aCondition)
Log a message when "aCondition" is true, otherwise be silent.


logDebugMessage

public static void logDebugMessage(java.lang.Object anInstance,
                                   java.lang.Object debugMessage)
Equivalent to calling "logDebugMessage(anInstance, debugMessage, "ALL")".


logDebugMessage

public static void logDebugMessage(java.lang.Object anInstance,
                                   java.lang.Object debugMessage,
                                   java.lang.String debugFilter)
Writes "debugMessage" to stderr, prefixed by the string "ApplicationName: ClassName[0xhashCode]: " *



Copyright © 2002-2005 Mozilla.org All Rights Reserved.