1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#ifndef YAPSSG_LOGGER_H
#define YAPSSG_LOGGER_H
#if defined(__GNUC__) || defined(__clang__)
#define YAPSSG_FORMAT_PRINTF(format_index, arguments_index) \
__attribute__((format(printf, format_index, arguments_index)))
#else
#define YAPSSG_FORMAT_PRINTF(format_index, arguments_index)
#endif
typedef enum {
LOG_LEVEL_SILENT = -1,
LOG_LEVEL_ERROR,
LOG_LEVEL_WARNING,
LOG_LEVEL_INFO,
LOG_LEVEL_DEBUG
} LogLevel;
void logger_set_level(LogLevel level);
LogLevel logger_get_level(void);
int logger_is_enabled(LogLevel level);
int logger_parse_level(const char *name, LogLevel *level);
void logger_log(LogLevel level, const char *format, ...)
YAPSSG_FORMAT_PRINTF(2, 3);
void logger_error(const char *format, ...) YAPSSG_FORMAT_PRINTF(1, 2);
void logger_warning(const char *format, ...) YAPSSG_FORMAT_PRINTF(1, 2);
void logger_info(const char *format, ...) YAPSSG_FORMAT_PRINTF(1, 2);
void logger_debug(const char *format, ...) YAPSSG_FORMAT_PRINTF(1, 2);
#endif
|