![]() |
Fledge
An open source edge computing platform for industrial users
|
Fledge Logger class used to log to syslog. More...
#include <logger.h>
Public Types | |
enum | LogLevel { ERROR, WARNING, INFO, DEBUG, FATAL } |
typedef void(* | LogInterceptor) (LogLevel, const std::string &, void *) |
Public Member Functions | |
Logger (const std::string &application) | |
Constructor for the Logger class. More... | |
~Logger () | |
Destructor for the logger class. | |
void | debug (const std::string &msg,...) |
Log a message at the level debug. More... | |
void | printLongString (const std::string &, LogLevel=LogLevel::DEBUG) |
Log a long string across multiple syslog entries. More... | |
void | info (const std::string &msg,...) |
Log a message at the level info. More... | |
void | warn (const std::string &msg,...) |
Log a message at the level warn. More... | |
void | error (const std::string &msg,...) |
Log a message at the level error. More... | |
void | fatal (const std::string &msg,...) |
Log a message at the level fatal. More... | |
void | setMinLevel (const std::string &level) |
Set the minimum level of logging to write to syslog. More... | |
std::string & | getMinLevel () |
bool | registerInterceptor (LogLevel level, LogInterceptor callback, void *userData) |
Register a callback function to be called when a log message is written that matches the specification given. More... | |
bool | unregisterInterceptor (LogLevel level, LogInterceptor callback) |
Remove the registration of a previously registered callback. More... | |
Static Public Member Functions | |
static Logger * | getLogger () |
Return the singleton instance of the logger class. | |
Fledge Logger class used to log to syslog.
At startup this class should be constructed using the standard constructor. To log a message call debug, info, warn etc. using the instance of the class.
To obtain that singleton instance call the static method getLogger.
It is generally unsafe to delete the logger class as it may be called asynchronouly from multiple threads and single handlers. The destructor has hence been made private to prevent the destruction of the class.
Logger::Logger | ( | const std::string & | application | ) |
Constructor for the Logger class.
application | The application name |
void Logger::debug | ( | const std::string & | msg, |
... | |||
) |
Log a message at the level debug.
msg | A printf format string |
... | The variable arguments required by the printf format |
void Logger::error | ( | const std::string & | msg, |
... | |||
) |
Log a message at the level error.
msg | A printf format string |
... | The variable arguments required by the printf format |
void Logger::fatal | ( | const std::string & | msg, |
... | |||
) |
Log a message at the level fatal.
msg | A printf format string |
... | The variable arguments required by the printf format |
void Logger::info | ( | const std::string & | msg, |
... | |||
) |
Log a message at the level info.
msg | A printf format string |
... | The variable arguments required by the printf format |
void Logger::printLongString | ( | const std::string & | , |
LogLevel | = LogLevel::DEBUG |
||
) |
Log a long string across multiple syslog entries.
s | The string to log |
level | level to log the string at |
bool Logger::registerInterceptor | ( | LogLevel | level, |
LogInterceptor | callback, | ||
void * | userData | ||
) |
Register a callback function to be called when a log message is written that matches the specification given.
Note: The callback functions are called on a separate thread. This worker thread is only created when the first callback is registered.
level | The level that must be matched |
callback | The funtion to be called |
userData | User date to pass to the callback function |
void Logger::setMinLevel | ( | const std::string & | level | ) |
Set the minimum level of logging to write to syslog.
level | The minimum, inclusive, level of logging to write |
bool Logger::unregisterInterceptor | ( | LogLevel | level, |
LogInterceptor | callback | ||
) |
Remove the registration of a previously registered callback.
level | The matching log level for the callback |
callback | The callback to unregister |
void Logger::warn | ( | const std::string & | msg, |
... | |||
) |
Log a message at the level warn.
msg | A printf format string |
... | The variable arguments required by the printf format |