39 #include <ealogger/logmessage.h> 40 #include <ealogger/logqueue.h> 66 #define eal_debug(msg) \ 67 write_log(msg, ealogger::constants::LOG_LEVEL::EAL_DEBUG, __FILE__, \ 73 #define eal_info(msg) \ 74 write_log(msg, ealogger::constants::LOG_LEVEL::EAL_INFO, __FILE__, \ 80 #define eal_warn(msg) \ 81 write_log(msg, ealogger::constants::LOG_LEVEL::EAL_WARNING, __FILE__, \ 87 #define eal_error(msg) \ 88 write_log(msg, ealogger::constants::LOG_LEVEL::EAL_ERROR, __FILE__, \ 94 #define eal_fatal(msg) \ 95 write_log(msg, ealogger::constants::LOG_LEVEL::EAL_FATAL, __FILE__, \ 101 #define eal_stack() \ 102 write_log("", ealogger::constants::LOG_LEVEL::EAL_STACK, __FILE__, \ 159 Logger(
bool async =
true);
183 std::string file,
int lnumber, std::string func);
222 std::string msg_template =
"%s: %m",
223 std::string datetime_pattern =
"%F %T");
242 std::string msg_template =
"%d %s: %m",
243 std::string datetime_pattern =
"%F %T");
271 std::string msg_template =
"%d %s [%f:%l] %m",
272 std::string datetime_pattern =
"%F %T",
273 std::string logfile =
"ealogger_logfile.log",
274 bool flush_buffer =
false);
313 std::string msg_template);
325 std::string datetime_pattern);
351 std::mutex mtx_logger_stop;
353 static bool signal_SIGUSR1;
360 std::thread logger_thread;
362 bool logger_thread_stop;
364 std::map<ealogger::constants::LOGGER_SINK, std::shared_ptr<Sink>>
366 std::map<ealogger::constants::LOGGER_SINK, std::unique_ptr<std::mutex>>
370 static void logrotate(
int signo);
372 void thread_entry_point();
379 void internal_log_routine(std::shared_ptr<LogMessage> m);
385 bool get_logger_thread_stop();
386 void set_logger_thread_stop(
bool stop);
void set_msg_template(ealogger::constants::LOGGER_SINK sink, std::string msg_template)
Set message template for a Sink.
Definition: ealogger.cpp:155
void init_file_sink(bool enabled=true, ealogger::constants::LOG_LEVEL min_lvl=ealogger::constants::LOG_LEVEL::EAL_DEBUG, std::string msg_template="%d %s [%f:%l] %m", std::string datetime_pattern="%F %T", std::string logfile="ealogger_logfile.log", bool flush_buffer=false)
Initialize the simple file Sink.
Definition: ealogger.cpp:131
Logger(bool async=true)
Logger constructor.
Definition: ealogger.cpp:25
void set_enabled(ealogger::constants::LOGGER_SINK sink, bool enabled)
Activate or deactivate a Sink.
Definition: ealogger.cpp:177
ealogger main class
Definition: ealogger.h:145
void set_datetime_pattern(ealogger::constants::LOGGER_SINK sink, std::string datetime_pattern)
Set datetime conversion pattern for a Sink.
Definition: ealogger.cpp:166
Global ealogger constants.
Main namespace for ealogger.
Definition: conversion_pattern.h:28
void discard_sink(ealogger::constants::LOGGER_SINK sink)
Discard a Sink and delete the object.
Definition: ealogger.cpp:196
The LogQueue class represents a threadsafe queue ealogger uses to store log messages.
Definition: logqueue.h:49
LOGGER_SINK
Supported logger Sinks.
Definition: global.h:44
void init_syslog_sink(bool enabled=true, ealogger::constants::LOG_LEVEL min_lvl=ealogger::constants::LOG_LEVEL::EAL_DEBUG, std::string msg_template="%s: %m", std::string datetime_pattern="%F %T")
Init a syslog Sink.
Definition: ealogger.cpp:103
void write_log(std::string msg, ealogger::constants::LOG_LEVEL lvl, std::string file, int lnumber, std::string func)
Write a log message.
Definition: ealogger.cpp:73
void set_min_lvl(ealogger::constants::LOGGER_SINK sink, ealogger::constants::LOG_LEVEL min_level)
Set the minimum log message severity for a Sink.
Definition: ealogger.cpp:186
void init_console_sink(bool enabled=true, ealogger::constants::LOG_LEVEL min_lvl=ealogger::constants::LOG_LEVEL::EAL_DEBUG, std::string msg_template="%d %s: %m", std::string datetime_pattern="%F %T")
Initialize the console Sink.
Definition: ealogger.cpp:117
bool is_initialized(ealogger::constants::LOGGER_SINK sink)
Check if a Sink has been initialized already.
Definition: ealogger.cpp:209
bool queue_empty()
Check if the message queue is empty.
Definition: ealogger.cpp:222
LOG_LEVEL
An enumaration representing the supported loglevels.
Definition: global.h:58