neuray API Programmer's Manual

mi::base::Log_stream Class Reference

[Logging]

Description

Adapts mi::base::ILogger to a standard streaming interface. Messages are forwarded to the logger whenever the stream is flushed. The log level for the next message can be changed by using one of the manipulators fatal, error, warning, info, verbose, or debug, which correspond to the values of mi::base::details::Message_severity. The log details can be changed by pushing an instance of mi::base::details;:Message_details into the stream. Changing the log level or the details also triggers flushing.

Example:

mi::base::Handle< mi::base::Logger> logger( ...);
 mi::base::Log_stream stream( logger.get(), "APP:MAIN");
 stream << "An info message" << std::flush;
 stream << error << "And an error message" << std::flush;
 stream << "And another info message" << std::flush;

Public Constructors

 Log_stream( ILogger* logger, const char* module_category, Message_severity default_level = MESSAGE_SEVERITY_INFO, const Message_details& default_details = Message_details())
Constructor. More...
 Log_stream( ILogger* logger, const std::​string& module_category, Message_severity default_level = MESSAGE_SEVERITY_INFO, const Message_details& default_details = Message_details())
Constructor. More...

Public Destructors

 ~Log_stream()
Destructor. More...

Public Member Functions

void set_details( const Message_details& details)
Flushes the buffer if not empty, and sets the message details of the next message.
void set_log_level( Message_severity level)
Flushes the buffer if not empty, and sets the log level of the next message to the given log level.

Constructors

mi::​base::​Log_stream::Log_stream( ILogger* logger, const char* module_category, Message_severity default_level = MESSAGE_SEVERITY_INFO, const Message_details& default_details = Message_details()) [inline]

Constructor.

Parameters

logger
The logger object used by this stream.
module_category
The module and the category which specify the origin and the functional area of this message. See mi::base::ILogger::message() for details.
default_level
The default log level. Used if no other log level is selected by one of the manipulators.
default_details
The default message details.
mi::​base::​Log_stream::Log_stream( ILogger* logger, const std::​string& module_category, Message_severity default_level = MESSAGE_SEVERITY_INFO, const Message_details& default_details = Message_details()) [inline]

Constructor.

Parameters

logger
The logger object used by this stream.
module_category
The module and the category which specify the origin and the functional area of this message. See mi::base::ILogger::message() for details.
default_level
The default log level. Used if no other log level is selected by one of the manipulators.
default_details
The default message details.

Destructors

mi::​base::​Log_stream::~Log_stream() [inline]

Destructor. Flushes the buffer.

Member Functions

void mi::​base::​Log_stream::set_details( const Message_details& details) [inline]

Flushes the buffer if not empty, and sets the message details of the next message.

void mi::​base::​Log_stream::set_log_level( Message_severity level) [inline]

Flushes the buffer if not empty, and sets the log level of the next message to the given log level.