25 #define LOG_LOCALTIME 0x100u
26 #define LOG_NOTIME 0x200u
27 #define LOG_IDENT 0x400u
44 #include "log_private.h"
136 #define log_fini() do {\
138 (void)log_fini_located(&loc);\
189 const char*
const id);
203 const char*
const hostId,
204 const bool isFeeder);
233 const unsigned options);
292 const char*
const dest);
324 #define log_free() do {\
326 (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prevState); \
328 log_free_located(&loc);\
329 (void)pthread_setcancelstate(prevState, &prevState); \
340 bool log_is_level_enabled(
347 #define log_is_enabled_warning log_is_level_enabled(LOG_LEVEL_WARNING)
352 #define log_is_enabled_notice log_is_level_enabled(LOG_LEVEL_NOTICE)
357 #define log_is_enabled_info log_is_level_enabled(LOG_LEVEL_INFO)
362 #define log_is_enabled_debug log_is_level_enabled(LOG_LEVEL_DEBUG)
372 #define log_log(level, ...) do {\
373 if ((level) >= log_level) {\
375 logl_log(&loc, (level), __VA_ARGS__);\
385 #define log_debug(...) do {\
386 if (LOG_LEVEL_DEBUG >= log_level) {\
388 logl_log(&loc, LOG_LEVEL_DEBUG, __VA_ARGS__);\
399 #define log_info(...) do {\
400 if (LOG_LEVEL_INFO >= log_level) {\
402 logl_log(&loc, LOG_LEVEL_INFO, __VA_ARGS__);\
413 #define log_notice(...) do {\
414 if (LOG_LEVEL_NOTICE >= log_level) {\
416 logl_log(&loc, LOG_LEVEL_NOTICE, __VA_ARGS__);\
427 #define log_warning(...) do {\
428 if (LOG_LEVEL_WARNING >= log_level) {\
430 logl_log(&loc, LOG_LEVEL_WARNING, __VA_ARGS__);\
441 #define log_error(...) do {\
442 if (LOG_LEVEL_ERROR >= log_level) {\
444 logl_log(&loc, LOG_LEVEL_ERROR, __VA_ARGS__);\
455 #define log_fatal(...) do {\
456 if (LOG_LEVEL_FATAL >= log_level) {\
458 logl_log(&loc, LOG_LEVEL_FATAL, __VA_ARGS__);\
470 #define log_errno(errnum, ...) do {\
472 logl_errno(&loc, errnum, __VA_ARGS__);\
482 #define log_syserr(...) log_errno(errno, __VA_ARGS__)
491 #define log_add(...) do { \
493 logl_add(&loc, __VA_ARGS__);\
503 #define log_vadd(fmt, args) do { \
505 logl_vadd(&loc, fmt, args); \
517 #define log_add_errno(n, ...) do {\
519 logl_add_errno(&loc, n, __VA_ARGS__); \
528 #define log_add_syserr(...) log_add_errno(errno, __VA_ARGS__)
545 #define log_error_q(...) LOG_LOG(LOG_LEVEL_ERROR, __VA_ARGS__)
553 #define log_warning_q(...) LOG_LOG(LOG_LEVEL_WARNING, __VA_ARGS__)
561 #define log_notice_q(...) LOG_LOG(LOG_LEVEL_NOTICE, __VA_ARGS__)
569 #define log_info_q(...) LOG_LOG(LOG_LEVEL_INFO, __VA_ARGS__)
577 #define log_debug_q(...) do {\
579 logl_log_q(&loc, LOG_LEVEL_DEBUG, __VA_ARGS__);\
589 #define log_log_q(level, ...) LOG_LOG(level, __VA_ARGS__)
611 #define log_flush_fatal() log_flush(LOG_LEVEL_FATAL)
616 #define log_flush_error() log_flush(LOG_LEVEL_ERROR)
621 #define log_flush_warning() log_flush(LOG_LEVEL_WARNING)
626 #define log_flush_notice() log_flush(LOG_LEVEL_NOTICE)
631 #define log_flush_info() log_flush(LOG_LEVEL_INFO)
636 #define log_flush_debug() log_flush(LOG_LEVEL_DEBUG)
648 #define log_malloc(nbytes, msg) logl_malloc(__FILE__, __func__, __LINE__, \
662 #define log_realloc(buf, nbytes, msg) logl_realloc(__FILE__, __func__, __LINE__, \
671 #define log_abort(...) do { \
672 log_add(__VA_ARGS__); \
673 log_flush(LOG_LEVEL_ERROR); \
678 #define log_assert(expr)
688 #define log_assert(expr) do { \
690 (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prevState); \
692 log_abort("Assertion failure: %s", #expr); \
693 (void)pthread_setcancelstate(prevState, &prevState); \
int log_set_id(const char *const id)
bool log_stderr_is_open(void)
int log_set_level(const log_level_t level)
int log_set_destination(const char *const dest)
log_level_t log_get_level(void)
void log_roll_level(void)
const char * log_get_default_destination(void)
int log_flush(const log_level_t level)
int log_get_facility(void)
const char * log_get_id(void)
int log_init(const char *const id)
unsigned log_get_options(void)
int log_set_upstream_id(const char *const hostId, const bool isFeeder)
log_level_t
Logging levels.
Definition: log.h:30
@ LOG_LEVEL_NOTICE
Notices.
Definition: log.h:33
@ LOG_LEVEL_DEBUG
Debug messages.
Definition: log.h:31
@ LOG_LEVEL_ERROR
Error messages.
Definition: log.h:35
@ LOG_LEVEL_WARNING
Warnings.
Definition: log.h:34
@ LOG_LEVEL_FATAL
Fatal messages.
Definition: log.h:36
@ LOG_LEVEL_COUNT
Number of levels.
Definition: log.h:37
@ LOG_LEVEL_INFO
Informational messages.
Definition: log.h:32
int log_set_options(const unsigned options)
const char * log_get_default_daemon_destination(void)
int log_set_facility(const int facility)
const char * log_get_destination(void)
void log_avoid_stderr(void)