hpx/logging/format/named_write.hpp

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace util
namespace logging
namespace writer
struct named_write
#include <named_write.hpp>

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

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

Contains a very easy interface for using formatters and destinations:

  • at construction, specify 2 params: the formatter string and the destinations string

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");

Public Functions

named_write()
void format(std::string const &format_str)

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

void destination(std::string const &destination_str)

sets the destinations string - where should logged messages be outputted

void write(std::string const &format_str, std::string const &destination_str)

Specifies the formats and destinations in one step.

void operator()(message const &msg) const
template<typename Formatter>
void set_formatter(std::string const &name, Formatter fmt)

Replaces a formatter from the named formatter.

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

template<typename Formatter, typename ...Args>
void set_formatter(std::string const &name, Args&&... args)
template<typename Destination>
void set_destination(std::string const &name, Destination dest)

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<typename Destination, typename ...Args>
void set_destination(std::string const &name, Args&&... args)

Private Functions

void configure_formatter(std::string const &format)
void configure_destination(std::string const &format)

Private Members

detail::named_formatters m_format
detail::named_destinations m_destination
std::string m_format_str
std::string m_destination_str