Class TextFileMessageLogger
Object
TextFileMessageLogger
- All Implemented Interfaces:
MessageLogger
,StatefulMessageLogger
Logs messages to a text-file.
Both the path of text-file can be determined in different ways by the constructor, and whether it is written at all.
- Author:
- Owen Feehan
-
Constructor Summary
ConstructorsConstructorDescriptionTextFileMessageLogger
(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 aOutputterChecked
. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.anchoranalysis.core.log.MessageLogger
logEmptyLine
-
Constructor Details
-
TextFileMessageLogger
Constructs a logger that (always) writes messages to a text-file with a specific path.- Parameters:
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.
-
TextFileMessageLogger
public 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 aOutputterChecked
.The message-log will only be outputted, if allowed by the
OutputterChecked
.- Parameters:
outputName
- output-nameoutputter
- output-managererrorReporter
- error-reporter an error is outputted here if the log cannot be created, and no further logging occurs.
-
-
Method Details
-
logFormatted
Description copied from interface:MessageLogger
Logs a message, derived from a format-string.- Specified by:
logFormatted
in interfaceMessageLogger
- Parameters:
formatString
- a format string like inString.format(java.lang.String, java.lang.Object...)
.args
- the arguments that match the placeholder informatString
like inString.format(java.lang.String, java.lang.Object...)
.
-
start
Description copied from interface:StatefulMessageLogger
Starts logging.This must be called once before any logging occurs.
- Specified by:
start
in interfaceStatefulMessageLogger
- Throws:
OperationFailedException
- if logging cannot be successfully started.
-
log
Description copied from interface:MessageLogger
Logs a message.- Specified by:
log
in interfaceMessageLogger
- Parameters:
message
- the message to log.
-
close
public void close(boolean successful, boolean warningOccurred) Description copied from interface:StatefulMessageLogger
Stops logging.This must be called once after all logging has occurred.
- Specified by:
close
in interfaceStatefulMessageLogger
- Parameters:
successful
- true when the task completed successfully.warningOccurred
- true if at least one warning has occurred, false otherwise.
-