Programming Reference:LogFile Class
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;
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.
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.