logging
Hello Simon,
I would like to convert printf and debug messages in the UEFI sub-system to log messages.
Currently if CONFIG_LOG=n, log_*() functions are mapped to log_nop(). So no output is provided independent of the criticality of the message.
What I would like to do is map log_err() to printf() and log_debug() to debug() if CONFIG_LOG=n . This way we could get the same console output no matter if CONFIG_LOG is enabled.
Would this make sense to you?
#if CONFIG_IS_ENABLED(LOG)
#define _LOG_MAX_LEVEL CONFIG_VAL(LOG_MAX_LEVEL)
#define log_err(_fmt...) log(LOG_CATEGORY, LOGL_ERR, ##_fmt) #define log_warning(_fmt...) log(LOG_CATEGORY, LOGL_WARNING, ##_fmt) #define log_notice(_fmt...) log(LOG_CATEGORY, LOGL_NOTICE, ##_fmt) #define log_info(_fmt...) log(LOG_CATEGORY, LOGL_INFO, ##_fmt) #define log_debug(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt) #define log_content(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_CONTENT, ##_fmt)
#define log_io(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt) #else
#define _LOG_MAX_LEVEL LOGL_INFO
#define log_err(_fmt...) printf(##_fmt)
#define log_warning(_fmt...) printf(##_fmt)
#define log_notice(_fmt...) printf(##_fmt)
#define log_info(_fmt...) printf(##_fmt)
#define log_debug(_fmt...) debug(##_fmt)
#define log_content(_fmt...) log_nop(LOG_CATEGORY, \
LOGL_DEBUG_CONTENT, ##_fmt)
#define log_io(_fmt...) log_nop(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt) #endif
Best regards
Heinrich
Hi Heinrich,
Quoted 34 lines · Heinrich Schuchardt
Hello Simon,
I would like to convert printf and debug messages in the UEFI sub-system to log messages.
Currently if
CONFIG_LOG=n, log_*() functions are mapped tolog_nop(). So no output is provided independent of the criticality of the message.What I would like to do is map
log_err()toprintf()andlog_debug()todebug()ifCONFIG_LOG=n. This way we could get the same console output no matter ifCONFIG_LOGis enabled.Would this make sense to you?
#if
CONFIG_IS_ENABLED(LOG)
#define_LOG_MAX_LEVELCONFIG_VAL(LOG_MAX_LEVEL)#define log_err(_fmt...) log(LOG_CATEGORY, LOGL_ERR, ##_fmt) #define log_warning(_fmt...) log(LOG_CATEGORY, LOGL_WARNING, ##_fmt) #define log_notice(_fmt...) log(LOG_CATEGORY, LOGL_NOTICE, ##_fmt) #define log_info(_fmt...) log(LOG_CATEGORY, LOGL_INFO, ##_fmt) #define log_debug(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG, ##_fmt) #define log_content(_fmt...) log(LOG_CATEGORY, LOGL_DEBUG_CONTENT,##_fmt)
#definelog_io(_fmt...)log(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)
#else
#define_LOG_MAX_LEVELLOGL_INFO#define log_err(_fmt...) printf(##_fmt) #define log_warning(_fmt...) printf(##_fmt) #define log_notice(_fmt...) printf(##_fmt) #define log_info(_fmt...) printf(##_fmt) #define log_debug(_fmt...) debug(##_fmt) #define log_content(_fmt...) log_nop(LOG_CATEGORY, \ LOGL_DEBUG_CONTENT, ##_fmt)
Quoted 2 lines
#define
log_io(_fmt...)log_nop(LOG_CATEGORY, LOGL_DEBUG_IO, ##_fmt)
#endif
I think that makes sense, yes.
Regards,
Simon