Programming Reference:LogFile Class

From BCI2000 Wiki
Jump to: navigation, search

Location

BCI2000/src/shared/utils

Synopsis

The LogFile class transparently handles output into a log file. The output log file is maintained in the current session directory, and carries the session name, followed with a user-specified extension. The log file's contents are never overwritten; rather, new entries are appended to it. Creating an instance of LogFile and writing to it is sufficient to create a log file at an appropriate location; no further programmer interaction is required.

The LogFile class inherits from std::ofstream and provides the full interface of STL ostreams, allowing to use convenient output notation as in

myLogFile << "Run number " << runNumber << " started." << endl;

Methods

LogFile(string FileExtension=".log")

When creating a LogFile object, specify the desired file extension as a string argument. Typically, the specified extension begins with a separating dot. By default, .log is chosen as a file extension.

Remarks

When writing a BCI2000 application module, it is recommended to use the ApplicationBase class as a base class for the application's task filter. In this case, dealing with a LogFile object is not necessary; rather, the ApplicationBase class provides a LogFile object that is tied to a Programming Reference:GenericVisualization Class object such that output will be written to the screen and to a log file simultaneously. For details, refer to Programming Reference:ApplicationBase Class.

See also

Programming Reference:ApplicationBase Class, Programming Reference:Debug Output, Programming Reference:Errors and Warnings