WebObjects 5.2.3

com.webobjects.foundation
Class NSLog.Logger

java.lang.Object
  extended bycom.webobjects.foundation.NSLog.Logger
Direct Known Subclasses:
NSLog.Log4JLogger, NSLog.PrintStreamLogger
Enclosing class:
NSLog

public abstract static class NSLog.Logger
extends Object

NSLog.Logger is an abstract class that specifies the core functionality for NSLog.
You can subclass NSLog.Logger to add custom logging implementations based on email, java.io.PrintWriters, display to a Swing window, etc. To add custom logging implementations based on java.io.PrintStream, subclass NSLog.PrintStreamLogger. If you subclass NSLog.Logger, you need only implement two of the appendln methods: appendln(Object), and appendln(), since the other appendln methods invoke appendln(Object) and appendln(). You must also implement flush() if you subclass.

See Also:
NSLog, NSLog.Log4JLogger, NSLog.PrintStreamLogger

Field Summary
protected  int debugLevel
           
protected  boolean isEnabled
           
protected  boolean isVerbose
           
 
Constructor Summary
NSLog.Logger()
          The default constructor for Logger does nothing.
 
Method Summary
 int allowedDebugLevel()
          Indicates the debug level for this NSLog.Logger instance.
abstract  void appendln()
          Since this is an abstract method, it does nothing by default.
 void appendln(boolean aValue)
          Calls appendln(Object), passing Boolean.TRUE if aValue is true, or Boolean.FALSE if aValue is false.
 void appendln(byte aValue)
          Transforms aValue into a java.lang.Byte object, and passes it to appendln(Object).
 void appendln(byte[] aValue)
          Transforms aValue into a java.lang.String object using the default encoding, and passes it to appendln(Object).
 void appendln(char aValue)
          Transforms aValue into a java.lang.String object, and passes it to appendln(Object).
 void appendln(char[] aValue)
          Transforms aValue into a java.lang.String object, and passes it to appendln(Object).
 void appendln(double aValue)
          Transforms aValue into a java.lang.Double object, and passes it to appendln(Object).
 void appendln(float aValue)
          Transforms aValue into a java.lang.Float object, and passes it to appendln(Object).
 void appendln(int aValue)
          Transforms aValue into a java.lang.Integer object, and passes it to appendln(Object).
 void appendln(long aValue)
          Transforms aValue into a java.lang.Long object, and passes it to appendln(Object).
abstract  void appendln(Object aValue)
          Since this is an abstract method, it does nothing by default.
 void appendln(short aValue)
          Transforms aValue into a java.lang.Short object, and passes it to appendln(Object).
 void appendln(Throwable aValue)
          Calls appendln(Object) with NSLog.throwableAsString(aValue) as an argument.
abstract  void flush()
          Since this is an abstract method, it does nothing by default.
 boolean isEnabled()
          Provides the state of an internal boolean that regulates whether logging is enabled or disabled.
 boolean isVerbose()
          Provides the state of an internal boolean that regulates whether verbose logging is activated or deactivated.
 void setAllowedDebugLevel(int aDebugLevel)
          Sets the debug level to aDebugLevel.
 void setIsEnabled(boolean aBool)
          Sets the value of an internal boolean to aBool.
 void setIsVerbose(boolean aBool)
          Sets the value of an internal boolean to aBool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debugLevel

protected int debugLevel

isEnabled

protected boolean isEnabled

isVerbose

protected boolean isVerbose
Constructor Detail

NSLog.Logger

public NSLog.Logger()
The default constructor for Logger does nothing. By default, allowedDebugLevel is DebugLevelOff, and both isEnabled and isVerbose return true.

Method Detail

allowedDebugLevel

public int allowedDebugLevel()
Indicates the debug level for this NSLog.Logger instance. Ignore this setting for any NSLog.Logger except the one assigned to NSLog.debug.

NOTE: Before invoking any of the appendln methods on NSLog.debug, check one of the NSLog.debugLoggingAllowedFor... methods. The aforementioned NSLog class methods invoke NSLog.debug.allowedDebugLevel. Otherwise, the debug level would be useless. This usage pattern is the only one provided, because methods that encapsulate the check whether to log actually slow execution by an order of magnitude when logging is disabled.

Returns:
level of debug required
See Also:
setAllowedDebugLevel(int), NSLog.debugLoggingAllowedForGroups(long), NSLog.debugLoggingAllowedForLevel(int), NSLog.debugLoggingAllowedForLevelAndGroups(int, long)

appendln

public void appendln(boolean aValue)
Calls appendln(Object), passing Boolean.TRUE if aValue is true, or Boolean.FALSE if aValue is false.

Parameters:
aValue - boolean value to append to output
See Also:
appendln(Object)

appendln

public void appendln(byte aValue)
Transforms aValue into a java.lang.Byte object, and passes it to appendln(Object).

Parameters:
aValue - byte value to append to output
See Also:
appendln(Object)

appendln

public void appendln(byte[] aValue)
Transforms aValue into a java.lang.String object using the default encoding, and passes it to appendln(Object).

Parameters:
aValue - byte array to append to output
See Also:
appendln(Object)

appendln

public void appendln(char aValue)
Transforms aValue into a java.lang.String object, and passes it to appendln(Object).

Parameters:
aValue - char value to append to output
See Also:
appendln(Object)

appendln

public void appendln(char[] aValue)
Transforms aValue into a java.lang.String object, and passes it to appendln(Object).

Parameters:
aValue - char array to append to output
See Also:
appendln(Object)

appendln

public void appendln(double aValue)
Transforms aValue into a java.lang.Double object, and passes it to appendln(Object).

Parameters:
aValue - double value to append to output
See Also:
appendln(Object)

appendln

public void appendln(float aValue)
Transforms aValue into a java.lang.Float object, and passes it to appendln(Object).

Parameters:
aValue - float value to append to output
See Also:
appendln(Object)

appendln

public void appendln(int aValue)
Transforms aValue into a java.lang.Integer object, and passes it to appendln(Object).

Parameters:
aValue - int value to append to output
See Also:
appendln(Object)

appendln

public void appendln(long aValue)
Transforms aValue into a java.lang.Long object, and passes it to appendln(Object).

Parameters:
aValue - long value to append to output
See Also:
appendln(Object)

appendln

public void appendln(short aValue)
Transforms aValue into a java.lang.Short object, and passes it to appendln(Object).

Parameters:
aValue - short value to append to output
See Also:
appendln(Object)

appendln

public void appendln(Throwable aValue)
Calls appendln(Object) with NSLog.throwableAsString(aValue) as an argument.

Parameters:
aValue - the Throwable object to append to output
See Also:
appendln(Object)

appendln

public abstract void appendln(Object aValue)
Since this is an abstract method, it does nothing by default. It's up to the subclass to implement the behavior. Note that this method may represent a race condition, so implementations of this method must either be declared synchronized or otherwise be designed to be thread-safe.

Parameters:
aValue - the object to be appended to the output
See Also:
NSLog.Log4JLogger.appendln(Object), NSLog.PrintStreamLogger.appendln(Object)

appendln

public abstract void appendln()
Since this is an abstract method, it does nothing by default.

See Also:
NSLog.Log4JLogger.appendln(), NSLog.PrintStreamLogger.appendln()

flush

public abstract void flush()
Since this is an abstract method, it does nothing by default.

See Also:
NSLog.Log4JLogger.flush(), NSLog.PrintStreamLogger.flush()

isEnabled

public boolean isEnabled()
Provides the state of an internal boolean that regulates whether logging is enabled or disabled. When logging is disabled, the NSLog.Logger subclass instance should ignore all invocations of appendln. By default, logging is enabled. Note that it is up to subclass implementations to pay attention to this setting, as NSLog.Logger does nothing but maintain state in an instance variable. Typically this instance variable is accessed directly, rather than through this method.

Returns:
the value of an internal boolean, which defaults to true
See Also:
setIsEnabled(boolean)

isVerbose

public boolean isVerbose()
Provides the state of an internal boolean that regulates whether verbose logging is activated or deactivated. When logging is verbose, the NSLog.Logger subclass instance should provide additional information, such as a prefix including the timestamp and thread ID.

Note that it is up to subclass implementations to pay attention to this setting, as NSLog.Logger does nothing but maintain state in an instance variable. Typically this instance variable is accessed directly, rather than through this method.

By default, verbose logging is enabled, except for the default NSLog.PrintStreamLogger object provided initially to NSLog.out.

Returns:
the value of an internal boolean, which defaults to true
See Also:
setIsVerbose(boolean)

setAllowedDebugLevel

public void setAllowedDebugLevel(int aDebugLevel)
Sets the debug level to aDebugLevel. Ignore this setting for any NSLog.Logger except the one assigned to NSLog.debug. Typically, this method is invoked at the beginning of the application execution, since it affects logging behavior in the entire application.

By default, logging is allowed for all debug groups. If the debug level is set to be high (for example, DebugLevelDetailed), the debugging output may be overwhelming.

NOTE: NSLog stores no state regarding debug level. If you replace NSLog.debug using setDebug(Logger), you must invoke NSLog.debug.setAllowedDebugLevel. Otherwise, use setDebug(Logger, int).

Parameters:
aDebugLevel - level of debug required
Throws:
IllegalArgumentException - if aDebugLevel is invalid
See Also:
allowedDebugLevel(), NSLog#setDebug(Logger), NSLog#setDebug(Logger, int)

setIsEnabled

public void setIsEnabled(boolean aBool)
Sets the value of an internal boolean to aBool.

Parameters:
aBool - true to activate logging for this NSLog.Logger instance, otherwise false
See Also:
isEnabled()

setIsVerbose

public void setIsVerbose(boolean aBool)
Sets the value of an internal boolean to aBool.

Parameters:
aBool - true to activate verbose logging for this NSLog.Logger instance, otherwise false
See Also:
isVerbose()

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.