WebObjects 5.2

com.webobjects.foundation
Class NSLog.PrintStreamLogger

java.lang.Object
  |
  +--com.webobjects.foundation.NSLog.Logger
        |
        +--com.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 receiver to output log messages somewhere else, such as a local file. Methods are provided to enable and disable logging, and to enable and disable verbose logging.

NSLog.out is a PrintStreamLogger that point at System.out, and has verbose logging disabled. NSLog.err and NSLog.debug are PrintStreamLoggers that points to System.err, and have verbose logging enabled.

NSLog.PrintStreamLogger looks at the value of the internal variables set by NSLog.Logger.setIsVerbose() and NSLog.Logger.setIsEnabled() to determine whether to produce verbose output and to determine whether to log messages to the logger. Verbose logging produces output of the format: "[Current Time] <Current Thread Name> output ".

See Also:
NSLog, NSLog.Logger

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()
          Writes a new line to the receiver's PrintStream, if isEnabled returns true.
 void appendln(Object aValue)
          Writes aValue to the receiver's PrintStream.
 void appendln(Throwable aValue)
          Writes the stack trace of aValue to the receiver's PrintStream.
 void flush()
          Invokes the underlying PrintStream'sflush method.
 PrintStream printStream()
           
 void setPrintStream(PrintStream aStream)
          Sets the receiver's print stream to aPrintStream.
 
Methods inherited from class com.webobjects.foundation.NSLog.Logger
appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, appendln, isEnabled, isVerbose, 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.

NSLog.PrintStreamLogger

public NSLog.PrintStreamLogger(PrintStream ps)
Creates a new NSLog.PrintStreamLogger which directs output to ps. Throws an IllegalArgumentException if aPrintStream is null.
Parameters:
ps - the PrintSteam to direct output to
Throws:
IllegalArgumentException - if the input string is null.
Method Detail

appendln

public void appendln()
Writes a new line to the receiver's PrintStream, if isEnabled returns true.
Overrides:
appendln in class NSLog.Logger

appendln

public void appendln(Throwable aValue)
Writes the stack trace of aValue to the receiver's PrintStream. This is overridden here for efficiency.
Overrides:
appendln in class NSLog.Logger
Parameters:
aValue - the message to be appended with the Java object

appendln

public void appendln(Object aValue)
Writes aValue to the receiver's PrintStream. This method appends the string representation of aValue to the logging output, potentially surrounded by the verbose prefix.
For example, a generic object passed to this method might output "java.lang.Object@67e5d". The string representation is derived from the toString method of the object.
PrintStreamLogger uses the values for both isEnabled and isVerbose to determine what to output.
Overrides:
appendln in class NSLog.Logger
Parameters:
aValue - the Java object to be appended

flush

public void flush()
Invokes the underlying PrintStream'sflush method.
Overrides:
flush in class NSLog.Logger

printStream

public PrintStream printStream()
Returns:
the receiver's PrintStream

setPrintStream

public void setPrintStream(PrintStream aStream)
Sets the receiver's print stream to aPrintStream. This redirects all of the receiver's output.
Parameters:
aStream - the input print stream

Last updated Fri Feb 21 13:15:00 PST 2003.

Copyright © 2003 Apple Computer, Inc.