[pseudo][PATCH v2 03/23] pseudo: Add new logging macros

Mark Hatle <[email protected]> Fri, 3 Jul 2026 13:40:35 -0500
Newsgroups org.yoctoproject.lists.yocto-patches
Message-ID <[email protected]>
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]>
Signed-off-by: Mark Hatle <[email protected]>
---
 enums/sev.in |  2 +-
 pseudo.h     | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/enums/sev.in b/enums/sev.in
index 24c2c6e..44dffde 100644
--- a/enums/sev.in
+++ b/enums/sev.in
@@ -1,4 +1,4 @@
-sev: SEVERITY
+sev: SEVERITY; FLAGS
 debug
 info
 warn
diff --git a/pseudo.h b/pseudo.h
index e48d38a..d214ba2 100644
--- a/pseudo.h
+++ b/pseudo.h
@@ -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__); } \
-- 
1.8.3.1