|
qflib 0.98.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--de.qfs.lib.log.StreamFilter
LevelFilter
in combination with
StreamLogWriter
, FileLogWriter
or RingFileLogWriter
as of version
0.98.0.
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.
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 |
public static final int MODE_CREATE
public static final int MODE_APPEND
public static final int MODE_UNIQUE
Constructor Detail |
public StreamFilter(java.io.OutputStream stream)
stream
- The Stream to write the log entries to.public StreamFilter(java.io.OutputStream stream, int level)
stream
- The Stream to write the log entries to.level
- Only messages up to this level will be printed to the
stream.public StreamFilter(java.io.OutputStream stream, int level, java.text.DateFormat format)
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.public StreamFilter(java.io.Writer writer)
writer
- The Writer to write the log entries to.public StreamFilter(java.io.Writer writer, int level)
writer
- The Writer to write the log entries to.level
- Only messages up to this level will be printed to the
writer.public StreamFilter(java.io.Writer writer, int level, java.text.DateFormat format)
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 |
public static StreamFilter logToFile(java.lang.String client, java.io.File file, int mode) throws java.io.IOException
FileLogWriter.logToFile
or RingFileLogWriter.logToFile
instead.
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
.java.io.IOException
- If the file cannot be created.public static void stopLogging()
public final int getLogLevel()
public final void setLogLevel(int level)
level
- Only messages up to this level will be printed to the
stream.public final java.text.DateFormat getDateFormat()
public final void setDateFormat(java.text.DateFormat format)
format
- The DateFormat to use.public void close()
public boolean filter(LogEntry logEntry)
filter
in interface LogFilter
logEntry
- The entry to write.public LogEntry[] filter(LogEntry[] entries)
filter
in interface LogFilter
entries
- The list of LogEntries.public void setFilterMode(int mode)
setFilterMode
in interface LogUser
mode
- The mode to set.
|
qflib 0.98.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |