[Crash-utility] [PATCH] log: fix log level print in older kernels

John Pittman jpittman at redhat.com
Fri Feb 12 19:37:34 UTC 2021


In older kernels, the log level and the log priority are not
separated.  Since the log level is only the last three bits,
print only those last three bits when using 'log -m'.

Suggested-by: David Jeffery <djeffery at redhat.com>
Signed-off-by: John Pittman <jpittman at redhat.com>
---
 defs.h   | 1 +
 kernel.c | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/defs.h b/defs.h
index 35cdac2..35b983a 100644
--- a/defs.h
+++ b/defs.h
@@ -5627,6 +5627,7 @@ void clone_bt_info(struct bt_info *, struct bt_info *, struct task_context *);
 void dump_kernel_table(int);
 void dump_bt_info(struct bt_info *, char *where);
 void dump_log(int);
+#define LOG_LEVEL(v) ((v) & 0x07)
 #define SHOW_LOG_LEVEL (0x1)
 #define SHOW_LOG_DICT  (0x2)
 #define SHOW_LOG_TEXT  (0x4)
diff --git a/kernel.c b/kernel.c
index ac765e3..735263c 100644
--- a/kernel.c
+++ b/kernel.c
@@ -5262,6 +5262,8 @@ dump_log_entry(char *logptr, int msg_flags)
 		fprintf(fp, "%s", buf);
 	}
 
+	level = LOG_LEVEL(level);
+
 	if (msg_flags & SHOW_LOG_LEVEL) {
 		sprintf(buf, "<%x>", level);
 		ilen += strlen(buf);
-- 
2.17.2




More information about the Crash-utility mailing list