ealogger
ealogger is a c++ library that provides a blazing fast and easy to use logging mechanism
|
Sink to write to a log file. More...
#include <sink_file.h>
Public Member Functions | |
SinkFile (std::string msg_template, std::string datetime_pattern, bool enabled, ealogger::constants::LOG_LEVEL min_lvl, std::string log_file, bool flush_buffer) | |
SinkFile constructor with additional parameters. More... | |
void | set_log_file (std::string log_file) |
Set log file. More... | |
Public Member Functions inherited from ealogger::Sink | |
Sink (std::string msg_template, std::string datetime_pattern, bool enabled, ealogger::constants::LOG_LEVEL min_lvl) | |
Sink constructor. More... | |
void | set_msg_template (std::string msg_template) |
Set the message template with conversion patterns. More... | |
void | set_datetime_pattern (std::string datetime_pattern) |
Set the date time conversion pattern. More... | |
void | set_enabled (bool enabled) |
Enable or disable the sink. More... | |
bool | get_enabled () |
Check if this sink is enabled. More... | |
void | set_min_lvl (ealogger::constants::LOG_LEVEL min_lvl) |
Set minimum severity for this sink. More... | |
void | prepare_log_message (const std::shared_ptr< LogMessage > &log_message) |
Prepare a log message before it is written to the targets. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ealogger::Sink | |
void | fill_conv_patterns (bool lock) |
Fill Sink::vec_conv_patterns with ConverionPattern depending on Sink::msg_template. | |
Protected Attributes inherited from ealogger::Sink | |
std::string | msg_template |
std::string | datetime_pattern |
bool | enabled |
ealogger::constants::LOG_LEVEL | min_level |
std::mutex | mtx_msg_template |
std::mutex | mtx_datetime_pattern |
std::mutex | mtx_enabled |
std::mutex | mtx_min_lvl |
std::mutex | mtx_conv_pattern |
std::vector< ConversionPattern > | vec_conv_patterns |
std::map< ealogger::constants::LOG_LEVEL, std::string > | loglevel_lookup |
Sink to write to a log file.
This sink allows you to write to a log file. It does not support rotating files based on elapsed time or file size. You also have to make sure the application hass appropriate write permissions and the target directory exists.
ealogger::SinkFile::SinkFile | ( | std::string | msg_template, |
std::string | datetime_pattern, | ||
bool | enabled, | ||
ealogger::constants::LOG_LEVEL | min_lvl, | ||
std::string | log_file, | ||
bool | flush_buffer | ||
) |
SinkFile constructor with additional parameters.
msg_template | String with conversion specifiers |
datetime_pattern | Conversion specifiers for date time |
enabled | Whether or not this sink is enabled |
min_lvl | Minimum severity |
log_file | Log file |
flush_buffer | Flush the ofstream buffer with every message |
Make sure you have write permissions for log_file
and the corresponding directories exist.
The parameter flush_buffer
can be used to influence the flushing of internal buffers. Normally ealogger leaves this to the system. This means not every message might be written immediately to the file. If you want a different behaviour set flush_buffer to true at the cost of decreasing performance.
void ealogger::SinkFile::set_log_file | ( | std::string | log_file | ) |
Set log file.
log_file |