14 #include <haka/compiler.h> 15 #include <haka/container/list.h> 33 #define HAKA_LOG_LEVEL_MAX 6 57 #define INVALID_SECTION_ID -1 64 #define DECLARE_LOG_SECTION(name) \ 65 int _##name##_section; 67 #define REGISTER_LOG_SECTION(name) \ 68 int _##name##_section = LOG_SECTION(external); \ 69 INIT static void _init_log_section_##name() { _##name##_section = register_log_section(#name); } 71 #define LOG_SECTION(name) _##name##_section 82 LOG_SECTION(external),
97 void _messagef(
log_level level,
section_id section,
const char *fmt, ...) FORMAT_PRINTF(3, 4);
99 #define SHOULD_LOG(level, section) \ 100 (check_section_log_level(LOG_SECTION(section), level)) 102 #define LOG(level, section, fmt, ...) \ 103 do { if (check_section_log_level(LOG_SECTION(section), level)) { \ 104 _messagef(level, LOG_SECTION(section), fmt, ##__VA_ARGS__); \ 110 #define LOG_FATAL(section, fmt, ...) LOG(HAKA_LOG_FATAL, section, fmt, ##__VA_ARGS__) 111 #define LOG_ERROR(section, fmt, ...) LOG(HAKA_LOG_ERROR, section, fmt, ##__VA_ARGS__) 112 #define LOG_WARNING(section, fmt, ...) LOG(HAKA_LOG_WARNING, section, fmt, ##__VA_ARGS__) 113 #define LOG_INFO(section, fmt, ...) LOG(HAKA_LOG_INFO, section, fmt, ##__VA_ARGS__) 114 #define LOG_DEBUG(section, fmt, ...) LOG(HAKA_LOG_DEBUG, section, fmt, ##__VA_ARGS__) 116 #define SHOULD_LOG_FATAL(section) SHOULD_LOG(HAKA_LOG_FATAL, section) 117 #define SHOULD_LOG_ERROR(section) SHOULD_LOG(HAKA_LOG_ERROR, section) 118 #define SHOULD_LOG_WARNING(section) SHOULD_LOG(HAKA_LOG_WARNING, section) 119 #define SHOULD_LOG_INFO(section) SHOULD_LOG(HAKA_LOG_INFO, section) 120 #define SHOULD_LOG_DEBUG(section) SHOULD_LOG(HAKA_LOG_DEBUG, section) 123 #define LOG_TRACE(section, fmt, ...) LOG(HAKA_LOG_TRACE, section, fmt, ##__VA_ARGS__) 124 #define SHOULD_LOG_TRACE(section) SHOULD_LOG(HAKA_LOG_TRACE, section) 126 #define LOG_TRACE(section, fmt, ...) 127 #define SHOULD_LOG_TRACE(section) 0 156 void (*destroy)(
struct logger *state);
158 bool mark_for_remove;
void remove_all_logger()
Definition: log.c:188
log_level str_to_level(const char *str)
Definition: log.c:224
bool setlevel(log_level level, const char *name)
Definition: log.c:416
log_level getlevel(const char *name)
Definition: log.c:468
bool remove_logger(struct logger *logger)
Definition: log.c:156
int section_id
Definition: log.h:52
bool stdout_message(log_level lvl, const char *module, const char *message)
Definition: log.c:243
bool check_section_log_level(section_id section, log_level level)
Definition: log.c:403
void enable_stdout_logging(bool enable)
Definition: log.c:238
bool add_logger(struct logger *logger)
Definition: log.c:136
log_level
Definition: log.h:21
const char * level_to_str(log_level level)
Definition: log.c:218
section_id search_log_section(const char *name)
Definition: log.c:313
section_id register_log_section(const char *name)
Definition: log.c:296