tuwien.auto.calimero.log
Class LogWriter

java.lang.Object
  extended by tuwien.auto.calimero.log.LogWriter
Direct Known Subclasses:
LogStreamWriter

public abstract class LogWriter
extends java.lang.Object

LogWriter is responsible for writing information to individual destinations.

A LogWriter has an assigned log level (by default LogLevel.ALL), which specifies what information to write and what to ignore. A log level of LogLevel.OFF will ignore any write requests. If a LogWriter is not used anymore, close() has to be called.

See Also:
LogLevel, LogService

Constructor Summary
LogWriter()
           
 
Method Summary
abstract  void close()
          Closes the LogWriter and all its resources.
abstract  void flush()
          Flushes all buffered output.
static ErrorHandler getErrorHandler()
          Returns the used error handler.
 LogLevel getLogLevel()
          Returns the log level used for deciding which messages will be logged.
static void setErrorHandler(ErrorHandler handler)
          Sets the error handler used on all log writer errors.
 void setLogLevel(LogLevel level)
          Sets the log level for deciding which messages gets logged by this LogWriter.
abstract  void write(java.lang.String logService, LogLevel level, java.lang.String msg)
          Writes a message out to this LogWriter.
abstract  void write(java.lang.String logService, LogLevel level, java.lang.String msg, java.lang.Throwable t)
          Like write(String, LogLevel, String), in addition a Throwable object is taken which will be added to the message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LogWriter

public LogWriter()
Method Detail

close

public abstract void close()
Closes the LogWriter and all its resources.

If necessary, all output is flushes before.


flush

public abstract void flush()
Flushes all buffered output.


getErrorHandler

public static ErrorHandler getErrorHandler()
Returns the used error handler.

Returns:
an ErrorHandler object

getLogLevel

public final LogLevel getLogLevel()
Returns the log level used for deciding which messages will be logged.

Returns:
log LogLevel

setErrorHandler

public static void setErrorHandler(ErrorHandler handler)
Sets the error handler used on all log writer errors.

Parameters:
handler - the new error handler

setLogLevel

public final void setLogLevel(LogLevel level)
Sets the log level for deciding which messages gets logged by this LogWriter.

Parameters:
level - new log level

write

public abstract void write(java.lang.String logService,
                           LogLevel level,
                           java.lang.String msg)
Writes a message out to this LogWriter.

The message has the associated log level level. It will only be written if the LogWriter logging level is not more restrictive than level. Otherwise the message is ignored. LogWriter is responsible for formatting the output.

Parameters:
logService - log service name stating the source of the message
level - log level of message
msg - the message to write

write

public abstract void write(java.lang.String logService,
                           LogLevel level,
                           java.lang.String msg,
                           java.lang.Throwable t)
Like write(String, LogLevel, String), in addition a Throwable object is taken which will be added to the message.

Parameters:
logService - log service name stating the source of the message
level - log level of message
msg - the message to write
t - Throwable object, might be null