public class TextFileMessageLogger extends Object implements StatefulMessageLogger
Both the path of text-file can be determined in different ways by the constructor, and whether it is written at all.
Constructor and Description |
---|
TextFileMessageLogger(String filePath,
ErrorReporter errorReporter)
Constructs a logger that (always) writes messages to a text-file with a specific path.
|
TextFileMessageLogger(String outputName,
OutputterChecked outputter,
ErrorReporter errorReporter)
Constructs a logger that (maybe) writes messages to a text-file, with a path based upon an
output name applied to a
OutputterChecked . |
Modifier and Type | Method and Description |
---|---|
void |
close(boolean successful,
boolean warningOccurred)
Stops logging.
|
void |
log(String message)
Logs a message.
|
void |
logFormatted(String formatString,
Object... args)
Logs a message, derived from a format-string.
|
void |
start()
Starts logging.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
logEmptyLine
public TextFileMessageLogger(String filePath, ErrorReporter errorReporter)
filePath
- path to write the log toerrorReporter
- error-reporter an error is outputted here if the log cannot be created,
and no further logging occurs.public TextFileMessageLogger(String outputName, OutputterChecked outputter, ErrorReporter errorReporter)
OutputterChecked
.
The message-log will only be outputted, if allowed by the OutputterChecked
.
outputName
- output-nameoutputter
- output-managererrorReporter
- error-reporter an error is outputted here if the log cannot be created,
and no further logging occurs.public void logFormatted(String formatString, Object... args)
MessageLogger
logFormatted
in interface MessageLogger
formatString
- a format string like in String.format(java.lang.String, java.lang.Object...)
.args
- the arguments that match the placeholder in formatString
like in String.format(java.lang.String, java.lang.Object...)
.public void start() throws OperationFailedException
StatefulMessageLogger
This must be called once before any logging occurs.
start
in interface StatefulMessageLogger
OperationFailedException
- if logging cannot be successfully started.public void log(String message)
MessageLogger
log
in interface MessageLogger
message
- the message to log.public void close(boolean successful, boolean warningOccurred)
StatefulMessageLogger
This must be called once after all logging has occurred.
close
in interface StatefulMessageLogger
successful
- true when the task completed successfully.warningOccurred
- true if at least one warning has occurred, false otherwise.Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.