23#include <boost/unordered_map.hpp>
30#ifdef FLOW_DOXYGEN_ONLY
59# define FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_PTR value_for_exposition
90# define FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_VAL value_for_exposition
93# ifndef FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_PTR
94# define FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_PTR Component_payload_type_dict_by_ptr_via_s_hash_map
96# ifndef FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_VAL
97# define FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_VAL Component_payload_type_dict_by_val_via_array
548 template<
typename Component_payload>
550 size_t enum_sparse_length,
551 bool component_payload_type_info_ptr_is_uniq =
false);
635 template<
typename Component_payload>
636 void init_component_names(
const boost::unordered_multimap<Component_payload, std::string>& component_names,
637 bool output_components_numerically =
false,
691 template<
typename Component_payload>
739 template<
typename Component_payload>
856 FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_VAL<Component_config>>;
972 static_assert(std::numeric_limits<component_union_idx_t>::is_integer
973 && (!std::numeric_limits<component_union_idx_t>::is_signed)
974 && (!std::numeric_limits<size_t>::is_signed)
976 "size_t must be able to act as equivalent to a component_union_idx_t key.");
1100template<
typename Component_payload>
1102 size_t enum_sparse_length,
1103 bool component_payload_type_info_ptr_is_uniq)
1105 assert(enum_sparse_length >= 1);
1108 assert(component_union_idx_max >= enum_to_num_offset);
1109 assert(component_union_idx_max >= enum_sparse_length);
1115 { enum_to_num_offset },
1116 component_payload_type_info_ptr_is_uniq);
1140template<
typename Component_payload>
1142 (
const boost::unordered_multimap<Component_payload, std::string>& component_names,
1143 bool output_components_numerically,
1172 for (
auto const & enum_val_and_name : component_names)
1174 const Component_payload enum_val = enum_val_and_name.first;
1176 auto name_sans_prefix_normalized = enum_val_and_name.second;
1177 assert(!name_sans_prefix_normalized.empty());
1180 string name_normalized;
1181 name_normalized.reserve(payload_type_prefix_normalized.size() + name_sans_prefix_normalized.size());
1182 name_normalized += payload_type_prefix_normalized;
1183 name_normalized += name_sans_prefix_normalized;
1203 if (!output_components_numerically)
1206 if (output_name_so_far.empty())
1208 assert(!name_normalized.empty());
1209 output_name_so_far = std::move(name_normalized);
1213 assert(!name_sans_prefix_normalized.empty());
1214 output_name_so_far +=
',';
1215 output_name_so_far += name_sans_prefix_normalized;
1227template<
typename Component_payload>
1243template<
typename Component_payload>
1246 return static_cast<size_t>(Component_payload::S_END_SENTINEL);
void insert(const std::type_info &type, Cfg cfg, bool type_info_ptr_is_uniq)
Adds a mapping from the given type to a Cfg value, so it can be obtained by lookup().
A light-weight class, each object storing a component payload encoding an enum value from enum type o...
unsigned int enum_raw_t
The type Payload must be enum class Payload : enum_raw_t: an enum type encoded via this integer type.
Trivial wrapper of atomic<raw_sev_t> which adds a couple of things to make it possible to construct,...
Atomic_raw_sev(raw_sev_t init_val=raw_sev_t(-1))
Constructs the atomic to the given value, guaranteed to be load()ed as such in all subsequent accesse...
Class used to configure the filtering and logging behavior of Loggers; its use in your custom Loggers...
static size_t standard_component_payload_enum_sparse_length()
Returns highest numeric value in the given component-payload enum, plus 1, assuming that enum was cre...
void init_component_names(const boost::unordered_multimap< Component_payload, std::string > &component_names, bool output_components_numerically=false, util::String_view payload_type_prefix_or_empty=util::String_view())
Registers the string names of each member of the enum class Component_payload earlier registered via ...
bool m_use_human_friendly_time_stamps
Config setting: If true, time stamps will include a (deterministically formatted) date,...
Config(Sev most_verbose_sev_default=S_MOST_VERBOSE_SEV_DEFAULT)
Constructs a conceptually blank but functional set of Config.
static void normalize_component_name(std::string *name)
Normalizes given component name in place.
bool configure_component_verbosity_by_name(Sev most_verbose_sev, util::String_view component_name)
Like configure_component_verbosity(), but the component is to be specified by its registered string n...
Component_union_idx_to_name_map m_component_names_by_union_idx
Maps each flat union component index to its output component name as registered in init_component_nam...
std::vector< Atomic_raw_sev > Component_union_idx_to_sev_map
Short-hand for fast-lookup, thread-safe-for-RW mapping from flat-union-component-table index to max a...
Atomic_raw_sev m_verbosity_default
Most verbose (highest) log::Sev for which output_whether_should_log() will return true,...
static std::string normalized_component_name(util::String_view name)
Normalized version of given component name.
void operator=(const Config &)=delete
For now at least there's no reason for copy assignment.
bool output_component_to_ostream(std::ostream *os, const Component &component) const
An output of Config, this writes a string representation of the given component value to the given os...
boost::unordered_map< component_union_idx_t, std::string > Component_union_idx_to_name_map
Short-hand for map that is essentially the inverse of Component_name_to_union_idx_map.
Component_union_idx_to_sev_map m_verbosities_by_component
Maps from flat union component index to most verbose (highest) log::Sev for which output_whether_shou...
static Sev * this_thread_verbosity_override()
Returns pointer to this thread's mutable verbosity override, for querying or assignment alike.
static const Sev S_MOST_VERBOSE_SEV_DEFAULT
Recommended default/catch-all most-verbose-severity value if no specific config is given.
void init_component_to_union_idx_mapping(component_union_idx_t enum_to_num_offset, size_t enum_sparse_length, bool component_payload_type_info_ptr_is_uniq=false)
Registers a generically-typed enum class that represents the full set of the calling module's possibl...
boost::unordered_map< std::string, component_union_idx_t > Component_name_to_union_idx_map
Short-hand for fast-lookup map from normalized component name to its flat-union-component-table index...
Component::enum_raw_t component_union_idx_t
Unsigned index into the flat union of component tables maintained by a Config, combining potentially ...
static util::Scoped_setter< Sev > this_thread_verbosity_override_auto(Sev most_verbose_sev_or_none)
Sets *(this_thread_verbosity_override()) = most_verbose_sev_or_none; and returns an object that shall...
Config(Config &&)=delete
For now at least there's no reason for move-construction.
void configure_default_verbosity(Sev most_verbose_sev_default, bool reset)
Sets the default verbosity to the given value, to be used by subsequent output_whether_should_log() c...
void operator=(Config &&)=delete
For now at least there's no reason for move assignment.
uint8_t raw_sev_t
How we store a log::Sev (a mere enum itself) in a certain data structure.
Component_name_to_union_idx_map m_component_union_idxs_by_name
Maps each distinct component name as registered in init_component_names() to its flat union component...
Config(const Config &src)
Copy-constructs *this to be equal to src config object.
bool configure_component_verbosity(Sev most_verbose_sev, Component_payload component_payload)
Sets the per-component verbosity for the given component to the given value, to be used by subsequent...
bool output_whether_should_log(Sev sev, const Component &component) const
A key output of Config, this computes the verbosity-filtering answer to Logger::should_log() based on...
Component_payload_type_to_cfg_map m_component_cfgs_by_payload_type
Fast-lookup map from distinct Component_payload type to the config for that component enum.
void store_severity_by_component(component_union_idx_t component_union_idx, raw_sev_t most_verbose_sev_or_none)
Helper that for the given flat-union-component-index saves the given per-component verbosity,...
component_union_idx_t component_to_union_idx(const Component &component) const
Given a component in the form user provides it at log call sites, returns its index in the flat compo...
A simple RAII-pattern class template that, at construction, sets the specified location in memory to ...
Flow module providing logging functionality.
Sev
Enumeration containing one of several message severity levels, ordered from highest to lowest.
bool key_exists(const Container &container, const typename Container::key_type &key)
Returns true if and only if the given key is present at least once in the given associative container...
Basic_string_view< char > String_view
Commonly used char-based Basic_string_view. See its doc header.
unsigned char uint8_t
Byte. Best way to represent a byte of binary data. This is 8 bits on all modern systems.
The set of config stored for each distinct (as determined by Component::payload_type(),...
component_union_idx_t m_enum_to_num_offset
See the enum_to_num_offset arg in init_component_to_union_idx_mapping() doc header.