ScummVM API documentation
Backends::Log::Log Class Reference

#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)
 

Detailed Description

Log file writer.

This can be used by the backends to implement file logging functionality.

Constructor & Destructor Documentation

◆ Log()

Backends::Log::Log::Log ( OSystem system)

Constructor for the logger object.

Parameters
systemThe OSystem instance to use. Must be non-null.

Member Function Documentation

◆ open()

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.

See also
Common::WriteStream::flush

Calling open with stream being 0 is valid and will result in the same behavior as calling close, but it may have additional overhead.

See also
close

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.

Parameters
streamStream where to output the log contents. Note that the stream will be deleted by the logger.

◆ close()

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.

◆ print()

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.

Parameters
messageThe message to write.
printTimeOnNewlineWhether to print a timestamp on the start of a new line.

The documentation for this class was generated from the following file: