How To Use the Message Service

LCG Project | LCG Applications Area

SEAL Project | Project Portal

 

$Date: 2004/06/28 17:34:30 $

Overview

This guide explains how to use the Message Service from a component (refer to how to create a component), and how to configure it.

Composing Messages

The message to be reported to message service is composed using a MessageStream. The user can define as many message streams as required.  The MessageStream sets the message source (typically the name or identification of the component), the severity level and the message text itself.

Typical method implementation looks like this:

#include "SealKernel/MesssageStream.h"
using namespace seal;
MyComponent::doSomething() { MessageStream log(this,"MyComponent"); MessageStream error(this,"MyComponent",Msg::Error); ... log << "This is a message at INFO level since is the default" << flush; log(Msg::Warning) << "This is a WARNING this time" << flush; error << "This is an ERROR" << flush; ... }

The MessageStream is communicating with the MessageService when the the message is complete (flush or endmsg) or at destruction (out of scope). The MessageService is located at the context of the component  or any context up in the hierarchy (this is why "this" appears in the constructor arguments ). If no MessageService is located then the standard std::cout is used instead.

The MessageStream is also initialized with a name (message source name) and a initial severity level (Msg::Info by default). Only a communication is established if the message severity level is equal or higher than the current level threshold for that source or the general one.

The output of the previous code snip is as follows:

MyComponent    INFO  This is a message at INFO level since is the default
MyComponent WARNING  This is a WARNING this time
MyComponent   ERROR  This is an ERROR  

Configuring the MessageService

For the time being the MessageService offers two configuration parameters: