logger.hh File Reference

#include <lestes/common.hh>
#include <lestes/std/map.hh>
#include <lestes/std/objectize_macros.hh>
#include <lestes/std/ostream_wrapper.hh>
#include <lestes/msg/logger_formatters.hh>
#include <iosfwd>

Include dependency graph for logger.hh:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  lestes
namespace  lestes::msg

Classes

class  lestes::msg::logger

Defines

#define llog(logger)   ((*(logger)) << ::lestes::msg::fullname_formatter::instance())
#define llog_plain(logger)   ((*(logger)) << ::lestes::msg::plain_formatter::instance())
#define llog_xml_open(logger, tag)
#define llog_xml_close(logger, tag)   ((*(logger)) << ::lestes::msg::plain_formatter::instance() << "</" << (tag) << '>')
#define declare_logger(variable_name)
 declares logger with specified name, used in namespace scope
#define initialize_logger(variable_name, logger_name, parent_variable)
 declares the logger variable with correct initializer
#define initialize_top_logger(variable_name, logger_name)
 similar to initialize_logger, just the logger will be a child of the root one


Detailed Description

Logger and the llog macro.
Author:
Rudo

Define Documentation

#define declare_logger ( variable_name   ) 

Value:

extern ::lestes::std::ptr< ::lestes::msg::logger > variable_name; \
        const ::lestes::std::ptr< ::lestes::msg::logger > & variable_name##_init();
declares logger with specified name, used in namespace scope

The declare_logger macro declares [extern] variable with given name, its type is ptr<logger>; the variable is ready to be passed to llog family of macros. The actual definition of the variable is handled by initialize_top_logger and initialize_logger macros.

The macro can only be used in namespace scope. It can be used in a header file.

Note: The macro also declares a function named variable_name#_init (i.e. passed name suffixed with _init) which is used to initialize the pointer.

#define initialize_logger ( variable_name,
logger_name,
parent_variable   ) 

Value:

ptr< ::lestes::msg::logger > variable_name = variable_name##_init(); \
        \
        const ptr< ::lestes::msg::logger > & variable_name##_init() \
        { \
                if (!variable_name) \
                        variable_name = ::lestes::msg::logger::create( \
                                        logger_name, parent_variable##_init() ); \
                return variable_name; \
        }
declares the logger variable with correct initializer

The initialize_logger macro declares the logger variable and initializes it. Name of the logger instance and name of variable with a pointer to parent logger are passed as arguments. The parent variable must be declared and initialized using declare_logger and initialize_logger (or initialize_top_logger) macros.

The macro can only be used in namespace scope. It MUST NOT be used in a header file.

Note: The macro also defines a function used to initialize the pointer. Such function of the parent logger is called from it. By analogy, this function is used when the logger is used as a parent in different initialize_logger macro invocation.

#define initialize_top_logger ( variable_name,
logger_name   ) 

Value:

ptr< ::lestes::msg::logger > variable_name = variable_name##_init(); \
        \
        const ptr< ::lestes::msg::logger > & variable_name##_init() \
        { \
                if (!variable_name) \
                        variable_name = ::lestes::msg::logger::create( \
                                logger_name, ::lestes::msg::logger::root_instance() ); \
                return variable_name; \
        }
similar to initialize_logger, just the logger will be a child of the root one

#define llog ( logger   )     ((*(logger)) << ::lestes::msg::fullname_formatter::instance())

The llog macro calls fullname_formatter on given logger, which prints full name of the logger followed by ": ". You can use the << operator in the result.

#define llog_plain ( logger   )     ((*(logger)) << ::lestes::msg::plain_formatter::instance())

The llog_plain macro calls plain_formatter on given logger. The plain_formatter does nothing except returning the logger's ostream.

#define llog_xml_close ( logger,
tag   )     ((*(logger)) << ::lestes::msg::plain_formatter::instance() << "</" << (tag) << '>')

The llog_xml_close prints closing tag with specified name to given logger. It is just a simple wrapper around llog_plain.

#define llog_xml_open ( logger,
tag   ) 

Value:

The llog_xml_open macro outputs opening xml tag with given name to given logger. The tag contains attribute named 'by' filled with full path of the logger. xml_formatter is used to achieve this.

Note: To avoid the 'by' attribute, simply use llog_plain.


Generated on Mon Feb 12 18:38:05 2007 for lestes by doxygen 1.5.1-20070107