#include <log.h>
Public Member Functions | |
Log (OSystem *system) | |
void | open (Common::WriteStream *stream) |
void | close () |
void | print (const char *message, const bool printTimeOnNewline=true) |
Log file writer.
This can be used by the backends to implement file logging functionality.
Backends::Log::Log::Log | ( | OSystem * | system | ) |
Constructor for the logger object.
system | The OSystem instance to use. Must be non-null. |
void Backends::Log::Log::open | ( | Common::WriteStream * | stream | ) |
Opens a new log file.
The previous log, which was handled by this logger, will be closed before the new stream is associated.
The current implemention will always call flush after data is written to the log file. It might thus be wise to pass an unbuffered write stream here to avoid unnecessary overhead.
Calling open with stream being 0 is valid and will result in the same behavior as calling close, but it may have additional overhead.
This function will output information about the ScummVM version and the features built into ScummVM automatically. It will also add a short notice to indicate that the log was opened successfully.
stream | Stream where to output the log contents. Note that the stream will be deleted by the logger. |
void Backends::Log::Log::close | ( | ) |
Closes the current log file.
This function will output a line saying that the log was closed successfully. This can be used to check whether a log is incomplete because of whatever reasons.
void Backends::Log::Log::print | ( | const char * | message, |
const bool | printTimeOnNewline = true |
||
) |
Prints a message to the log stream.
This has optional support to output a timestamp on every new line. The timestamp will look like: "[YYYY-MM-DD HH:MM:SS] ". Printing of a timestamp is done by default.
It might be noteworthy that this function does not append a new line to the given message.
In case no stream is associated with this logger, this function will quit immediately.
message | The message to write. |
printTimeOnNewline | Whether to print a timestamp on the start of a new line. |