mpacklog — Log dictionaries to file using MessagePack
v2.1.0
|
Multi-threaded logger. More...
#include <Logger.h>
Public Member Functions | |
Logger (const std::string &path, bool append=false) | |
Open a new log file and start the logging thread. More... | |
~Logger () | |
Stop the logging thread. More... | |
bool | put (char *data, size_t size) |
Save data to be written to the log. More... | |
bool | put (const Dictionary &dict) |
Save a dictionary to be written to the log. More... | |
size_t | last_size () const |
Size of the last message in bytes. More... | |
Multi-threaded logger.
This logger stores input data to an internal circular memory buffer and flushes it to an output file in a separate thread.
Quick performance check for the writing rate:
|
explicit |
Open a new log file and start the logging thread.
[in] | path | Path to the output log file. |
[in] | append | If true, append to the log file if it exists. |
Definition at line 30 of file Logger.cpp.
mpacklog::Logger::~Logger | ( | ) |
Stop the logging thread.
Definition at line 56 of file Logger.cpp.
|
inline |
bool mpacklog::Logger::put | ( | char * | data, |
size_t | size | ||
) |
Save data to be written to the log.
This function only copies the data to the circular buffer. It is then written later to file by the logging thread.
data | Raw data to log. |
size | Size of data array. |
Definition at line 64 of file Logger.cpp.
|
inline |
Save a dictionary to be written to the log.
dict | Dictionary to log. |