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__);\
386 #define log_debug(...) do {\
387 if (LOG_LEVEL_DEBUG >= log_level) {\
389 logl_log(&loc, LOG_LEVEL_DEBUG, __VA_ARGS__);\
400 #define log_info(...) do {\
401 if (LOG_LEVEL_INFO >= log_level) {\
403 logl_log(&loc, LOG_LEVEL_INFO, __VA_ARGS__);\
414 #define log_notice(...) do {\
415 if (LOG_LEVEL_NOTICE >= log_level) {\
417 logl_log(&loc, LOG_LEVEL_NOTICE, __VA_ARGS__);\
428 #define log_warning(...) do {\
429 if (LOG_LEVEL_WARNING >= log_level) {\
431 logl_log(&loc, LOG_LEVEL_WARNING, __VA_ARGS__);\
442 #define log_error(...) do {\
443 if (LOG_LEVEL_ERROR >= log_level) {\
445 logl_log(&loc, LOG_LEVEL_ERROR, __VA_ARGS__);\
456 #define log_fatal(...) do {\
457 if (LOG_LEVEL_FATAL >= log_level) {\
459 logl_log(&loc, LOG_LEVEL_FATAL, __VA_ARGS__);\
471 #define log_errno(errnum, ...) do {\
473 logl_errno(&loc, errnum, __VA_ARGS__);\
483 #define log_syserr(...) log_errno(errno, __VA_ARGS__)
492 #define log_add(...) do { \
494 logl_add(&loc, __VA_ARGS__);\
504 #define log_vadd(fmt, args) do { \
506 logl_vadd(&loc, fmt, args); \
518 #define log_add_errno(n, ...) do {\
520 logl_add_errno(&loc, n, __VA_ARGS__); \
529 #define log_add_syserr(...) log_add_errno(errno, __VA_ARGS__)
546 #define log_error_q(...) LOG_LOG(LOG_LEVEL_ERROR, __VA_ARGS__)
554 #define log_warning_q(...) LOG_LOG(LOG_LEVEL_WARNING, __VA_ARGS__)
562 #define log_notice_q(...) LOG_LOG(LOG_LEVEL_NOTICE, __VA_ARGS__)
570 #define log_info_q(...) LOG_LOG(LOG_LEVEL_INFO, __VA_ARGS__)
578 #define log_debug_q(...) do {\
580 logl_log_q(&loc, LOG_LEVEL_DEBUG, __VA_ARGS__);\
590 #define log_log_q(level, ...) LOG_LOG(level, __VA_ARGS__)
612 #define log_flush_fatal() log_flush(LOG_LEVEL_FATAL)
617 #define log_flush_error() log_flush(LOG_LEVEL_ERROR)
622 #define log_flush_warning() log_flush(LOG_LEVEL_WARNING)
627 #define log_flush_notice() log_flush(LOG_LEVEL_NOTICE)
632 #define log_flush_info() log_flush(LOG_LEVEL_INFO)
637 #define log_flush_debug() log_flush(LOG_LEVEL_DEBUG)
649 #define log_malloc(nbytes, msg) logl_malloc(__FILE__, __func__, __LINE__, \
663 #define log_realloc(buf, nbytes, msg) logl_realloc(__FILE__, __func__, __LINE__, \
672 #define log_abort(...) do { \
673 log_add(__VA_ARGS__); \
674 log_flush(LOG_LEVEL_ERROR); \
679 #define log_assert(expr)
689 #define log_assert(expr) do { \
691 (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &prevState); \
693 log_abort("Assertion failure: %s", #expr); \
694 (void)pthread_setcancelstate(prevState, &prevState); \
int log_set_destination(const char *const dest)
int log_set_facility(const int facility)
log_level_t
Logging levels.
Definition: log.h:30
Error messages.
Definition: log.h:35
Number of levels.
Definition: log.h:37
int log_set_id(const char *const id)
Notices.
Definition: log.h:33
const char * log_get_destination(void)
bool log_stderr_is_open(void)
log_level_t log_get_level(void)
Debug messages.
Definition: log.h:31
void log_avoid_stderr(void)
int log_init(const char *const id)
int log_flush(const log_level_t level)
void log_roll_level(void)
unsigned log_get_options(void)
int log_get_facility(void)
Informational messages.
Definition: log.h:32
Fatal messages.
Definition: log.h:36
int log_set_level(const log_level_t level)
const char * log_get_id(void)
const char * log_get_default_daemon_destination(void)
const char * log_get_default_destination(void)
int log_set_upstream_id(const char *const hostId, const bool isFeeder)
int log_set_options(const unsigned options)
Warnings.
Definition: log.h:34