PrevUpHomeNext

Appendix - Logging

RCF has a configurable logging subsystem which can be controlled through the RCF::enableLogging() and RCF::disableLogging() functions. To use these functions, you will need to include the <RCF/util/Log.hpp> header.

By default, logging is disabled. To enable logging, call RCF::enableLogging(). RCF::enableLogging() takes two optional parameters: log level and log target:

// Using default values for log target and log level.
RCF::enableLogging();

// Using custom values for log target and log level.
int logLevel = 2;
RCF::enableLogging(RCF::LogToDebugWindow(), logLevel);

The log level can range from 0 (no logging at all) to 4 (maximum logging). The default log level is 2.

The log target parameter can be one of the following:

Log target

Log output location

LogToDebugWindow()

Windows only. Log output appears in Visual Studio debug output window.

LogToStdout()

Log output appears on standard output.

LogToFile(const std::string & logFilePath)

Log output appears in the nominated file.

LogToFunc(boost::function<void(const RCF::ByteBuffer &)>)

Log output is passed to a user-defined function.

On Windows platforms, the default log target is LogToDebugWindow.

On non-Windows platforms, the default log target is LogToStdout.

Finally, to disable logging, call RCF::disableLogging():

// Disable logging.
RCF::disableLogging();

RCF::enableLogging() and RCF::disableLogging() are internally threadsafe and can be called by multiple threads concurrently.


PrevUpHomeNext