All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.ibm.beans.util.LogStream

java.lang.Object
   |
   +----java.io.OutputStream
           |
           +----java.io.FilterOutputStream
                   |
                   +----java.io.PrintStream
                           |
                           +----com.ibm.beans.util.LogStream

public class LogStream
extends PrintStream
The LogStream class presents a mechanism for logging messages. The default OutputStream instance for any LogStream instance is System.err, but each LogStream instance can be set to write to any OutputStream instance.

Because the LogStream class inherits from the PrintStream class, all the println methods available from the PrintStream class are available here. Only the println methods should be used to print to a LogStream instance. The println methods result in a single write to the OutputStream instance. This single write produces better, cleaner output when used in a distributed environment.


Variable Index

 o BRIEF
Logging level constant that means the prefix is not added to the message.
 o buffer
StringBuffer used for constructing log message prefixes.
 o bufOut
Stream used for buffering lines.
 o closeWhenThrough
Flag to indicate if the current OutputStream instance will be flushed or closed when changing to a new OutputStream instance.
 o dateFormatter
Date formatter to format the date in the current locale.
 o defaultStream
Default OutputStream instance for new logs.
 o known
Table mapping of known log names to LogStream instances.
 o lineSeparator
Line separator character.
 o loggingLevel
Flag to indicate the style of the logging level.
 o logOut
This log sends all output to this OutputStream instance.
 o logWriter
Writer used for writing to the LogStream instance.
 o name
Name for this log.
 o SILENT
Logging level constant that means nothing is written.
 o VERBOSE
Logging level constant that means the prefix and message are printed to the OutputStream instance.
 o writeIdentifierToLog
Flag to indicate if the identifier will be written to the log as part of the log prefix.

Method Index

 o getCloseWhenThrough()
Returns the flag that indicates if the current OutputStream instance will be flushed or closed when changing to a new OutputStream instance.
 o getDefaultStream()
Returns the current default stream for new logs.
 o getLoggingLevel()
Returns the logging level of this LogStream instance.
 o getOutputStream()
Returns the OutputStream instance for this log.
 o getWriteIdentifierToLog()
Returns the flag that indicates if the identifier will be written to the log prefix.
 o log(String)
Returns the LogStream instance identified by the given name.
 o println(MessageFormatter, String)
Prints a line containing the String retrieved from the ResourceBundle.
 o println(MessageFormatter, String, Object)
Prints a line containing the String retrieved from the ResourceBundle.
 o println(MessageFormatter, String, Object, Object)
Prints a line containing the String retrieved from the ResourceBundle.
 o println(MessageFormatter, String, Object, Object, Object)
Prints a line containing the String retrieved from the ResourceBundle.
 o setCloseWhenThrough(boolean)
Sets the flag that indicates if the current OutputStream instance will be flushed or closed when changing to a new OutputStream instance.
 o setDefaultStream(PrintStream)
Sets the default stream for new logs.
 o setLoggingLevel(int)
Sets the logging level of this LogStream instance.
 o setOutputStream(OutputStream)
Sets the OutputStream instance for this log.
 o setWriteIdentifierToLog(boolean)
Sets the flag that indicates if the identifier will be written to the log prefix.
 o toString()
Returns the log name as the string representation.
 o write(byte[], int, int)
Writes a subarray of bytes.
 o write(int)
Writes a byte of data to the stream.

Variables

 o known
 protected static Hashtable known
Table mapping of known log names to LogStream instances.

 o defaultStream
 protected static PrintStream defaultStream
Default OutputStream instance for new logs.

 o name
 protected String name
Name for this log.

 o logOut
 protected OutputStream logOut
This log sends all output to this OutputStream instance.

 o logWriter
 protected OutputStreamWriter logWriter
Writer used for writing to the LogStream instance.

 o buffer
 protected StringBuffer buffer
StringBuffer used for constructing log message prefixes.

 o bufOut
 protected ByteArrayOutputStream bufOut
Stream used for buffering lines.

 o dateFormatter
 protected DateFormat dateFormatter
Date formatter to format the date in the current locale.

 o closeWhenThrough
 protected boolean closeWhenThrough
Flag to indicate if the current OutputStream instance will be flushed or closed when changing to a new OutputStream instance.

 o writeIdentifierToLog
 protected boolean writeIdentifierToLog
Flag to indicate if the identifier will be written to the log as part of the log prefix. For the initial release, the identifier is the IP address of the local computer.

 o lineSeparator
 protected char lineSeparator
Line separator character. This character is the value of the last character of the line.separator property String.

 o loggingLevel
 protected int loggingLevel
Flag to indicate the style of the logging level. The logging levels are SILENT, BRIEF, and VERBOSE. The default is VERBOSE.

 o SILENT
 public static final int SILENT
Logging level constant that means nothing is written. Messages are not written to any OutputStream instance.

 o BRIEF
 public static final int BRIEF
Logging level constant that means the prefix is not added to the message.

 o VERBOSE
 public static final int VERBOSE
Logging level constant that means the prefix and message are printed to the OutputStream instance.

Methods

 o log
 public static LogStream log(String name)
Returns the LogStream instance identified by the given name. If no log exists with a name ID, a log using the default stream is created and labeled name

Parameters:
name - String identifying this log.
Returns:
The LogStream instance identified by name.
 o getCloseWhenThrough
 public synchronized boolean getCloseWhenThrough()
Returns the flag that indicates if the current OutputStream instance will be flushed or closed when changing to a new OutputStream instance.

Returns:
true if the current OutputStream instance will be flushed or closed; false otherwise.
 o setCloseWhenThrough
 public synchronized void setCloseWhenThrough(boolean newCWT)
Sets the flag that indicates if the current OutputStream instance will be flushed or closed when changing to a new OutputStream instance.

Parameters:
newCWT - true if the current OutputStream instance will be flushed or closed; false otherwise.
 o getWriteIdentifierToLog
 public synchronized boolean getWriteIdentifierToLog()
Returns the flag that indicates if the identifier will be written to the log prefix. For the initial release, the identifier is the IP address of the local computer.

Returns:
true if the identifier will be written; false otherwise.
 o setWriteIdentifierToLog
 public synchronized void setWriteIdentifierToLog(boolean newID)
Sets the flag that indicates if the identifier will be written to the log prefix. For the initial release, the identifier is the IP address of the local computer.

Parameters:
newID - true if the identifier will be written; false otherwise.
 o getLoggingLevel
 public synchronized int getLoggingLevel()
Returns the logging level of this LogStream instance.

Returns:
SILENT, BRIEF, or VERBOSE.
 o setLoggingLevel
 public synchronized boolean setLoggingLevel(int newLevel)
Sets the logging level of this LogStream instance.

Parameters:
newLevel - SILENT, BRIEF, or VERBOSE.
Returns:
true if the input logging level was set correctly (the input newLevel was recognized); false otherwise.
 o getDefaultStream
 public static synchronized PrintStream getDefaultStream()
Returns the current default stream for new logs.

Returns:
The initial PrintStream setting of all logs that are created.
 o setDefaultStream
 public static synchronized void setDefaultStream(PrintStream newDefault)
Sets the default stream for new logs.

Parameters:
newDefault - All newly created logs will be initially set to this PrintStream.
 o getOutputStream
 public synchronized OutputStream getOutputStream()
Returns the OutputStream instance for this log.

Returns:
The OutputStream instance of this log.
 o setOutputStream
 public synchronized void setOutputStream(OutputStream out)
Sets the OutputStream instance for this log. When this LogStream instance changes the OutputStream instance, the previous OutputStream instance is flushed or closed depending on the setting of closeWhenThrough.

Parameters:
out - The new OutputStream instance for this log.
 o write
 public void write(int b)
Writes a byte of data to the stream. All non-newline bytes are appended to the internal buffer. All newline bytes result in the currently buffered line being sent to the output stream, prefixed with the appropriate logging information.

Parameters:
b - A byte of data to be written to the OutputStream instance.
Overrides:
write in class PrintStream
 o write
 public void write(byte b[],
                   int off,
                   int len)
Writes a subarray of bytes.

Parameters:
b - The data.
off - The start offset in the data.
len - The number of bytes to write.
Overrides:
write in class PrintStream
 o println
 public void println(MessageFormatter mf,
                     String msgHandle)
Prints a line containing the String retrieved from the ResourceBundle.

Parameters:
mf - The MessageFormatter instance with the resource bundle.
msgHandle - The String that is the key for retrieving a message from the resource bundle.
See Also:
println
 o println
 public void println(MessageFormatter mf,
                     String msgHandle,
                     Object arg)
Prints a line containing the String retrieved from the ResourceBundle.

Parameters:
mf - The MessageFormatter instance with the resource bundle.
msgHandle - The String that is the key for retrieving a message from the resource bundle.
arg - An object reference to the variable argument.
See Also:
println
 o println
 public void println(MessageFormatter mf,
                     String msgHandle,
                     Object arg1,
                     Object arg2)
Prints a line containing the String retrieved from the ResourceBundle.

Parameters:
mf - The MessageFormatter instance with the resource bundle.
msgHandle - The String that is the key for retrieving a message from the resource bundle.
arg1 - An object reference to the first variable argument.
arg2 - An object reference to the second variable argument.
See Also:
println
 o println
 public void println(MessageFormatter mf,
                     String msgHandle,
                     Object arg1,
                     Object arg2,
                     Object arg3)
Prints a line containing the String retrieved from the ResourceBundle.

Parameters:
mf - The MessageFormatter instance with the resource bundle.
msgHandle - The String that is the key for retrieving a message from the resource bundle.
arg1 - An object reference to the first variable argument.
arg2 - An object reference to the second variable argument.
arg3 - An object reference to the third variable argument.
See Also:
println
 o toString
 public String toString()
Returns the log name as the string representation.

Overrides:
toString in class Object

All Packages  Class Hierarchy  This Package  Previous  Next  Index