From: Mark Hatle <mark.hatle@kernel.crashing.org>
To: yocto-patches@lists.yoctoproject.org
Cc: richard.purdie@linuxfoundation.org, frezidok1@gmail.com
Subject: [pseudo][PATCH v2 02/23] pseudo_util: Add log severity flags
Date: Fri, 3 Jul 2026 13:40:34 -0500 [thread overview]
Message-ID: <1783104055-19005-3-git-send-email-mark.hatle@kernel.crashing.org> (raw)
In-Reply-To: <1783104055-19005-1-git-send-email-mark.hatle@kernel.crashing.org>
From: Dmitry Sakhonchik <frezidok1@gmail.com>
Create an infrastructure to make use of severity flags from pseudo_tables.
After that it is now possible to set severity flags from env (PSEUDO_SEVERITY) and from terminal via optargs.
[YOCTO #12141]
Signed-off-by: Dmitry Sakhonchik <frezidok1@gmail.com>
Signed-off-by: Mark Hatle <mark.hatle@kernel.crashing.org>
---
pseudo.c | 5 ++++-
pseudo.h | 3 +++
pseudo_util.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 51 insertions(+), 1 deletion(-)
diff --git a/pseudo.c b/pseudo.c
index 25711b6..e5fe5cf 100644
--- a/pseudo.c
+++ b/pseudo.c
@@ -134,7 +134,7 @@ main(int argc, char *argv[]) {
* wrong. The + suppresses this annoying behavior, but may not
* be compatible with sane option libraries.
*/
- while ((o = getopt(argc, argv, "+BCdfhi:lm:M:p:P:r:R:St:vVx:")) != -1) {
+ while ((o = getopt(argc, argv, "+BCdfhi:klm:M:p:P:r:R:St:vVx:")) != -1) {
switch (o) {
case 'B': /* rebuild database */
opt_B = 1;
@@ -231,6 +231,9 @@ main(int argc, char *argv[]) {
printf("Set PSEUDO_PREFIX to run with a different prefix.\n");
exit(0);
break;
+ case 'k': /* debug severity */
+ pseudo_severity_set(optarg);
+ break;
case 'x': /* debug flags */
pseudo_debug_set(optarg);
break;
diff --git a/pseudo.h b/pseudo.h
index b6c13f2..e48d38a 100644
--- a/pseudo.h
+++ b/pseudo.h
@@ -26,8 +26,11 @@ extern void pseudo_debug_terse(void);
extern void pseudo_debug_set(char *);
extern void pseudo_debug_clear(char *);
extern void pseudo_debug_flags_finalize(void);
+extern void pseudo_severity_set(char *);
+extern void pseudo_severity_flags_finalize(void);
extern unsigned long pseudo_util_debug_flags;
extern unsigned long pseudo_util_evlog_flags;
+extern unsigned long pseudo_util_severity_flags;
extern int pseudo_util_debug_fd;
extern int pseudo_disabled;
extern int pseudo_allow_fsync;
diff --git a/pseudo_util.c b/pseudo_util.c
index 2b0cc04..f8f2a2f 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -63,6 +63,7 @@ static struct pseudo_variables pseudo_env[] = {
#endif
{ "PSEUDO_EVLOG", 12, NULL },
{ "PSEUDO_EVLOG_FILE", 17, NULL },
+ { "PSEUDO_SEVERITY", 15, NULL },
{ NULL, 0, NULL } /* Magic terminator */
};
@@ -90,6 +91,7 @@ static int pseudo_evlog_next_entry = 0;
static void pseudo_evlog_set(char *);
static void pseudo_evlog_flags_finalize(void);
static unsigned long pseudo_debug_flags_in(char *);
+static unsigned long pseudo_severity_flags_in(char *);
/* -1 - init hasn't been run yet
* 0 - init has been run
@@ -247,10 +249,17 @@ pseudo_init_util(void) {
pseudo_evlog_flags_finalize();
}
free(env);
+ env = pseudo_get_value("PSEUDO_SEVERITY");
+ if (env) {
+ pseudo_severity_set(env);
+ pseudo_severity_flags_finalize();
+ }
+ free(env);
}
unsigned long pseudo_util_debug_flags = 0;
unsigned long pseudo_util_evlog_flags = 0;
+unsigned long pseudo_util_severity_flags = 0;
int pseudo_util_debug_fd = 2;
int pseudo_util_evlog_fd = 2;
static int debugged_newline = 1;
@@ -433,6 +442,11 @@ pseudo_evlog_set(char *s) {
pseudo_util_evlog_flags = pseudo_debug_flags_in(s);
}
+void
+pseudo_severity_set(char *s) {
+ pseudo_util_severity_flags = pseudo_severity_flags_in(s);
+}
+
/* This exists because we don't want to allocate a bunch of strings
* and free them immediately if you have several flags set.
*/
@@ -457,6 +471,11 @@ pseudo_evlog_flags_finalize(void) {
pseudo_flags_finalize(pseudo_util_evlog_flags, "PSEUDO_EVLOG");
}
+void
+pseudo_severity_flags_finalize(void) {
+ pseudo_flags_finalize(pseudo_util_severity_flags, "PSEUDO_SEVERITY");
+}
+
static unsigned long
pseudo_debug_flags_in(char *s) {
unsigned long flags = 0;
@@ -471,6 +490,31 @@ pseudo_debug_flags_in(char *s) {
return flags;
}
+static unsigned long
+pseudo_severity_flags_in(char *s) {
+ unsigned long flags = 0;
+ char *token = NULL;
+ char *saveptr = NULL;
+ char *s_copy = NULL;
+
+ if (!s)
+ return flags;
+
+ s_copy = strdup(s);
+
+ token = strtok_r(s_copy, " ,;", &saveptr);
+ while (token != NULL) {
+ pseudo_sev_t id = pseudo_sev_id(token);
+ if (id > SEVERITY_NONE && id < SEVERITY_MAX) {
+ flags |= (1UL << id);
+ }
+ token = strtok_r(NULL, " ,;", &saveptr);
+ }
+
+ free(s_copy);
+ return flags;
+}
+
void
pseudo_debug_clear(char *s) {
if (!s)
--
1.8.3.1
next prev parent reply other threads:[~2026-07-03 18:41 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 18:40 [pseudo][PATCH v2 00/23] Create new pseudo 1.99.0 version Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 01/23] Makefile.in: Move version to 1.99.0 to prep for 2.0 development Mark Hatle
2026-07-03 18:40 ` Mark Hatle [this message]
2026-07-03 18:40 ` [pseudo][PATCH v2 03/23] pseudo: Add new logging macros Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 04/23] pseudo_util: Change pseudo_diag() calls to appropriate " Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 05/23] pseudo_db: Change pseudo_diag() calls to appropriate macros Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 06/23] pseudo_client: " Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 07/23] pseudo_server: " Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 08/23] pseudo.c: " Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 09/23] pseudolog.c: " Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 10/23] wrappers: " Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 11/23] pseudo: Change pseudo_diag() name to pseudo_log() Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 12/23] pseudo_util: Add default log severity values Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 13/23] pseudo_util.c: strchr now returns const char Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 14/23] test/test-openat2-func.c: Remove unusuaed saved_errno Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 15/23] pseudo.h: Avoid accessing unallocated memory Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 16/23] pseudo_util: Avoid accidental free calls for without_libpseudo() Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 17/23] pseudo_util: Ensure pseudo_setupenvp handles memory consistently Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 18/23] pseudo_util: Avoid a memory leak in pseudo_dropenv() Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 19/23] pseudo_util: Clean up memory handling for setupenvp results Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 20/23] exec*: Replace bash workaround to avoid memory corruption Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 21/23] pseudo_util: Correctly free memory allocated by pseudo_setupenvp Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 22/23] test-bash-exec-env: Add bash env test case Mark Hatle
2026-07-03 18:40 ` [pseudo][PATCH v2 23/23] test: various: Move to makefile compilation Mark Hatle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1783104055-19005-3-git-send-email-mark.hatle@kernel.crashing.org \
--to=mark.hatle@kernel.crashing.org \
--cc=frezidok1@gmail.com \
--cc=richard.purdie@linuxfoundation.org \
--cc=yocto-patches@lists.yoctoproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox