WebObjects 5.2.3

com.webobjects.foundation
Class NSLog.PrintStreamLogger

java.lang.Object
  extended bycom.webobjects.foundation.NSLog.Logger
      extended bycom.webobjects.foundation.NSLog.PrintStreamLogger
Enclosing class:
NSLog

public static class NSLog.PrintStreamLogger
extends NSLog.Logger

NSLog.PrintStreamLogger is a concrete subclass of NSLog.Logger. It logs output to a java.io.PrintStream which is contained by the logger. This PrintStream can be changed, which causes the logger to direct log messages somewhere else, such as a local file. NSLog.PrintStreamLogger provides additional method behavior for verbose logging.

By default, NSLog.out is an NSLog.PrintStreamLogger that points at System.out with verbose logging disabled. NSLog.err and NSLog.debug are NSLog.PrintStreamLoggers that point to System.err with verbose logging enabled.

Verbose logging produces output of the format: [Current Time] <Current Thread Name> output

See Also:
NSLog, NSLog.Logger

Field Summary
 
Fields inherited from class com.webobjects.foundation.NSLog.Logger
debugLevel, isEnabled, isVerbose
 
Constructor Summary
NSLog.PrintStreamLogger()
          Creates a new NSLog.PrintStreamLogger which directs output to System.out.
NSLog.PrintStreamLogger(PrintStream ps)
          Creates a new NSLog.PrintStreamLogger which directs output to ps.
 
Method Summary
 void appendln()
          Invokes println() and flush on printStream, if isEnabled returns true.
 void appendln(Object aValue)
          Writes the string representation of aValue to printStream, if isEnabled returns true.
 void appendln(Throwable aValue)
          Writes the stack trace of aValue to printStream, if isEnabled returns true.
 void flush()
          Invokes flush on printStream.
 PrintStream printStream()
          Provides the PrintStream wrapped by this NSLog.Logger instance.
 void setPrintStream(PrintStream aStream)
          Redirects all output for this NSLog.Logger instance to aStream.
 
Methods inherited from class com.webobjects.foundation.NSLog.Logger
allowedDebugLevel, appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, isEnabled, isVerbose, setAllowedDebugLevel, setIsEnabled, setIsVerbose
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NSLog.PrintStreamLogger

public NSLog.PrintStreamLogger()
Creates a new NSLog.PrintStreamLogger which directs output to System.out.

See Also:
NSLog.Logger#()

NSLog.PrintStreamLogger

public NSLog.PrintStreamLogger(PrintStream ps)
Creates a new NSLog.PrintStreamLogger which directs output to ps.

Parameters:
ps - the PrintSteam that may accept output
Throws:
IllegalArgumentException - if ps is null
See Also:
#(), NSLog.Logger#()
Method Detail

appendln

public void appendln()
Invokes println() and flush on printStream, if isEnabled returns true.

Specified by:
appendln in class NSLog.Logger
See Also:
NSLog.Logger.isEnabled, printStream(), NSLog.Logger.appendln()

appendln

public void appendln(Throwable aValue)
Writes the stack trace of aValue to printStream, if isEnabled returns true. This is overridden here for efficiency.

Prefixes the stack trace if isVerbose returns true.

Overrides:
appendln in class NSLog.Logger
Parameters:
aValue - the exception to log
See Also:
NSLog.Logger.isEnabled, NSLog.Logger.isVerbose, printStream(), NSLog.Logger.appendln(Throwable)

appendln

public void appendln(Object aValue)
Writes the string representation of aValue to printStream, if isEnabled returns true.

For example, a generic object passed to this method might output "java.lang.Object@67e5d". The toString method of aValue provides the string representation.

Prefixes the string representation if isVerbose returns true.

Specified by:
appendln in class NSLog.Logger
Parameters:
aValue - the object to log
See Also:
NSLog.Logger.isEnabled, NSLog.Logger.isVerbose, printStream(), NSLog.Logger.appendln(Object)

flush

public void flush()
Invokes flush on printStream.

Specified by:
flush in class NSLog.Logger
See Also:
NSLog.Logger.flush()

printStream

public PrintStream printStream()
Provides the PrintStream wrapped by this NSLog.Logger instance.

Returns:
a java.io.PrintStream; never null
See Also:
#(), #(java.io.PrintStream), setPrintStream(java.io.PrintStream)

setPrintStream

public void setPrintStream(PrintStream aStream)
Redirects all output for this NSLog.Logger instance to aStream. No change is made if aStream is null.

Parameters:
aStream - the input print stream
See Also:
printStream()

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

Copyright © 2004 Apple Computer, Inc.