15 #include "../misc/ErrObj.h"
27 #define LOG_LOCALTIME 0x100u
28 #define LOG_NOTIME 0x200u
29 #define LOG_IDENT 0x400u
46 #include "log_private.h"
138 #define log_fini() do {\
140 (void)log_fini_located(&loc);\
191 const char*
const id);
205 const char*
const hostId,
206 const bool isFeeder);
235 const unsigned options);
294 const char*
const dest);
330 #define log_free() do {\
332 (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prevState); \
334 log_free_located(&loc);\
335 (void)pthread_setcancelstate(prevState, &prevState); \
346 bool log_is_level_enabled(
353 #define log_is_enabled_warning log_is_level_enabled(LOG_LEVEL_WARNING)
358 #define log_is_enabled_notice log_is_level_enabled(LOG_LEVEL_NOTICE)
363 #define log_is_enabled_info log_is_level_enabled(LOG_LEVEL_INFO)
368 #define log_is_enabled_debug log_is_level_enabled(LOG_LEVEL_DEBUG)
378 #define log_log(level, ...) do {\
379 if ((level) >= log_level) {\
381 logl_log(&loc, (level), __VA_ARGS__);\
391 #define log_debug(...) do {\
392 if (LOG_LEVEL_DEBUG >= log_level) {\
394 logl_log(&loc, LOG_LEVEL_DEBUG, __VA_ARGS__);\
405 #define log_info(...) do {\
406 if (LOG_LEVEL_INFO >= log_level) {\
408 logl_log(&loc, LOG_LEVEL_INFO, __VA_ARGS__);\
419 #define log_notice(...) do {\
420 if (LOG_LEVEL_NOTICE >= log_level) {\
422 logl_log(&loc, LOG_LEVEL_NOTICE, __VA_ARGS__);\
433 #define log_warning(...) do {\
434 if (LOG_LEVEL_WARNING >= log_level) {\
436 logl_log(&loc, LOG_LEVEL_WARNING, __VA_ARGS__);\
447 #define log_error(...) do {\
448 if (LOG_LEVEL_ERROR >= log_level) {\
450 logl_log(&loc, LOG_LEVEL_ERROR, __VA_ARGS__);\
461 #define log_fatal(...) do {\
462 if (LOG_LEVEL_FATAL >= log_level) {\
464 logl_log(&loc, LOG_LEVEL_FATAL, __VA_ARGS__);\
476 #define log_errno(errnum, ...) do {\
478 logl_errno(&loc, errnum, __VA_ARGS__);\
488 #define log_syserr(...) log_errno(errno, __VA_ARGS__)
497 #define log_add(...) do { \
499 logl_add(&loc, __VA_ARGS__);\
509 #define log_vadd(fmt, args) do { \
511 logl_vadd(&loc, fmt, args); \
523 #define log_add_errno(n, ...) do {\
525 logl_add_errno(&loc, n, __VA_ARGS__); \
534 #define log_add_syserr(...) log_add_errno(errno, __VA_ARGS__)
551 #define log_error_q(...) LOG_LOG(LOG_LEVEL_ERROR, __VA_ARGS__)
559 #define log_warning_q(...) LOG_LOG(LOG_LEVEL_WARNING, __VA_ARGS__)
567 #define log_notice_q(...) LOG_LOG(LOG_LEVEL_NOTICE, __VA_ARGS__)
575 #define log_info_q(...) LOG_LOG(LOG_LEVEL_INFO, __VA_ARGS__)
583 #define log_debug_q(...) do {\
585 logl_log_q(&loc, LOG_LEVEL_DEBUG, __VA_ARGS__);\
595 #define log_log_q(level, ...) LOG_LOG(level, __VA_ARGS__)
617 #define log_flush_fatal() log_flush(LOG_LEVEL_FATAL)
622 #define log_flush_error() log_flush(LOG_LEVEL_ERROR)
627 #define log_flush_warning() log_flush(LOG_LEVEL_WARNING)
632 #define log_flush_notice() log_flush(LOG_LEVEL_NOTICE)
637 #define log_flush_info() log_flush(LOG_LEVEL_INFO)
642 #define log_flush_debug() log_flush(LOG_LEVEL_DEBUG)
654 #define log_malloc(nbytes, msg) logl_malloc(__FILE__, __func__, __LINE__, \
668 #define log_realloc(buf, nbytes, msg) logl_realloc(__FILE__, __func__, __LINE__, \
677 #define log_abort(...) do { \
678 log_add(__VA_ARGS__); \
679 log_flush(LOG_LEVEL_ERROR); \
684 #define log_assert(expr)
694 #define log_assert(expr) do { \
696 (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prevState); \
698 log_abort("Assertion failure: %s", #expr); \
699 (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:32
@ LOG_LEVEL_NOTICE
Notices.
Definition: log.h:35
@ LOG_LEVEL_DEBUG
Debug messages.
Definition: log.h:33
@ LOG_LEVEL_ERROR
Error messages.
Definition: log.h:37
@ LOG_LEVEL_WARNING
Warnings.
Definition: log.h:36
@ LOG_LEVEL_FATAL
Fatal messages.
Definition: log.h:38
@ LOG_LEVEL_COUNT
Number of levels.
Definition: log.h:39
@ LOG_LEVEL_INFO
Informational messages.
Definition: log.h:34
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)