mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-09 03:21:51 +00:00
log: Allow LOG_DEBUG to always enable log output
At present if CONFIG_LOG enabled, putting LOG_DEBUG at the top of a file (before log.h inclusion) causes _log() to be executed for every log() call, regardless of the build- or run-time logging level. However there is no guarantee that the log record will actually be displayed. If the current log level is lower than LOGL_DEBUG then it will not be. Add a way to signal that the log record should always be displayed and update log_passes_filters() to handle this. With the new behaviour, log_debug() will always log if LOG_DEBUG is enabled. Move log_test_syslog_nodebug() into its own file since it cannot be made to work where it is, with LOG_DEBUG defined. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
0437cc4155
commit
52d3df7fef
7 changed files with 129 additions and 84 deletions
|
@ -33,6 +33,9 @@ enum log_level_t {
|
|||
LOGL_COUNT,
|
||||
LOGL_NONE,
|
||||
|
||||
LOGL_LEVEL_MASK = 0xf, /* Mask for valid log levels */
|
||||
LOGL_FORCE_DEBUG = 0x10, /* Mask to force output due to LOG_DEBUG */
|
||||
|
||||
LOGL_FIRST = LOGL_EMERG,
|
||||
LOGL_MAX = LOGL_DEBUG_IO,
|
||||
};
|
||||
|
@ -133,7 +136,7 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
|
|||
|
||||
#if CONFIG_IS_ENABLED(LOG)
|
||||
#ifdef LOG_DEBUG
|
||||
#define _LOG_DEBUG 1
|
||||
#define _LOG_DEBUG LOGL_FORCE_DEBUG
|
||||
#else
|
||||
#define _LOG_DEBUG 0
|
||||
#endif
|
||||
|
@ -141,9 +144,11 @@ static inline int _log_nop(enum log_category_t cat, enum log_level_t level,
|
|||
/* Emit a log record if the level is less that the maximum */
|
||||
#define log(_cat, _level, _fmt, _args...) ({ \
|
||||
int _l = _level; \
|
||||
if (CONFIG_IS_ENABLED(LOG) && (_l <= _LOG_MAX_LEVEL || _LOG_DEBUG)) \
|
||||
_log((enum log_category_t)(_cat), _l, __FILE__, __LINE__, \
|
||||
__func__, \
|
||||
if (CONFIG_IS_ENABLED(LOG) && \
|
||||
(_LOG_DEBUG != 0 || _l <= _LOG_MAX_LEVEL)) \
|
||||
_log((enum log_category_t)(_cat), \
|
||||
(enum log_level_t)(_l | _LOG_DEBUG), __FILE__, \
|
||||
__LINE__, __func__, \
|
||||
pr_fmt(_fmt), ##_args); \
|
||||
})
|
||||
#else
|
||||
|
@ -279,8 +284,12 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
|
|||
* Memebers marked as 'allocated' are allocated (e.g. via strdup()) by the log
|
||||
* system.
|
||||
*
|
||||
* TODO(sjg@chromium.org): Compress this struct down a bit to reduce space, e.g.
|
||||
* a single u32 for cat, level, line and force_debug
|
||||
*
|
||||
* @cat: Category, representing a uclass or part of U-Boot
|
||||
* @level: Severity level, less severe is higher
|
||||
* @force_debug: Force output of debug
|
||||
* @file: Name of file where the log record was generated (not allocated)
|
||||
* @line: Line number where the log record was generated
|
||||
* @func: Function where the log record was generated (not allocated)
|
||||
|
@ -289,6 +298,7 @@ void __assert_fail(const char *assertion, const char *file, unsigned int line,
|
|||
struct log_rec {
|
||||
enum log_category_t cat;
|
||||
enum log_level_t level;
|
||||
bool force_debug;
|
||||
const char *file;
|
||||
int line;
|
||||
const char *func;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue