logging¶
#include <compatibility/hpx/util/logging.hpp>
¶
#include <compatibility/hpx/util/logging/format_fwd.hpp>
¶
#include <compatibility/hpx/util/logging/format.hpp>
¶
#include <compatibility/hpx/util/logging/logging.hpp>
¶
#include <compatibility/hpx/util/logging/writer/format_write.hpp>
¶
#include <compatibility/hpx/util/logging/writer/named_write.hpp>
¶
#include <compatibility/hpx/util/logging/format/named_write.hpp>
¶
#include <compatibility/hpx/util/logging/format/named_write_fwd.hpp>
¶
#include <compatibility/hpx/util/logging/format/op_equal.hpp>
¶
#include <compatibility/hpx/util/logging/format/optimize.hpp>
¶
#include <compatibility/hpx/util/logging/format/array.hpp>
¶
#include <compatibility/hpx/util/logging/format/formatter/thread_id.hpp>
¶
#include <compatibility/hpx/util/logging/format/formatter/spacer.hpp>
¶
#include <compatibility/hpx/util/logging/format/formatter/time_strf.hpp>
¶
#include <compatibility/hpx/util/logging/format/formatter/time.hpp>
¶
#include <compatibility/hpx/util/logging/format/formatter/high_precision_time.hpp>
¶
#include <compatibility/hpx/util/logging/format/formatter/named_spacer.hpp>
¶
#include <compatibility/hpx/util/logging/format/formatter/convert_format.hpp>
¶
#include <compatibility/hpx/util/logging/format/formatter/defaults.hpp>
¶
#include <compatibility/hpx/util/logging/format/destination/convert_destination.hpp>
¶
#include <compatibility/hpx/util/logging/format/destination/named.hpp>
¶
#include <compatibility/hpx/util/logging/format/destination/file.hpp>
¶
#include <compatibility/hpx/util/logging/format/destination/defaults.hpp>
¶
#include <hpx/logging.hpp>
¶
Defines
-
LAGAS_
(lvl)¶
-
LPT_
(lvl)¶
-
LTIM_
(lvl)¶
-
LPROGRESS_
¶
-
LHPX_
(lvl, cat)¶
-
LAPP_
(lvl)¶
-
LDEB_
¶
-
LTM_
(lvl)¶
-
LRT_
(lvl)¶
-
LOSH_
(lvl)¶
-
LERR_
(lvl)¶
-
LLCO_
(lvl)¶
-
LPCS_
(lvl)¶
-
LAS_
(lvl)¶
-
LBT_
(lvl)¶
-
LFATAL_
¶
-
LAGAS_CONSOLE_
(lvl)¶
-
LPT_CONSOLE_
(lvl)¶
-
LTIM_CONSOLE_
(lvl)¶
-
LHPX_CONSOLE_
(lvl)¶
-
LAPP_CONSOLE_
(lvl)¶
-
LDEB_CONSOLE_
¶
-
LAGAS_ENABLED
(lvl)¶
-
LPT_ENABLED
(lvl)¶
-
LTIM_ENABLED
(lvl)¶
-
LHPX_ENABLED
(lvl)¶
-
LAPP_ENABLED
(lvl)¶
-
LDEB_ENABLED
¶
Functions
-
template <typename T>
bootstrap_logging const &operator<<
(bootstrap_logging const &l, T&&)¶
Variables
-
constexpr bootstrap_logging
lbt_
¶
#include <hpx/logging/format_fwd.hpp>
¶
#include <hpx/logging/format.hpp>
¶
Include this file when you’re using formatters and destinations, and you want to define the logger classes, in a source file (using HPX_DEFINE_LOG)
-
namespace
hpx
-
namespace
util
-
namespace
logging
¶ -
namespace
format_and_write
¶ The
format_and_write
classes know how to call the formatter and destinationobjects
.Usually you’ll be happy with the format_and_write::simple class - which simply calls
operator()
on the formatters , andoperator()
on the destinations.Note that usually the formatter and destination class just have an
operator()
, which when called, formats the message or writes it to a destination. In case your formatters/destinations are more complex than that (for instance, more than a member function needs to be called), you’ll have to implement your own format_and_write class.-
struct
simple
¶ - #include <format.hpp>
Formats the message, and writes it to destinations.
- calls
operator()
on the formatters , andoperator()
on the destinations. Ignoresclear_format()
commands.
If you derive from
destination::base
, this type can bedestination::base::raw_param
(see below).- Parameters
msg_type
: The message to pass to the formatter. This is the type that is passed to the formatter objects and to the destination objects. Thus, it needs to be convertible to the argument to be sent to the formatter objects and to the argument to be sent to the destination objects. Usually, it’s the argument you pass on to your destination classes.
Example:
typedef destination::base<const std::string &> dest_base; // in this case : msg_type = std::string = dest_base::raw_param struct write_to_cout : dest_base { void operator()(param msg) const { std::cout << msg ; } }; typedef destination::base<const std::string &> dest_base; // in this case : msg_type = cache_string = dest_base::raw_param struct write_to_file : dest_base, ... { void operator()(param msg) const { context() << msg ; } };
Public Functions
-
simple
(msg_type &msg)¶
-
template <class formatter_ptr>
voidformat
(const formatter_ptr &fmt)¶
-
template <class destination_ptr>
voidwrite
(const destination_ptr &dest)¶
-
void
clear_format
()¶
Protected Attributes
-
msg_type &
m_msg
¶
- calls
-
struct
-
namespace
msg_route
¶ Specifies the route : how formatting and writing to destinations take place.
Classes in this namespace specify when formatters and destinations are to be called.
-
template <class formatter_array, class destination_array>
structformatter_and_destination_array_holder
¶ - #include <format.hpp>
Recomended base class for message routers that need access to the underlying formatter and/or destination array.
-
struct
simple
¶ - #include <format.hpp>
Represents a simple router - first calls all formatters.
- in the order they were added, then all destinations - in the order they were added
Example:
typedef logger< format_write > logger_type; HPX_DEFINE_LOG_FILTER(g_log_filter, filter::no_ts ) HPX_DEFINE_LOG(g_l, logger_type) #define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) // add formatters : [idx] [time] message [enter] g_l()->writer().add_formatter( write_idx() ); g_l()->writer().add_formatter( write_time() ); g_l()->writer().add_formatter( append_newline() ); // write to cout and file g_l()->writer().add_destination( write_to_cout() ); g_l()->writer().add_destination( write_to_file("out.txt") ); // usage int i = 1; L_ << "testing " << i << i+1 << i+2;
In the above case:
- First, the formatters are called:
write_idx()
is called, thenwrite_time()
, thenappend_newline()
. - Then, the destinations are called:
write_to_cout()
, and thenwrite_to_file()
.
- Parameters
format_base
: The base class for all formatter classes from your application. See manipulator.destination_base
: The base class for all destination classes from your application. See manipulator.
Public Types
-
typedef destination::base::ptr_type
destination_ptr
¶
-
typedef std::vector<formatter_ptr>
f_array
¶
-
typedef std::vector<destination_ptr>
d_array
¶
Public Functions
-
template <class formatter_array, class destination_array>
simple
(const formatter_array&, const destination_array&)¶
-
void
append_formatter
(formatter_ptr fmt)¶
-
void
del_formatter
(formatter_ptr fmt)¶
-
void
append_destination
(destination_ptr dest)¶
-
void
del_destination
(destination_ptr dest)¶
-
template <class format_and_write>
voidwrite
(msg_type &msg) const¶
Private Members
-
write_info
m_to_write
¶
-
struct
write_info
¶
-
template <class formatter_array, class destination_array>
-
namespace
-
namespace
-
namespace
#include <hpx/logging/logging.hpp>
¶
Include this file when you’re using the logging lib, but don’t necessarily want to use formatters and destinations. If you want to use formatters and destinations, then you can include this one instead:
#include <hpx/logging/format_fwd.hpp>
#include <hpx/logging/writer/format_write.hpp>
¶
#include <hpx/logging/writer/named_write.hpp>
¶
-
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
(const std::string &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
format
(const std::string &format_before_str, const std::string &format_after_str)¶ sets the format strings (what should be before, and what after the original message)
-
void
destination
(const std::string &destination_str)¶ sets the destinations string - where should logged messages be outputted
-
void
write
(const std::string &format_str, const std::string &destination_str)¶ Specifies the formats and destinations in one step.
-
void
operator()
(msg_type &msg) const¶
-
template <class destination>
voidreplace_destination
(const std::string &name, destination d)¶ 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 formatter>
voidreplace_formatter
(const std::string &name, formatter d)¶ 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 <class destination>
voidadd_destination
(const std::string &name, destination d)¶
Private Functions
-
template <class manipulator, class parser_type>
voidset_and_configure
(manipulator &manip, const std::string &name, parser_type parser)¶
-
void
init
()¶
Private Members
-
formatter::named_spacer_t<formatter::do_convert_format::prepend>
m_format_before
¶
-
formatter::named_spacer_t<formatter::do_convert_format::append>
m_format_after
¶
-
destination::named
m_destination
¶
-
format_write
m_writer
¶
-
struct
parse_destination
¶
-
struct
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/named_write.hpp>
¶
#include <hpx/logging/format/named_write_fwd.hpp>
¶
#include <hpx/logging/format/op_equal.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
op_equal
¶ Implements operator== for manipulators.
Functions
-
bool
operator==
(const same_type_op_equal_top &a, const same_type_op_equal_top &b)¶
-
template <class type>
structsame_type_op_equal
: public hpx::util::logging::op_equal::same_type_op_equal_base¶ - #include <op_equal.hpp>
Implements operator==, which compares two objects. If they have the same type, it will compare them using the type’s member operator==.
The only constraint is that operator== must be a member function
Public Functions
-
virtual bool
equals
(const same_type_op_equal_top &other) const¶
-
virtual bool
-
struct
same_type_op_equal_base
: public virtual hpx::util::logging::op_equal::same_type_op_equal_top¶ - #include <op_equal.hpp>
Base class when you want to implement operator== that will compare based on type and member operator==.
Subclassed by hpx::util::logging::op_equal::same_type_op_equal< type >
-
struct
same_type_op_equal_top
¶ Subclassed by hpx::util::logging::op_equal::same_type_op_equal_base
Public Functions
-
virtual bool
equals
(const same_type_op_equal_top&) const = 0¶
Protected Functions
-
same_type_op_equal_top
()¶
-
virtual
~same_type_op_equal_top
()¶
-
same_type_op_equal_top
(const same_type_op_equal_top&)¶
-
virtual bool
-
bool
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/optimize.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
optimize
¶ Gathering the message: contains optimizers for formatting and/or destinations: for example, caching techniques.
Functions
-
template <class stream>
stream &operator<<
(stream &out, const cache_string_one_str &val)¶
-
struct
cache_string_one_str
¶ - #include <optimize.hpp>
Optimizes the formatting for prepending and/or appending strings to the original message.
It keeps all the modified message in one string. Useful if some formatter needs to access the whole string at once.
reserve_prepend() - the size that is reserved for prepending (similar to string::reserve function) reserve_append() - the size that is reserved for appending (similar to string::reserve function)
Note : as strings are prepended, reserve_prepend() shrinks. Same goes for append.
Public Types
-
typedef cache_string_one_str
self_type
¶
Public Functions
-
cache_string_one_str
(std::size_t reserve_prepend_, std::size_t reserve_append_, std::size_t grow_size_ = 10)¶ - Parameters
reserve_prepend
: - how many chars to have space to prepend by defaultreserve_append
: - how many chars to have space to append by defaultgrow_size
: - in case we add a string and there’s no room for it, with how much should we grow? We’ll grow this much in addition to the added string- in the needed direction
-
cache_string_one_str
(const std::string &msg, std::size_t reserve_prepend_ = 10, std::size_t reserve_append_ = 10, std::size_t grow_size_ = 10)¶ - Parameters
msg
: - the message that is originally cachedreserve_prepend
: - how many chars to have space to prepend by defaultreserve_append
: - how many chars to have space to append by defaultgrow_size
: - in case we add a string and there’s no room for it, with how much should we grow? We’ll grow this much in addition to the added string- in the needed direction
-
cache_string_one_str
(cache_string_one_str &&other)¶
-
cache_string_one_str
()¶
-
void
prepend_string
(const char *str)¶
-
void
append_string
(const char *str)¶
-
template <class stream_type>
voidto_stream
(stream_type &stream) const¶ writes the current cached contents to a stream
-
operator const std::string&
() const¶
Private Functions
-
bool
is_string_set
() const¶
Private Members
-
bool
m_full_msg_computed
¶
-
typedef cache_string_one_str
-
template <class stream>
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/array.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
array
¶ -
template <class base_type>
classptr_holder
¶ - #include <array.hpp>
Holds an array of manipulators (formatters or destinations). It owns them, holding them internally as smart pointers Each function call is locked.
The base_type must implement operator==
When you call get_ptr() or del(), the type you provide, must implement operator==(const type& , const base_type&)
Public Functions
-
template <class derived>
base_type *append
(derived val)¶
-
template <class derived>
base_type *get_ptr
(derived val) const¶
-
template <class derived>
voiddel
(derived val)¶
-
void
del
(base_type *p)¶
Private Members
-
array_type
m_array
¶
-
template <class derived>
-
template <class base_type>
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/formatter/thread_id.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
formatter
¶ Typedefs
-
typedef thread_id_t
thread_id
¶ thread_id_t with default values. See thread_id_t
Writes the thread_id to the log.
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
-
template <class convert = do_convert_format::prepend>
structthread_id_t
: public is_generic¶ - #include <thread_id.hpp>
Writes the thread_id to the log.
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
-
typedef thread_id_t
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/formatter/spacer.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
formatter
Functions
-
template <class original_formatter>
detail::find_spacer<original_formatter>::typespacer
(const original_formatter &fmt, const char *format_str)¶ Prepends some info, and appends some info to an existing formatter.
The syntax is simple: construct a spacer by passing the original formatter, and the text to space (prepend and append). Use:
%
to mean the original formatter text- anything before
"%"
is prepended before - anything after
"%"
is appended after
Examples:
// prefix "[" before index, and append "] " after it. formatter::spacer( formatter::idx(), "[%] "); // prefix "{T" before thread_id, and append "} " after it formatter::spacer( formatter::thread_id(), "{T%} ");
When adding a spacer formatter, you’ll do something similar to:
g_l()->writer().add_formatter( formatter::spacer( formatter::idx(), "[%] ") );
However, to make this even simpler, I allow an ever easier syntax:
// equivalent to the above g_l()->writer().add_formatter( formatter::idx(), "[%] " );
-
template <class convert, class original_formatter, bool is_generic_formatter>
structspacer_t
: public original_formatter¶ - #include <spacer.hpp>
Prepends some info, and appends some info to an existing formatter.
The syntax is simple: construct a spacer by passing the original formatter, and the text to space (prepend and append). Use:
%
to mean the original formatter text- anything before
"%"
is prepended before - anything after
"%"
is appended after
Examples:
// prefix "[" before index, and append "] " after it. formatter::spacer( formatter::idx(), "[%] "); // prefix "{T" before thread_id, and append "} " after it formatter::spacer( formatter::thread_id(), "{T%} ");
When adding a spacer formatter, you’ll do something similar to:
g_l()->writer().add_formatter( formatter::spacer( formatter::idx(), "[%] ") );
However, to make this even simpler, I allow an ever easier syntax:
// equivalent to the above g_l()->writer().add_formatter( formatter::idx(), "[%] " );
Public Functions
-
spacer_t
(const original_formatter &fmt, const char *format_str)¶
-
template <class convert, class original_formatter>
template<>
structspacer_t
<convert, original_formatter, true> : public original_formatter¶ Public Types
-
typedef original_formatter
spacer_base
Public Functions
-
spacer_t
(const original_formatter &fmt, const char *format_str)
-
void
operator()
(msg_type &msg) const¶
Private Functions
-
void
parse_format
(const std::string &format_str)
-
typedef original_formatter
-
template <class original_formatter>
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/formatter/time_strf.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
formatter
Typedefs
-
typedef time_strf_t
time_strf
¶ time_strf_t with default values. See time_strf_t
Prefixes the message with the time, by using strftime function. You pass the format string at construction.
- Parameters
msg_type
: The type that holds your logged message.convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
-
template <class convert = do_convert_format::prepend>
structtime_strf_t
: public is_generic¶ - #include <time_strf.hpp>
Prefixes the message with the time, by using strftime function. You pass the format string at construction.
- Parameters
msg_type
: The type that holds your logged message.convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
Public Functions
-
time_strf_t
(const std::string &format, bool localtime)¶ constructs a time_strf object
- Parameters
format
: the time format , strftime-likelocaltime
: if true, use localtime, otherwise global time
-
void
operator()
(msg_type &msg) const¶
-
bool
operator==
(const time_strf_t &other) const¶
-
typedef time_strf_t
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/formatter/time.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
formatter
Typedefs
-
typedef time_t
time
¶ time_t with default values. See time_t
Prefixes the message with the time. You pass the format string at construction. It’s friendlier than write_time_strf (which uses strftime).
The format can contain escape sequences: $dd - day, 2 digits $MM - month, 2 digits $yy - year, 2 digits $yyyy - year, 4 digits $hh - hour, 2 digits $mm - minute, 2 digits $ss - second, 2 digits
Example: time(“Today is $dd/$MM/$yyyy”);
Note: for a high precision clock, try high_precision_time (uses hpx::util::date_time)
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
-
template <class convert = do_convert_format::prepend>
structtime_t
: public is_generic, public non_const_context<hpx::util::logging::detail::time_format_holder>¶ - #include <time.hpp>
Prefixes the message with the time. You pass the format string at construction.
It’s friendlier than write_time_strf (which uses strftime).
The format can contain escape sequences: $dd - day, 2 digits $MM - month, 2 digits $yy - year, 2 digits $yyyy - year, 4 digits $hh - hour, 2 digits $mm - minute, 2 digits $ss - second, 2 digits
Example: time(“Today is $dd/$MM/$yyyy”);
Note: for a high precision clock, try high_precision_time (uses hpx::util::date_time)
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
Public Types
Public Functions
-
void
operator()
(msg_type &msg) const¶
-
typedef time_t
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/formatter/high_precision_time.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
formatter
Typedefs
-
typedef high_precision_time_t
high_precision_time
¶ high_precision_time_t with default values. See high_precision_time_t
Prefixes the message with a high-precision time (. You pass the format string at construction.
#include <hpx/logging/format/formatter/high_precision_time.hpp>
Internally, it uses hpx::util::date_time::microsec_time_clock. So, our precision matches this class.
The format can contain escape sequences: $dd - day, 2 digits $MM - month, 2 digits $yy - year, 2 digits $yyyy - year, 4 digits $hh - hour, 2 digits $mm - minute, 2 digits $ss - second, 2 digits $mili - milliseconds $micro - microseconds (if the high precision clock allows; otherwise, it pads zeros) $nano - nanoseconds (if the high precision clock allows; otherwise, it pads zeros)
Example:
high_precision_time("$mm:$ss:$micro");
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
-
template <class convert = do_convert_format::prepend>
structhigh_precision_time_t
: public is_generic, public non_const_context<hpx::util::logging::detail::time_format_holder>¶ - #include <high_precision_time.hpp>
Prefixes the message with a high-precision time (. You pass the format string at construction.
#include <hpx/logging/format/formatter/high_precision_time.hpp>
Internally, it uses hpx::util::date_time::microsec_time_clock. So, our precision matches this class.
The format can contain escape sequences: $dd - day, 2 digits $MM - month, 2 digits $yy - year, 2 digits $yyyy - year, 4 digits $hh - hour, 2 digits $mm - minute, 2 digits $ss - second, 2 digits $mili - milliseconds $micro - microseconds (if the high precision clock allows; otherwise, it pads zeros) $nano - nanoseconds (if the high precision clock allows; otherwise, it pads zeros)
Example:
high_precision_time("$mm:$ss:$micro");
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
Public Types
-
typedef high_precision_time_t
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/formatter/named_spacer.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
formatter
-
template <class convert>
structnamed_spacer_t
: public is_generic, public non_const_context<detail::named_spacer_context<convert>>¶ - #include <named_spacer.hpp>
Allows you to contain multiple formatters, and specify a spacer between them. You have a spacer string, and within it, you can escape your contained formatters.
#include <hpx/logging/format/formatter/named_spacer.hpp>
This allows you:
- to hold multiple formatters
- each formatter is given a name, when being added
- you have a spacer string, which contains what is to be prepended or appended to the string (by default, prepended)
- a formatter is escaped with
'%'
chars, like this"%name%"
- if you want to write the
'%'
, just double it, like this:"this %% gets written"
Example:
#define L_ HPX_LOG_USE_LOG_IF_FILTER(g_l(), g_log_filter()->is_enabled() ) g_l()->writer().add_formatter( formatter::named_spacer("[%index%] %time% (T%thread%) ") .add( "index", formatter::idx()) .add( "thread", formatter::thread_id()) .add( "time", formatter::time("$mm")) );
Assuming you’d use the above in code
int i = 1; L_ << "this is so cool " << i++; L_ << "this is so cool again " << i++;
You could have an output like this:
[1] 53 (T3536) this is so cool 1 [2] 54 (T3536) this is so cool again 2
Public Functions
-
named_spacer_t &
string
(const std::string &str)¶
-
template <class formatter>
named_spacer_t &add
(const std::string &name, formatter fmt)¶
-
void
operator()
(msg_type &msg) const¶
-
bool
operator==
(const named_spacer_t &other) const¶
-
template <class convert>
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/formatter/convert_format.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
formatter
-
-
namespace
convert
¶ Allows format convertions.
- In case you’re using a formatter that does not match your string type
In case you want to use a formatter developed by someone else (for instance, a formatter provided by this lib), perhaps you’re using another type of string to hold the message
- thus, you need to provide a conversion function
Example: FIXME
> convert_format::prepend
explain that you can extend the following - since they’re namespaces!!! so that you can “inject” your own write function in the convert_format::prepend/orwhatever namespace, and then it’ll be automatically used!
-
namespace
append
¶
-
namespace
prepend
¶ Example : write_time
-
namespace
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/formatter/defaults.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
formatter
Typedefs
-
typedef idx_t
idx
¶ idx_t with default values. See idx_t
prefixes each message with an index. Example:
L_ << "my message"; L_ << "my 2nd message";
This will output something similar to:
[1] my message [2] my 2nd message
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
-
typedef append_newline_t
append_newline
¶ append_newline_t with default values. See append_newline_t
Appends a new line.
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
-
typedef append_newline_if_needed_t
append_newline_if_needed
¶ append_newline_if_needed_t with default values. See append_newline_if_needed_t
Appends a new line, if not already there.
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
-
template <class convert = do_convert_format::append>
structappend_newline_if_needed_t
: public is_generic¶ - #include <defaults.hpp>
Appends a new line, if not already there.
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
Public Functions
-
void
operator()
(msg_type &str) const¶
-
bool
operator==
(const append_newline_if_needed_t&) const¶
-
template <class convert = do_convert_format::append>
structappend_newline_t
: public is_generic¶ - #include <defaults.hpp>
Appends a new line.
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
Public Functions
-
void
operator()
(msg_type &str) const¶
-
bool
operator==
(const append_newline_t&) const¶
-
template <class convert = do_convert_format::prepend>
structidx_t
: public is_generic, public formatter::non_const_context<std::uint64_t>¶ - #include <defaults.hpp>
prefixes each message with an index.
Example:
L_ << "my message"; L_ << "my 2nd message";
This will output something similar to:
[1] my message [2] my 2nd message
- Parameters
convert
: [optional] In case there needs to be a conversion between std::(w)string and the string that holds your logged message. See convert_format. For instance, you might use a cached_string class (see optimize namespace).
Public Types
-
typedef idx_t
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/destination/convert_destination.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
destination
¶
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/destination/named.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
destination
-
struct
named
: public is_generic, public non_const_context<detail::named_context>¶ - #include <named.hpp>
Allows you to contain multiple destinations, give each such destination a name. Then, at run-time, you can specify a format string which will specify which destinations to be called, and on what order.
This allows you:
- to hold multiple destinations
- each destination is given a name, when being added. The name must not contain spaces and must not start with ‘+’/’-‘ signs
- you have a format string, which contains what destinations to be called, and on which order
The format string contains destination names, separated by space.
When a message is written to this destination, I parse the format string. When a name is encountered, if there’s a destination corresponding to this name, I will call it.
Example:
g_l()->writer().add_destination( destination::named("cout out debug") .add( "cout", destination::cout()) .add( "debug", destination::dbg_window() ) .add( "out", destination::file("out.txt")) );
In the above code, we’ll write to 3 destinations, in the following order:
- first, to the console
- second, to the out.txt file
- third, to the debug window
Public Types
-
typedef non_const_context<detail::named_context>
non_const_context_base
¶
Public Functions
-
named
(const std::string &format_string = std::string())¶ constructs the named destination
- Parameters
named_name
: name of the namedset
: [optional] named settings - see named_settings class, and dealing_with_flags
-
void
operator()
(const msg_type &msg) const¶
-
template <class destination>
named &add
(const std::string &name, destination dest)¶
-
struct
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/destination/file.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
destination
-
struct
file
: public is_generic, public non_const_context<detail::file_info>¶ - #include <file.hpp>
Writes the string to a file.
Public Types
-
typedef non_const_context<detail::file_info>
non_const_context_base
¶
Public Functions
-
file
(const std::string &file_name, file_settings set = file_settings())¶ constructs the file destination
- Parameters
file_name
: name of the fileset
: [optional] file settings - see file_settings class, and dealing_with_flags
-
void
operator()
(const msg_type &msg) const¶
Public Static Attributes
-
mutex_type
mtx_
¶
-
typedef non_const_context<detail::file_info>
-
struct
-
namespace
-
namespace
-
namespace
#include <hpx/logging/format/destination/defaults.hpp>
¶
-
namespace
hpx
-
namespace
util
-
namespace
logging
-
namespace
destination
-
struct
cerr
: public is_generic¶ - #include <defaults.hpp>
Writes the string to cerr.
-
struct
cout
: public is_generic¶ - #include <defaults.hpp>
Writes the string to console.
-
struct
dbg_window
: public is_generic¶ - #include <defaults.hpp>
Writes the string to output debug window.
For non-Windows systems, this is the console.
Public Functions
-
void
operator()
(const msg_type &msg) const¶
-
bool
operator==
(const dbg_window&) const¶
-
void
-
struct
stream
: public is_generic, public non_const_context<std::ostream *>¶ - #include <defaults.hpp>
writes to stream.
- Note
- : The stream must outlive this object! Or, clear() the stream, before the stream is deleted.
Public Types
-
typedef non_const_context<stream_type *>
non_const_context_base
¶
Public Functions
-
stream
(stream_type *s)¶
-
stream
(stream_type &s)¶
-
void
operator()
(const msg_type &msg) const¶
-
void
set_stream
(stream_type *p)¶ resets the stream. Further output will be written to this stream
-
void
clear
()¶ clears the stream. Further output will be ignored
-
struct
-
namespace
-
namespace
-
namespace