pseudo: Add new logging macros
PATCH 1/1 pseudo: Add new logging macros
From: Dmitry Sakhonchik <[email protected]>
They are designed to replace various direct pseudo_diag() call across the program and add new "smart" logging functionality. CRITICAL and ERROR messages are shown no matter what, INFO and WARNING only if the corresponding flag is set.
The patch is based on: [pseudo,v2] pseudo_util: Add log severity flags and implements [YOCTO #12141]
Signed-off-by Dmitry Sakhonchik <[email protected]>
--- enums/sev.in | 2 +- pseudo.h | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-)
enums/sev.in +1 -1
@@ -1,4 +1,4 @@ -sev: SEVERITY +sev: SEVERITY; FLAGS debug info warn
pseudo.h +17 -0
@@ -41,6 +41,23 @@ extern int pseudo_evlog_internal(char *, ...) __attribute__ ((format (printf, 1, }while (0 ) extern void pseudo_evlog_dump(void);#ifndef NDEBUG +#define pseudo_critical (fmt, ...) do { \ + pseudo_diag("CRITICAL: " fmt, ##__VA_ARGS__); \ + abort(); \ +} while (0) +#define pseudo_error (fmt, ...) do { \ + pseudo_diag("ERROR: " fmt, ##__VA_ARGS__); \ +} while (0) +#define pseudo_warning (fmt, ...) do { \ + if (pseudo_util_severity_flags & SEVERITYF_WARN) { \ + pseudo_diag("WARNING: " fmt, ##__VA_ARGS__); \ + } \ +} while (0) +#define pseudo_info (fmt, ...) do { \ + if (pseudo_util_severity_flags & SEVERITYF_INFO) { \ + pseudo_diag("INFO: " fmt, ##__VA_ARGS__); \ + } \ +} while (0)#define pseudo_debug (x, ...) do { \ if ((x) & PDBGF_VERBOSE) { \ if ((pseudo_util_debug_flags & PDBGF_VERBOSE) && (pseudo_util_debug_flags & ((x) & ~PDBGF_VERBOSE))) { pseudo_diag(__VA_ARGS__); } \