30 #include <platform/defaults.h>
31 #include <platform/stdio.h>
40 #define KAA_LOG_LEVEL_NONE 0
42 #define KAA_LOG_LEVEL_FATAL 1
44 #define KAA_LOG_LEVEL_ERROR 2
46 #define KAA_LOG_LEVEL_WARN 3
48 #define KAA_LOG_LEVEL_INFO 4
50 #define KAA_LOG_LEVEL_DEBUG 5
52 #define KAA_LOG_LEVEL_TRACE 6
54 #ifndef KAA_MAX_LOG_LEVEL
56 #define KAA_MAX_LOG_LEVEL KAA_LOG_LEVEL_TRACE
59 #define KAA_LOG_LEVEL_FATAL_ENABLED (KAA_MAX_LOG_LEVEL >= KAA_LOG_LEVEL_FATAL)
60 #define KAA_LOG_LEVEL_ERROR_ENABLED (KAA_MAX_LOG_LEVEL >= KAA_LOG_LEVEL_ERROR)
61 #define KAA_LOG_LEVEL_WARN_ENABLED (KAA_MAX_LOG_LEVEL >= KAA_LOG_LEVEL_WARN)
62 #define KAA_LOG_LEVEL_INFO_ENABLED (KAA_MAX_LOG_LEVEL >= KAA_LOG_LEVEL_INFO)
63 #define KAA_LOG_LEVEL_DEBUG_ENABLED (KAA_MAX_LOG_LEVEL >= KAA_LOG_LEVEL_DEBUG)
64 #define KAA_LOG_LEVEL_TRACE_ENABLED (KAA_MAX_LOG_LEVEL >= KAA_LOG_LEVEL_TRACE)
143 ,
kaa_error_t error_code,
const char* format, ...);
148 #if KAA_LOG_LEVEL_FATAL_ENABLED
149 #define KAA_LOG_FATAL(logger, err, ...) kaa_log_write(logger, __FILE__, __LINE__, KAA_LOG_LEVEL_FATAL, err, __VA_ARGS__)
151 #define KAA_LOG_FATAL(logger, err, ...) do { (void)(logger); (void)(err); } while (0)
154 #if KAA_LOG_LEVEL_ERROR_ENABLED
155 #define KAA_LOG_ERROR(logger, err, ...) kaa_log_write(logger, __FILE__, __LINE__, KAA_LOG_LEVEL_ERROR, err, __VA_ARGS__)
157 #define KAA_LOG_ERROR(logger, err, ...) do { (void)(logger); (void)(err); } while (0)
160 #if KAA_LOG_LEVEL_WARN_ENABLED
161 #define KAA_LOG_WARN(logger, err, ...) kaa_log_write(logger, __FILE__, __LINE__, KAA_LOG_LEVEL_WARN, err, __VA_ARGS__)
163 #define KAA_LOG_WARN(logger, err, ...) do { (void)(logger); (void)(err); } while (0)
166 #if KAA_LOG_LEVEL_INFO_ENABLED
167 #define KAA_LOG_INFO(logger, err, ...) kaa_log_write(logger, __FILE__, __LINE__, KAA_LOG_LEVEL_INFO, err, __VA_ARGS__)
169 #define KAA_LOG_INFO(logger, err, ...) do { (void)(logger); (void)(err); } while (0)
172 #if KAA_LOG_LEVEL_DEBUG_ENABLED
173 #define KAA_LOG_DEBUG(logger, err, ...) kaa_log_write(logger, __FILE__, __LINE__, KAA_LOG_LEVEL_DEBUG, err, __VA_ARGS__)
175 #define KAA_LOG_DEBUG(logger, err, ...) do { (void)(logger); (void)(err); } while (0)
178 #if KAA_LOG_LEVEL_TRACE_ENABLED
179 #define KAA_LOG_TRACE(logger, err, ...) kaa_log_write(logger, __FILE__, __LINE__, KAA_LOG_LEVEL_TRACE, err, __VA_ARGS__)
181 #define KAA_LOG_TRACE(logger, err, ...) do { (void)(logger); (void)(err); } while (0)
185 #define KAA_LOG_TRACE_LDB(logger, err, ...) KAA_LOG_TRACE(logger, err, ...)
187 #define KAA_LOG_TRACE_LDB(logger, err, ...) do { (void)(logger); (void)(err); } while (0)
kaa_error_t kaa_log_destroy(kaa_logger_t *logger)
Deinitializes and destroys the logger instance.
kaa_error_t kaa_log_set_sink(kaa_logger_t *self, FILE *sink)
Sets user sink for log output.
uint8_t kaa_log_level_t
Log level type.
Definition: kaa_log.h:73
kaa_error_t
Definition: kaa_error.h:31
kaa_error_t kaa_set_max_log_level(kaa_logger_t *self, kaa_log_level_t max_log_level)
Sets the maximum log level.
void kaa_log_write(kaa_logger_t *self, const char *source_file, int lineno, kaa_log_level_t log_level, kaa_error_t error_code, const char *format,...)
Compiles a log message and puts it into the sink.
struct kaa_logger_t kaa_logger_t
Definition: kaa_log.h:68
kaa_error_t kaa_log_create(kaa_logger_t **logger, size_t buffer_size, kaa_log_level_t max_log_level, FILE *sink)
Creates and initializes a logger instance.
kaa_log_level_t kaa_get_max_log_level(const kaa_logger_t *self)
Retrieves the current log level.