qflib 0.98.1

de.qfs.lib.log
Class StreamFilter

java.lang.Object
  |
  +--de.qfs.lib.log.StreamFilter
All Implemented Interfaces:
LogFilter, LogUser

Deprecated. Replaced by LevelFilter in combination with StreamLogWriter, FileLogWriter or RingFileLogWriter as of version 0.98.0.

public class StreamFilter
extends java.lang.Object
implements LogUser

A StreamFilter prints log messages to a stream. Its main use is the creation of log files.

The simplest way to create a log file is the convenience method logToFile, that expects a client name for use with the log server qflog, a file and a mode, defining whether to overwrite an existing file, append to it or to create a unique filename first.

For combination with other LogFilters, LogStream implements the LogUser interface to customize, which log messages will be passed on. Its default filter mode is FILTER_NONE.

By setting a maximum log level for the StreamFilter, some control over which messages are printed to the stream is possible. For fine grained control, additional LogFilters can be installed after the StreamFilter.

Version:
$Revision: 1.3 $
Author:
Gregor Schmid

Field Summary
static int MODE_APPEND
          Deprecated. Append to a log file, creating a new one if necessary.
static int MODE_CREATE
          Deprecated. Create a new log file, overwriting existing files.
static int MODE_UNIQUE
          Deprecated. Create a new log file.
 
Fields inherited from interface de.qfs.lib.log.LogUser
FILTER_ALL, FILTER_NONE, FILTER_UNUSED, FILTER_USED
 
Constructor Summary
StreamFilter(java.io.OutputStream stream)
          Deprecated. Create a new StreamFilter.
StreamFilter(java.io.OutputStream stream, int level)
          Deprecated. Create a new StreamFilter.
StreamFilter(java.io.OutputStream stream, int level, java.text.DateFormat format)
          Deprecated. Create a new StreamFilter.
StreamFilter(java.io.Writer writer)
          Deprecated. Create a new StreamFilter.
StreamFilter(java.io.Writer writer, int level)
          Deprecated. Create a new StreamFilter.
StreamFilter(java.io.Writer writer, int level, java.text.DateFormat format)
          Deprecated. Create a new StreamFilter.
 
Method Summary
 void close()
          Deprecated. Close the StreamFilter's output stream and remove the StreamFilter from the Log filter chain.
 boolean filter(LogEntry logEntry)
          Deprecated. Take a LogEntry and write it to the stream.
 LogEntry[] filter(LogEntry[] entries)
          Deprecated. Write all entries from the list to the stream.
 java.text.DateFormat getDateFormat()
          Deprecated. Get the DateFormat used to print the timestamp of the log messages.
 int getLogLevel()
          Deprecated. Get the level limiting the output of messages.
static StreamFilter logToFile(java.lang.String client, java.io.File file, int mode)
          Deprecated. Please use FileLogWriter.logToFile or RingFileLogWriter.logToFile instead.
 void setDateFormat(java.text.DateFormat format)
          Deprecated. Set the DateFormat used to print the timestamp of the log messages.
 void setFilterMode(int mode)
          Deprecated. Configure the StreamFilter's filter mode.
 void setLogLevel(int level)
          Deprecated. Set the level limiting the output of messages.
static void stopLogging()
          Deprecated. Remove the StreamFilter instance from the Log filter chain and close the log file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_CREATE

public static final int MODE_CREATE
Deprecated. 
Create a new log file, overwriting existing files.

MODE_APPEND

public static final int MODE_APPEND
Deprecated. 
Append to a log file, creating a new one if necessary.

MODE_UNIQUE

public static final int MODE_UNIQUE
Deprecated. 
Create a new log file. A number appended to the basename is incremented until the file name is unique.
Constructor Detail

StreamFilter

public StreamFilter(java.io.OutputStream stream)
Deprecated. 
Create a new StreamFilter.
Parameters:
stream - The Stream to write the log entries to.

StreamFilter

public StreamFilter(java.io.OutputStream stream,
                    int level)
Deprecated. 
Create a new StreamFilter.
Parameters:
stream - The Stream to write the log entries to.
level - Only messages up to this level will be printed to the stream.

StreamFilter

public StreamFilter(java.io.OutputStream stream,
                    int level,
                    java.text.DateFormat format)
Deprecated. 
Create a new StreamFilter.
Parameters:
stream - The Stream to write the log entries to.
level - Only messages up to this level will be printed to the stream.
format - The DateFormat to use when printing LogEntries.

StreamFilter

public StreamFilter(java.io.Writer writer)
Deprecated. 
Create a new StreamFilter.
Parameters:
writer - The Writer to write the log entries to.

StreamFilter

public StreamFilter(java.io.Writer writer,
                    int level)
Deprecated. 
Create a new StreamFilter.
Parameters:
writer - The Writer to write the log entries to.
level - Only messages up to this level will be printed to the writer.

StreamFilter

public StreamFilter(java.io.Writer writer,
                    int level,
                    java.text.DateFormat format)
Deprecated. 
Create a new StreamFilter.
Parameters:
writer - The Writer to write the log entries to.
level - Only messages up to this level will be printed to the writer.
format - The DateFormat to use when printing LogEntries.
Method Detail

logToFile

public static StreamFilter logToFile(java.lang.String client,
                                     java.io.File file,
                                     int mode)
                              throws java.io.IOException
Deprecated. Please use FileLogWriter.logToFile or RingFileLogWriter.logToFile instead.

Log messages to a log file by creating a StreamFilter and adding it to the Log filter chain. The log file will be in the format recognized by the qflog log server.
Parameters:
client - Name of the client, used by qflog.
file - The file to save in.
mode - How the file should be created. Must be one of MODE_CREATE, MODE_APPEND, or MODE_UNIQUE.
Returns:
The new StreamFilter.
Throws:
java.io.IOException - If the file cannot be created.

stopLogging

public static void stopLogging()
Deprecated. 
Remove the StreamFilter instance from the Log filter chain and close the log file.

getLogLevel

public final int getLogLevel()
Deprecated. 
Get the level limiting the output of messages.
Returns:
Only messages up to the returned level will be printed to the stream.

setLogLevel

public final void setLogLevel(int level)
Deprecated. 
Set the level limiting the output of messages.
Parameters:
level - Only messages up to this level will be printed to the stream.

getDateFormat

public final java.text.DateFormat getDateFormat()
Deprecated. 
Get the DateFormat used to print the timestamp of the log messages.
Returns:
The DateFormat used by the StreamFilter.

setDateFormat

public final void setDateFormat(java.text.DateFormat format)
Deprecated. 
Set the DateFormat used to print the timestamp of the log messages.
Parameters:
format - The DateFormat to use.

close

public void close()
Deprecated. 
Close the StreamFilter's output stream and remove the StreamFilter from the Log filter chain.

filter

public boolean filter(LogEntry logEntry)
Deprecated. 
Take a LogEntry and write it to the stream.
Specified by:
filter in interface LogFilter
Parameters:
logEntry - The entry to write.
Returns:
True if the entry should be passed on to the next filter.

filter

public LogEntry[] filter(LogEntry[] entries)
Deprecated. 
Write all entries from the list to the stream.
Specified by:
filter in interface LogFilter
Parameters:
entries - The list of LogEntries.

setFilterMode

public void setFilterMode(int mode)
Deprecated. 
Configure the StreamFilter's filter mode.
Specified by:
setFilterMode in interface LogUser
Parameters:
mode - The mode to set.

qflib 0.98.1