28 Config* config,
const fs::path& log_path) :
38 m_ofs_writer(*m_config, m_ofs),
41 FLOW_LOG_INFO(
"detail/Serial_file_logger [" <<
this <<
"] @ [" <<
m_log_path <<
"]: These log messages are going to "
42 "associated backup logger [" << backup_logger_ptr <<
"]. The messages actually logged through "
43 "Logger API requests to `*this` will go to aforementioned log path, not to the present output.");
53 "output if possible; then we will proceed to shut down.");
57 FLOW_LOG_INFO(
"detail/Serial_file_logger [" <<
this <<
"] @ [" <<
m_log_path <<
"]: Flushing before destruction "
58 "finishes in other thread.");
86 "file stream is in bad state, spuriously or due to a previous op; will attempt reopen first.");
91 "Stream still in bad state; giving up on that log message. "
92 "Will retry file stream for next message.");
105 (
"detail/Serial_file_logger [" <<
this <<
"] @ [" <<
m_log_path <<
"]: do_log() just tried to log "
106 "msg when file stream was in good state, but now file stream is in bad state, probably because the "
107 "write failed. Giving up on that log message. Will retry file stream for next message.");
135 "by internal code while already being asked to reopen file. Doing nothing.");
146 FLOW_LOG_INFO(
"detail/Serial_file_logger [" <<
this <<
"] @ [" <<
m_log_path <<
"]: Closing before re-opening.");
158 "Closing before re-opening.");
166 "Opening for append. Will log on error.");
176 "Opened successfully for further logging.");
190 return m_config->output_whether_should_log(sev, component);
A light-weight class, each object storing a component payload encoding an enum value from enum type o...
Class used to configure the filtering and logging behavior of Loggers; its use in your custom Loggers...
Convenience class that simply stores a Logger and/or Component passed into a constructor; and returns...
Interface that the user should implement, passing the implementing Logger into logging classes (Flow'...
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...
bool m_reopening
Starts at false, becomes true at entry to log_flush_and_reopen(), then becomes false again.
void do_log(Msg_metadata *metadata, util::String_view msg) override
Implements interface method by synchronously logging the message and some subset of the metadata in a...
bool logs_asynchronously() const override
Implements interface method by returning false, indicating that this Logger will not need the content...
~Serial_file_logger() override
Flushes out anything buffered, returns resources/closes output file(s); then returns.
void log_flush_and_reopen()
Causes the log at the file-system path to be flushed/closed (if needed) and re-opened; this will occu...
Ostream_log_msg_writer m_ofs_writer
Stream writer via which to log messages to m_ofs.
Serial_file_logger(Logger *backup_logger_ptr, Config *config, const fs::path &log_path)
Constructs logger to subsequently log to the given file-system path.
const fs::path m_log_path
File-system path to which to write subsequently.
fs::ofstream m_ofs
The file to which to write. Because only the worker thread ever accesses it, no mutex is needed.
bool should_log(Sev sev, const Component &component) const override
See Async_file_logger::should_log().
#define FLOW_LOG_INFO(ARG_stream_fragment)
Logs an INFO message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
#define FLOW_LOG_WARNING(ARG_stream_fragment)
Logs a WARNING message into flow::log::Logger *get_logger() with flow::log::Component get_log_compone...
#define FLOW_LOG_SET_LOGGER(ARG_logger_ptr)
Equivalent to FLOW_LOG_SET_CONTEXT() but sets the get_logger only.
#define FLOW_LOG_TRACE(ARG_stream_fragment)
Logs a TRACE message into flow::log::Logger *get_logger() with flow::log::Component get_log_component...
Flow module providing logging functionality.
Sev
Enumeration containing one of several message severity levels, ordered from highest to lowest.
Basic_string_view< char > String_view
Commonly used char-based Basic_string_view. See its doc header.
Flow_log_component
The flow::log::Component payload enumeration comprising various log components used by Flow's own int...