12 #ifndef __METAL_METAL_LOG__H__
13 #define __METAL_METAL_LOG__H__
37 const char *format, ...);
72 const char *format, ...);
85 #if defined(ML_FUNC_LINE)
86 #define metal_fmt(fmt) "%s:%u " fmt, __func__, __LINE__
88 #define metal_fmt(fmt) fmt
98 #define metal_log(level, fmt, ...) ({ \
99 if (_metal.common.log_handler && level <= _metal.common.log_level) \
100 _metal.common.log_handler(level, metal_fmt(fmt), ## __VA_ARGS__); \
103 #define metal_err(fmt, args...) metal_log(METAL_LOG_ERROR, fmt, ##args)
104 #define metal_warn(fmt, args...) metal_log(METAL_LOG_WARNING, fmt, ##args)
105 #define metal_info(fmt, args...) metal_log(METAL_LOG_INFO, fmt, ##args)
106 #define metal_dbg(fmt, args...) metal_log(METAL_LOG_DEBUG, fmt, ##args)
114 #include <metal/system/@PROJECT_SYSTEM@/log.h>
void metal_default_log_handler(enum metal_log_level level, const char *format,...)
Default libmetal log handler.
Definition: log.c:13
metal_log_level
Log message priority levels for libmetal.
Definition: log.h:24
metal_log_handler metal_get_log_handler(void)
Get the current libmetal log handler.
Definition: log.c:49
void metal_set_log_handler(metal_log_handler handler)
Set libmetal log handler.
Definition: log.c:44
void metal_set_log_level(enum metal_log_level level)
Set the level for libmetal logging.
Definition: log.c:54
void(* metal_log_handler)(enum metal_log_level level, const char *format,...)
Log message handler type.
Definition: log.h:36
enum metal_log_level metal_get_log_level(void)
Get the current level for libmetal logging.
Definition: log.c:59
@ METAL_LOG_NOTICE
normal but significant condition.
Definition: log.h:30
@ METAL_LOG_INFO
informational messages.
Definition: log.h:31
@ METAL_LOG_WARNING
warning conditions.
Definition: log.h:29
@ METAL_LOG_EMERGENCY
system is unusable.
Definition: log.h:25
@ METAL_LOG_ALERT
action must be taken immediately.
Definition: log.h:26
@ METAL_LOG_CRITICAL
critical conditions.
Definition: log.h:27
@ METAL_LOG_DEBUG
debug-level messages.
Definition: log.h:32
@ METAL_LOG_ERROR
error conditions.
Definition: log.h:28