31 "fatl",
"eror",
"warn",
32 "info",
"debg",
"trce",
"data" });
34 = boost::chrono::system_clock::from_time_t(0);
40 m_do_log_func(m_config.m_use_human_friendly_time_stamps
44 m_clean_os_state(m_os),
45 m_last_human_friendly_time_stamp_str_sz(0)
82 using std::chrono::duration_cast;
83 using std::chrono::microseconds;
91 const auto since_epoch = duration_cast<microseconds>(metadata.
m_called_when.time_since_epoch());
93 const auto usec_since_epoch = since_epoch.count();
94 const microseconds::rep sec = usec_since_epoch / 1000000;
95 const microseconds::rep usec = usec_since_epoch % 1000000;
99 << setw(6) << usec <<
' ';
108 using std::chrono::time_point_cast;
109 using std::chrono::seconds;
110 using std::chrono::system_clock;
115 constexpr String_view TIME_STAMP_FORMAT(
"{0:%Y-%m-%d %H:%M:}{1:%S} {0:%z} ");
131 const auto rounded_time_stamp = time_point_cast<seconds>(metadata.
m_called_when);
145 static_cast<const std::string_view&
>(TIME_STAMP_FORMAT),
146 fmt::localtime(system_clock::to_time_t(metadata.
m_called_when)),
175 m_os << '[' << S_SEV_STRS[static_cast<size_t>(metadata.
m_msg_sev)] <<
"]: T";
Class used to configure the filtering and logging behavior of Loggers; its use in your custom Loggers...
bool m_use_human_friendly_time_stamps
Config setting: If true, time stamps will include a (deterministically formatted) date,...
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...
Utility class, each object of which wraps a given ostream and outputs discrete messages to it adorned...
const Function< void(Ostream_log_msg_writer *, const Msg_metadata &, util::String_view)> m_do_log_func
Pointer to function that log() will forward to when invoked.
static const std::vector< util::String_view > S_SEV_STRS
Mapping from Sev to its brief string description.
size_t m_last_human_friendly_time_stamp_str_sz
Length of string in m_last_human_friendly_time_stamp_str (excluding any NUL).
static const boost::chrono::system_clock::time_point S_POSIX_EPOCH
Jan 1, 1970, 00:00.
std::array< char, S_HUMAN_FRIENDLY_TIME_STAMP_MIN_SZ_TEMPLATE.size()+S_HUMAN_FRIENDLY_TIME_STAMP_REST_SZ_TEMPLATE.size()+1 > m_last_human_friendly_time_stamp_str
Buffer storing the last log() time stamp in human-friendly form, including a NUL at the end.
void do_log_with_human_friendly_time_stamp(const Msg_metadata &metadata, util::String_view msg)
log() implementation with time stamp = date/time with microsecond+ resolution/time zone,...
static constexpr util::String_view S_HUMAN_FRIENDLY_TIME_STAMP_MIN_SZ_TEMPLATE
Example human-readable time stamp output, up to but excluding seconds, for compile-time size calculat...
Ostream_log_msg_writer(const Config &config, std::ostream &os)
Constructs object wrapping the given ostream.
std::chrono::time_point< std::chrono::system_clock, std::chrono::seconds > m_cached_rounded_time_stamp
As used in the caching-for-perf algorithm in do_log_with_human_friendly_time_stamp(),...
void log_past_time_stamp(const Msg_metadata &metadata, util::String_view msg)
Remainder of log() functionality after either do_log_with_epoch_time_stamp() or do_log_with_human_fri...
const Config & m_config
Reference to the config object passed to constructor. See notes on thread safety.
~Ostream_log_msg_writer() noexcept
Restores formatting state of os to how it was before entry to constructor.
void do_log_with_epoch_time_stamp(const Msg_metadata &metadata, util::String_view msg)
log() implementation with time stamp = seconds.microseconds since Epoch.
void log(const Msg_metadata &metadata, util::String_view msg)
Logs to the wrapped ostream the given message and associated metadata like severity and time stamp; p...
std::ostream & m_os
Reference to stream to which to log messages.
Flow module providing logging functionality.
@ S_NONE
Sentinel log level that must not be specified for any actual message (at risk of undefined behavior s...
Basic_string_view< char > String_view
Commonly used char-based Basic_string_view. See its doc header.
#define FLOW_UTIL_WHERE_AM_I_FROM_ARGS(ARG_file, ARG_function, ARG_line)
Helper macro, same as FLOW_UTIL_WHERE_AM_I(), but takes the source location details as arguments inst...