struct named_write
Declaration
struct named_write { /* full declaration omitted */ };Description
Composed of a named formatter and a named destinations. Thus, you can specify the formatting and destinations as strings
Contains a very easy interface for using @ref"formatters and destinations": - at construction, specify 2 params: the %formatter string and the destinations string Setting the @ref"formatters and destinations" to write to is extremely simple: - The format string specifies how the message is to be logged - Every formatter is escaped using % fmt % - Available formatters: - "%idx%" - writes the index of the message (formatter::idx) - "%time%" - writes the time (formatter::high_precision_time) - "%thread_id%" - writes the thread id (formatter::thread_id) - if you want to write @cdouble it, like this: @c@cis used to specify the original message. What is before it, is prepended to the message, what is after, is appended to the message - If a formatter is configurable, append @emto it - For now, only @cis configurable. For instance,@cwrites time like @c Example: The output can look like: - The syntax of the destination string specifies where the message is to be logged - Every destination is specified by name - Separate destinations by space (' ') - Available destinations - "cout" - writes to std::cout (destination::cout) - "cerr" - writes to std::cerr (destination::cerr) - "debug" - writes to the debug window: OutputDebugString in Windows, console on Linux (destination::dbg_window) - "file" - writes to a file (destination::file) - If a destination is configurable, append @emto it - Right now, @cis configurable - Append ( filename ) to them to specify the file name. Example: @cwill write to the out.txt file Examples: - "file(out.txt) cout" - will write to a file called out.txt and to cout - "cout debug" - will write to cout and debug window (see above)
Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:363
Method Overview
- public void destination(const std::string & destination_str)
- public void format(const std::string & format_str)
- public named_write()
- public template <typename Destination>void set_destination(const std::string & name, Destination dest)
- public template <typename Destination, typename... Args>void set_destination(const std::string & name, Args &&... args)
- public template <typename Formatter>void set_formatter(const std::string & name, Formatter fmt)
- public template <typename Formatter, typename... Args>void set_formatter(const std::string & name, Args &&... args)
- public void write(const std::string & format_str, const std::string & destination_str)
Methods
void destination(
const std::string& destination_str)
void destination(
const std::string& destination_str)Description
sets the destinations string - where should logged messages be outputted
Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:385
Parameters
- const std::string& destination_str
void format(const std::string& format_str)
void format(const std::string& format_str)Description
sets the format string: what should be before, and what after the original message, separated by "|"
Example: \n"[%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
Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:376
Parameters
- const std::string& format_str
named_write()
named_write()Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:365
template <typename Destination>
void set_destination(const std::string& name,
Destination dest)
template <typename Destination>
void set_destination(const std::string& name,
Destination dest)Description
Replaces a destination from the named destination.
You can use this, for instance, when you want to share a destination between multiple named writers.
Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:437
Parameters
- const std::string& name
- Destination dest
template <typename Destination, typename... Args>
void set_destination(const std::string& name,
Args&&... args)
template <typename Destination, typename... Args>
void set_destination(const std::string& name,
Args&&... args)Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:444
Parameters
- const std::string& name
- Args&&... args
template <typename Formatter>
void set_formatter(const std::string& name,
Formatter fmt)
template <typename Formatter>
void set_formatter(const std::string& name,
Formatter fmt)Description
Replaces a formatter from the named formatter.
You can use this, for instance, when you want to share a formatter between multiple named writers.
Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:419
Parameters
- const std::string& name
- Formatter fmt
template <typename Formatter, typename... Args>
void set_formatter(const std::string& name,
Args&&... args)
template <typename Formatter, typename... Args>
void set_formatter(const std::string& name,
Args&&... args)Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:426
Parameters
- const std::string& name
- Args&&... args
void write(const std::string& format_str,
const std::string& destination_str)
void write(const std::string& format_str,
const std::string& destination_str)Description
Specifies the formats and destinations in one step
Declared at: libs/pika/logging/include/pika/logging/format/named_write.hpp:394
Parameters
- const std::string& format_str
- const std::string& destination_str