SK.gnome.dwarf.mail.utils
Class LoggedWriter

java.lang.Object
  extended bySK.gnome.dwarf.mail.utils.LoggedWriter

public class LoggedWriter
extends java.lang.Object

Provides line writer with a built-in logging capability.

This class may be used to write lines to the underlying output stream while automatically logging them for debugging purposes. It is suitable for handling text-based network protocols, such as SMTP or POP3, for example.


Constructor Summary
LoggedWriter(SK.gnome.dwarf.log.Logger logger, java.lang.String facility, java.lang.String prefix, java.io.OutputStream stream)
          Creates a new LoggedWriter.
 
Method Summary
 java.io.OutputStream getStream()
          Returns the underlying output stream.
 void print(java.lang.String s)
          Prints the string.
 void println(java.lang.String s)
          Prints the string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggedWriter

public LoggedWriter(SK.gnome.dwarf.log.Logger logger,
                    java.lang.String facility,
                    java.lang.String prefix,
                    java.io.OutputStream stream)
             throws java.io.UnsupportedEncodingException
Creates a new LoggedWriter.

The writer will write to stream and log each written line via the logger. The log messages have the LOG_TRACE logging level and the logging facility associated with them. Each logged line is prepended with the prefix string.

The log messages will be generated only if it is enabled for the given facility via the SK.gnome.dwar.log.Log.setTrace(String) method.

This writer converts the written characters using the ISO 8859-1 character encoding.

Parameters:
logger - the logging service
facility - the logging facility
prefix - the prefix identifying the log messages
stream - the output stream to write to
Throws:
java.io.UnsupportedEncodingException - if the required encoding is not known
Method Detail

println

public void println(java.lang.String s)
             throws java.io.IOException
Prints the string.

Parameters:
s - the string
Throws:
java.io.IOException - if an error occurs

print

public void print(java.lang.String s)
           throws java.io.IOException
Prints the string.

Parameters:
s - the string
Throws:
java.io.IOException - if an error occurs

getStream

public java.io.OutputStream getStream()
Returns the underlying output stream.

The stream may be used to directly write byte octets when line-oriented output or logging function is not desired.

Returns:
the output stream


Copyright (c) 2004-2005, Gnome Ltd. All rights reserved.