|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectch.javasoft.util.logging.LogFragmenter
public class LogFragmenter
The LogFragmenter allows fragmented logging of a log record,
which might for instance result as a single line in the log file. Normally,
a record is logged as one line. With this class, multiple log records can be
logged on a single line.
Fragmented logging starts with one of the xxxStart(..) methods, for
instance, infoStart(String) to log with the INFO log level. The
subsequent calls which should appear on the same line are logged with append(String), and the line is completed with end() or
end(String).
Sample usage:
Logger logger = Logger.getLogger("myLogger");
LogFragmenter frag = new LogFragmenter(logger);
frag.start("Counting to 10: ", Level.INFO);
for (int i = 1; i <= 10; i++) {
if (i > 1) frag.append(", ");
frag.append(String.valueOf(i));
}
frag.end();
NOTE: this class is intended to be used with the LogFormatter.
| Constructor Summary | |
|---|---|
LogFragmenter(Logger logger)
Constructor with logger to log to |
|
LogFragmenter(String logger)
Constructor with name of the logger to log to |
|
| Method Summary | |
|---|---|
void |
append(String msg)
Append the given message to the log, usually printed on the same log line |
void |
cleanUp()
End fragmented logging if it is started, or do nothing otherwise |
void |
configStart(String msg)
Start fragmented logging with the given message at log level CONFIG Calls start(String, Level) with Level.CONFIG |
void |
end()
End fragmented logging without any additional message |
void |
end(String msg)
End fragmented logging, appending the given message before logging is closed |
void |
finerStart(String msg)
Start fragmented logging with the given message at log level FINER Calls start(String, Level) with Level.FINER |
void |
fineStart(String msg)
Start fragmented logging with the given message at log level FINE Calls start(String, Level) with Level.FINE |
void |
finestStart(String msg)
Start fragmented logging with the given message at log level FINEST Calls start(String, Level) with Level.FINEST |
void |
infoStart(String msg)
Start fragmented logging with the given message at log level INFO Calls start(String, Level) with Level.INFO |
boolean |
isStarted()
|
void |
severeStart(String msg)
Start fragmented logging with the given message at log level SEVERE Calls start(String, Level) with Level.SEVERE |
void |
start(String msg,
Level level)
Start fragmented logging with the given message at the given level |
void |
warningStart(String msg)
Start fragmented logging with the given message at log level WARNING Calls start(String, Level) with Level.WARNING |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public LogFragmenter(String logger)
logger - the name of the logger to log toLogger.getLogger(String)public LogFragmenter(Logger logger)
logger - the logger to log to| Method Detail |
|---|
public void start(String msg,
Level level)
throws IllegalStateException
msg - the message to start logging withlevel - the level on which all log messages (until end is called)
will be logged
IllegalStateException - if the logger has already been startedpublic void severeStart(String msg)
start(String, Level) with Level.SEVERE
public void warningStart(String msg)
start(String, Level) with Level.WARNING
public void infoStart(String msg)
start(String, Level) with Level.INFO
public void configStart(String msg)
start(String, Level) with Level.CONFIG
public void fineStart(String msg)
start(String, Level) with Level.FINE
public void finerStart(String msg)
start(String, Level) with Level.FINER
public void finestStart(String msg)
start(String, Level) with Level.FINEST
public void append(String msg)
msg - the message to append to the log
IllegalStateException - if the logger has not yet been startedpublic void end()
IllegalStateException - if the logger has not yet been startedpublic void end(String msg)
IllegalStateException - if the logger has not yet been startedpublic void cleanUp()
public boolean isStarted()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||