ealogger
ealogger is a c++ library that provides a blazing fast and easy to use logging mechanism
Public Member Functions | List of all members
ealogger::SinkFile Class Reference

Sink to write to a log file. More...

#include <sink_file.h>

Inheritance diagram for ealogger::SinkFile:
ealogger::Sink

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< ConversionPatternvec_conv_patterns
 
std::map< ealogger::constants::LOG_LEVEL, std::string > loglevel_lookup
 

Detailed Description

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.

Constructor & Destructor Documentation

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.

Parameters
msg_templateString with conversion specifiers
datetime_patternConversion specifiers for date time
enabledWhether or not this sink is enabled
min_lvlMinimum severity
log_fileLog file
flush_bufferFlush 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.

Member Function Documentation

void ealogger::SinkFile::set_log_file ( std::string  log_file)

Set log file.

Parameters
log_file
Warning
This is method is not exposed by the API currently. You may have the possibility to work with Sink objects directly in the future. If you need to change the logfile use Logger::init_file_sink to reinit the SinkFile sink with a different logfile

The documentation for this class was generated from the following files: