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.
-
BRIEF
- Logging level constant that
means the prefix is not added to the message.
-
buffer
- StringBuffer used for constructing log message prefixes.
-
bufOut
- Stream used for buffering lines.
-
closeWhenThrough
- Flag to indicate if the current OutputStream instance will be flushed
or closed when changing to a new OutputStream instance.
-
dateFormatter
- Date formatter to format the date in the current locale.
-
defaultStream
- Default OutputStream instance for new logs.
-
known
- Table mapping of known log names to LogStream instances.
-
lineSeparator
- Line separator character.
-
loggingLevel
- Flag to indicate the style of the logging level.
-
logOut
- This log sends all output to this OutputStream instance.
-
logWriter
- Writer used for writing to the LogStream instance.
-
name
- Name for this log.
-
SILENT
- Logging level constant that means nothing is written.
-
VERBOSE
- Logging level constant that
means the prefix and message are printed to the OutputStream instance.
-
writeIdentifierToLog
- Flag to indicate if the identifier will be written to the log
as part of the log prefix.
-
getCloseWhenThrough()
- Returns the flag that indicates if the current OutputStream instance
will be flushed or closed when changing to a new OutputStream instance.
-
getDefaultStream()
- Returns the current default stream for new logs.
-
getLoggingLevel()
- Returns the logging level of this LogStream instance.
-
getOutputStream()
- Returns the OutputStream instance for this log.
-
getWriteIdentifierToLog()
- Returns the flag that indicates if the identifier will be written
to the log prefix.
-
log(String)
- Returns the LogStream instance identified by the given name.
-
println(MessageFormatter, String)
- Prints a line containing the String retrieved from the ResourceBundle.
-
println(MessageFormatter, String, Object)
- Prints a line containing the String retrieved from the ResourceBundle.
-
println(MessageFormatter, String, Object, Object)
- Prints a line containing the String retrieved from the ResourceBundle.
-
println(MessageFormatter, String, Object, Object, Object)
- Prints a line containing the String retrieved from the ResourceBundle.
-
setCloseWhenThrough(boolean)
- Sets the flag that indicates if the current OutputStream instance will be
flushed or closed when changing to a new OutputStream instance.
-
setDefaultStream(PrintStream)
- Sets the default stream for new logs.
-
setLoggingLevel(int)
- Sets the logging level of this LogStream instance.
-
setOutputStream(OutputStream)
- Sets the OutputStream instance for this log.
-
setWriteIdentifierToLog(boolean)
- Sets the flag that indicates if the identifier
will be written to the log prefix.
-
toString()
- Returns the log name as the string representation.
-
write(byte[], int, int)
- Writes a subarray of bytes.
-
write(int)
- Writes a byte of data to the stream.
known
protected static Hashtable known
- Table mapping of known log names to LogStream instances.
defaultStream
protected static PrintStream defaultStream
- Default OutputStream instance for new logs.
name
protected String name
- Name for this log.
logOut
protected OutputStream logOut
- This log sends all output to this OutputStream instance.
logWriter
protected OutputStreamWriter logWriter
- Writer used for writing to the LogStream instance.
buffer
protected StringBuffer buffer
- StringBuffer used for constructing log message prefixes.
bufOut
protected ByteArrayOutputStream bufOut
- Stream used for buffering lines.
dateFormatter
protected DateFormat dateFormatter
- Date formatter to format the date in the current locale.
closeWhenThrough
protected boolean closeWhenThrough
- Flag to indicate if the current OutputStream instance will be flushed
or closed when changing to a new OutputStream instance.
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.
lineSeparator
protected char lineSeparator
- Line separator character. This character is the value of the
last character of the line.separator property String.
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
.
SILENT
public static final int SILENT
- Logging level constant that means nothing is written.
Messages are not written to any OutputStream instance.
BRIEF
public static final int BRIEF
- Logging level constant that
means the prefix is not added to the message.
VERBOSE
public static final int VERBOSE
- Logging level constant that
means the prefix and message are printed to the OutputStream instance.
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.
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.
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.
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.
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.
getLoggingLevel
public synchronized int getLoggingLevel()
- Returns the logging level of this LogStream instance.
- Returns:
- SILENT, BRIEF, or VERBOSE.
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.
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.
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.
getOutputStream
public synchronized OutputStream getOutputStream()
- Returns the OutputStream instance for this log.
- Returns:
- The OutputStream instance of this log.
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.
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
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
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
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
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
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
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