57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
#ifndef INCLUDE_DI_LOG_H_
|
|
#define INCLUDE_DI_LOG_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdarg.h>
|
|
|
|
enum di_log_level {
|
|
DI_LOG_LEVEL_QUIET = 0x00,
|
|
DI_LOG_LEVEL_CRIT = 0x01,
|
|
DI_LOG_LEVEL_ERROR = 0x02,
|
|
DI_LOG_LEVEL_WARN = 0x03,
|
|
DI_LOG_LEVEL_INFO = 0x04,
|
|
DI_LOG_LEVEL_DEBUG = 0x05
|
|
};
|
|
|
|
#include <di/log/file.h>
|
|
#include <di/log/module.h>
|
|
#include <di/log/component.h>
|
|
|
|
struct di_log_msg {
|
|
uint64_t timestamp; /**< DI-Net time in milliseconds (di_time_get_stamp) */
|
|
enum di_log_level loglevel; /**< Name of the module */
|
|
enum di_log_component component;
|
|
uint16_t module;
|
|
const char *msg;
|
|
};
|
|
|
|
/**
|
|
* Log backend callback
|
|
* @param ctx Configuration context
|
|
* @param offset Read offset in bytes
|
|
* @param data Address to read data into
|
|
* @param size Size of data in bytes
|
|
*/
|
|
typedef void (*di_log_writer_t)(const struct di_log_msg *msg, void *private_data);
|
|
|
|
#include <di/log/macros.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
void di_log_init(enum di_log_level level, di_log_writer_t writer, void *private_data);
|
|
void di_log(enum di_log_level level, enum di_log_component component, uint16_t module, const char *fmt, ...);
|
|
const char *di_log_level_str(enum di_log_level l);
|
|
const char *di_log_component_str(enum di_log_component c);
|
|
const char *di_log_module_str(enum di_log_component c, uint16_t module);
|
|
|
|
const char *di_log_decorate_begin(enum di_log_level l);
|
|
const char *di_log_decorate_end(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* INCLUDE_DI_LOG_H_ */
|