Logo
Reference manual - version ored_version
Public Member Functions | List of all members
LoggerStream Class Reference

LoggerStream class that is a std::ostream replacement that will log each line. More...

#include <ored/utilities/log.hpp>

Public Member Functions

 LoggerStream (unsigned mask, const char *filename, unsigned lineNo)
 
 ~LoggerStream ()
 destructor - this is when the logging takes place.
 
 operator std::ostream & ()
 cast this LoggerStream as a ostream&
 

Detailed Description

LoggerStream class that is a std::ostream replacement that will log each line.

LoggerStream is a simple wrapper around a std::string stream, it has an explicit cast std::ostream& method so it can be used in place of any std::ostream, this can be used with QuantExt methods that take a std::ostream& for logging purposes.

Once the stream falls out of focus, it's destructor will take the buffered log messages and pass them the main ore::data::Log::instance().

Note the following

The LoggerStream relies on falling out of scope to trigger the logging, as such they should not be created using the new operator.

The proper usage is to use the macro LOGGERSTREAM and DLOGGERSTREAM, if a function takes a std::ostream& as a parameter, use the macro instead.

void function(int x, int y, std::ostream& out);
void main () {
// call function
function (3, 4, LOGGERSTREAM);
// All logging will be completed before this line
}