boost::logging::writer::named_write< format_write_ > Struct Template Reference

Composed of a named formatter and a named destinations. Thus, you can specify the formatting and destinations as strings. More...

List of all members.

Public Member Functions

void format (const string_type &format_str)
 sets the format string: what should be before, and what after the original message, separated by "|"
void format (const string_type &format_before_str, const string_type &format_after_str)
 sets the format strings (what should be before, and what after the original message)
void destination (const string_type &destination_str)
 sets the destinations string - where should logged messages be outputted
void write (const string_type &format_str, const string_type &destination_str)
 Specifies the formats and destinations in one step.
template<class destination>
void replace_destination (const string_type &name, destination d)
 Replaces a destination from the named destination.
template<class formatter>
void replace_formatter (const string_type &name, formatter d)
 Replaces a formatter from the named formatter.


Detailed Description

template<class format_write_>
struct boost::logging::writer::named_write< format_write_ >

Composed of a named formatter and a named destinations. Thus, you can specify the formatting and destinations as strings.

#include <boost/logging/format/named_write.hpp>

Contains a very easy interface for using formatters and destinations:

Setting the formatters and destinations to write to is extremely simple:

// Set the formatters (first param) and destinatins (second step) in one step 
g_l()->writer().write("%time%($hh:$mm.$ss.$mili) [%idx%] |\n", "cout file(out.txt) debug");

// set the formatter(s)
g_l()->writer().format("%time%($hh:$mm.$ss.$mili) [%idx%] |\n");

// set the destination(s)
g_l()->writer().destination("cout file(out.txt) debug");

The syntax of the format string

Example:

"%time%($hh:$mm.$ss.$mili) [%idx%] |\n"

The output can look like:

21:03.17.243 [1] this is so cool 
21:03.17.243 [2] first error 
21:03.17.243 [3] hello, world

The syntax of the destinations string

Examples:

Note:
If you want to output to 2 files, don't use "file(one.txt) file(two.txt)". This will just configure "file" twice, ending up with writing only to "two.txt" file. Use "file(one.txt) file2(two.txt)" instead!

At this time, named_write does not support tags. However, it's a high priority on my TODO list, so it'll be here soon!

Parameters:
format_write_ the underlying format writer

Member Function Documentation

template<class format_write_>
void boost::logging::writer::named_write< format_write_ >::format ( const string_type &  format_str  )  [inline]

sets the format string: what should be before, and what after the original message, separated by "|"

Example:
"[%idx%] |\n" - this writes "[%idx%] " before the message, and "\n" after the message

If "|" is not present, the whole message is prepended to the message

template<class format_write_>
template<class destination>
void boost::logging::writer::named_write< format_write_ >::replace_destination ( const string_type &  name,
destination  d 
) [inline]

Replaces a destination from the named destination.

You can use this, for instance, when you want to share a destination between multiple named writers.

template<class format_write_>
template<class formatter>
void boost::logging::writer::named_write< format_write_ >::replace_formatter ( const string_type &  name,
formatter  d 
) [inline]

Replaces a formatter from the named formatter.

You can use this, for instance, when you want to share a formatter between multiple named writers.


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

Copyright John Torjo © 2007
Have a question/ suggestion/ comment? Send me feedback