Cortex  10.0.0-a4
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
IECore::MessageHandler Class Referenceabstract

#include <MessageHandler.h>

+ Inheritance diagram for IECore::MessageHandler:

Classes

class  Scope
 

Public Types

enum  Level {
  Error = 0, Warning = 1, Info = 2, Debug = 3,
  Invalid = 4
}
 
- Public Types inherited from IECore::RefCounted
typedef size_t RefCount
 

Public Member Functions

 IE_CORE_DECLAREMEMBERPTR (MessageHandler)
 
virtual void handle (Level level, const std::string &context, const std::string &message)=0
 
- Public Member Functions inherited from IECore::RefCounted
 IE_CORE_DECLAREMEMBERPTR (RefCounted)
 
void addRef () const
 Add a reference to the current object.
 
void removeRef () const
 Remove a reference from the current object.
 
RefCount refCount () const
 Returns the current reference count.
 

Static Public Member Functions

static MessageHandlercurrentHandler ()
 
Message output

These functions all output a message via the current MessageHandler object.

Threading:
These functions are threadsafe provided that the current handler's handle() method is also threadsafe.
static void output (Level level, const std::string &context, const std::string &message)
 Output a message to the current handler.
 
static void output (Level level, const std::string &context, const boost::format &message)
 Output a message to the current handler.
 
Default handler

There is a single default MessageHandler specified globally. Typically this will be set once on application startup and then be left in place. This message handler is used whenever there is no locally specified handler installed using the Scope class below.

Threading:
These functions are not threadsafe - it is expected that setDefaultHandler() will be called once from the main thread on application startup.
static void setDefaultHandler (const MessageHandlerPtr &handler)
 
static MessageHandlergetDefaultHandler ()
 
Conversions between Level and string
static std::string levelAsString (Level level)
 Returns a readable string representation of the specified message level.
 
static Level stringAsLevel (const std::string &level)
 Returns a message level based on the specified string (case is ignored).
 

Detailed Description

The MessageHandler class should be used for all logging within IECore code, and code using IECore. It provides a uniform interface for outputting messages, with the possibility to implement multiple message handlers appropriate to specific application contexts.

Member Function Documentation

static MessageHandler* IECore::MessageHandler::currentHandler ( )
static

Returns the current handler for this thread, reverting to the result of getDefaultHandler() if no thread-local handler has been installed.

Threading:
This is threadsafe with respect to handlers installed by the Scope class.
virtual void IECore::MessageHandler::handle ( Level  level,
const std::string &  context,
const std::string &  message 
)
pure virtual

Must be implemented by subclasses to output the message appropriately. Client code should use MessageHandler::output() rather than call this directly.

Implemented in IECore::OStreamMessageHandler, IECore::LevelFilteredMessageHandler, IECore::CompoundMessageHandler, IECore::NullMessageHandler, and IECoreHoudini::MessageHandler.


The documentation for this class was generated from the following file: