jcifs.util
Class LogWriter

java.lang.Object
  |
  +--jcifs.util.LogWriter

public class LogWriter
extends Object

This class is basically a PrintWriter that prepends a timestamp before each message is written to the underlying stream. The methods for printing are a pertainent subset from PrintWriter.

See Also:
Log

Field Summary
 Object lock
          The object used to synchronize operations on this stream
 
Constructor Summary
LogWriter(OutputStream out)
          Create a new LogWriter instance that uses the specified output stream as it's underlying stream
LogWriter(Writer out)
          Create a new LogWriter instance.
 
Method Summary
 boolean checkError()
          Flush the stream and check error state
 void close()
          Close the stream
 void println(String desc, char[] c)
          Print an array of char to the log.
 void println(String desc, int i)
          Print an int to the log stream.
 void println(String desc, Object o)
          Print the string representation of an Object to the screen.
 void println(String desc, String s)
          Print a String to the log.
 void printStackTrace(String desc, Throwable t)
          This is a pervasive enough feature for a logging utility that it is built in.
static void setDateFormat(String format)
          Set the date format used to render the timestamp written with each message.
 void setError()
          Indicate that an error has occured
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

lock

public Object lock
The object used to synchronize operations on this stream
Constructor Detail

LogWriter

public LogWriter(Writer out)
Create a new LogWriter instance.

LogWriter

public LogWriter(OutputStream out)
Create a new LogWriter instance that uses the specified output stream as it's underlying stream
Method Detail

setDateFormat

public static void setDateFormat(String format)
Set the date format used to render the timestamp written with each message.
Parameters:
format - the format string used
See Also:
SimpleDateFormat

close

public void close()
Close the stream

checkError

public boolean checkError()
Flush the stream and check error state

setError

public void setError()
Indicate that an error has occured

printStackTrace

public void printStackTrace(String desc,
                            Throwable t)
This is a pervasive enough feature for a logging utility that it is built in.
Parameters:
desc - a brief description of the source of the message to follow
t - the Exception to obtain the message to be printed from

println

public void println(String desc,
                    int i)
Print an int to the log stream. Keep in mind that every call to a PrintWriter like method will print a new timestamp. Using several calls together will not concatonate several messages together under one timestamp.
Parameters:
desc - a brief description of the source of the message to follow
i - the int to print

println

public void println(String desc,
                    char[] c)
Print an array of char to the log.
Parameters:
desc - a brief description of the source of the message to follow
c - the message

println

public void println(String desc,
                    String s)
Print a String to the log.
Parameters:
desc - a brief description of the source of the message to follow
s - the string message

println

public void println(String desc,
                    Object o)
Print the string representation of an Object to the screen.
Parameters:
desc - a general description of the source of the message
o - the Object to print