Package: util-linux
Version: 2.37.3-1
Severity: normal
Tags: patch upstream
X-Debbugs-Cc: steve+...@tecwec.eu

Hello,
please find attached a very simple patch which allows consistent customization
of the coloring schemes  of the emerg, notice, info and debug levels in dmesg.
(currently only alert, crit, err and warn coloring schemes could be customized).

output changes (when coloring enabled):
        emerg level takes a default reverse+red, as alert and crit.
        debug level takes dark gray (seems reasonable)

As my color choices might not suit the masses (or even offend them!),
notice and info levels are unaffected and keep a default reset vt100 sequence.
Afterall, they could then be customized via /etc/terminal-colors.d/dmesg.scheme

== LEGAL STUFF ==
Due to the triviality of the patch, I HEREBY EXPLICITELY DISMISS any right, 
copyrights, whatsoever,
applying to this patch, with or without changes, and grant the rights to the 
Debian maintainer,
and/or upstream maintainers, or anybody, to have it applied to Debian and/or 
upstream, even on his/her own name,
without even mentioning me, hoping this will make things faster and paperless.
(If this is not sufficient or explicit enough, please tell, but, honestly...)

Regards, Thanks & Happy new year, if not too late.

-- System Information:
Debian Release: bookworm/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.15.0-3-amd64 (SMP w/4 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_US.ISO-8859-1, LC_CTYPE=en_US.ISO-8859-1 (charmap=ISO-8859-1), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages util-linux depends on:
ii  libaudit1      1:3.0.6-1+b1
ii  libblkid1      2.37.3-1+b1
ii  libc6          2.33-5
ii  libcap-ng0     0.7.9-2.2+b1
ii  libcrypt1      1:4.4.27-1.1
ii  libmount1      2.37.3-1+b1
ii  libpam0g       1.4.0-11
ii  libselinux1    3.3-1+b1
ii  libsmartcols1  2.37.3-1+b1
ii  libsystemd0    250.3-2
ii  libtinfo6      6.3-2
ii  libudev1       250.3-2
ii  libuuid1       2.37.3-1+b1
ii  zlib1g         1:1.2.11.dfsg-2

util-linux recommends no packages.

Versions of packages util-linux suggests:
ii  dosfstools          4.2-1
ii  kbd                 2.3.0-3
pn  util-linux-locales  <none>

-- debconf information excluded
diff -ru sys-utils.orig/dmesg.1.adoc sys-utils/dmesg.1.adoc
--- sys-utils.orig/dmesg.1.adoc 2022-02-02 21:23:39.220901256 +0100
+++ sys-utils/dmesg.1.adoc      2022-02-02 21:28:55.355191631 +0100
@@ -159,6 +159,9 @@
 *timebreak*::
 The message timestamp in short ctime format in *--reltime* or *--human* output.
 
+*emerg*::
+The text of the message with the emerg log priority.
+
 *alert*::
 The text of the message with the alert log priority.
 
@@ -171,6 +174,15 @@
 *warn*::
 The text of the message with the warning log priority.
 
+*notice*::
+The text of the message with the notice log priority.
+
+*info*::
+The text of the message with the info log priority.
+
+*debug*::
+The text of the message with the debug log priority.
+
 *segfault*::
 The text of the message that inform about segmentation fault.
 
diff -ru sys-utils.orig/dmesg.c sys-utils/dmesg.c
--- sys-utils.orig/dmesg.c      2022-02-02 21:23:39.224901283 +0100
+++ sys-utils/dmesg.c   2022-02-02 22:02:56.918640093 +0100
@@ -71,10 +71,14 @@
        DMESG_COLOR_SUBSYS,
        DMESG_COLOR_TIME,
        DMESG_COLOR_TIMEBREAK,
+       DMESG_COLOR_EMERG,
        DMESG_COLOR_ALERT,
        DMESG_COLOR_CRIT,
        DMESG_COLOR_ERR,
        DMESG_COLOR_WARN,
+       DMESG_COLOR_NOTICE,
+       DMESG_COLOR_INFO,
+       DMESG_COLOR_DEBUG,
        DMESG_COLOR_SEGFAULT
 };
 
@@ -83,10 +87,14 @@
        [DMESG_COLOR_SUBSYS]    = { "subsys",   UL_COLOR_BROWN },
        [DMESG_COLOR_TIME]      = { "time",     UL_COLOR_GREEN },
        [DMESG_COLOR_TIMEBREAK] = { "timebreak",UL_COLOR_GREEN UL_COLOR_BOLD },
+       [DMESG_COLOR_EMERG]     = { "emerg",    UL_COLOR_REVERSE UL_COLOR_RED },
        [DMESG_COLOR_ALERT]     = { "alert",    UL_COLOR_REVERSE UL_COLOR_RED },
        [DMESG_COLOR_CRIT]      = { "crit",     UL_COLOR_BOLD UL_COLOR_RED },
        [DMESG_COLOR_ERR]       = { "err",      UL_COLOR_RED },
        [DMESG_COLOR_WARN]      = { "warn",     UL_COLOR_BOLD },
+       [DMESG_COLOR_NOTICE]    = { "notice",     UL_COLOR_RESET },
+       [DMESG_COLOR_INFO]      = { "info",     UL_COLOR_RESET },
+       [DMESG_COLOR_DEBUG]     = { "debug",     UL_COLOR_DARK_GRAY },
        [DMESG_COLOR_SEGFAULT]  = { "segfault", UL_COLOR_HALFBRIGHT 
UL_COLOR_RED }
 };
 
@@ -235,6 +243,9 @@
        int id = -1;
 
        switch (log_level) {
+       case LOG_EMERG:
+               id = DMESG_COLOR_EMERG;
+               break;
        case LOG_ALERT:
                id = DMESG_COLOR_ALERT;
                break;
@@ -247,6 +258,15 @@
        case LOG_WARNING:
                id = DMESG_COLOR_WARN;
                break;
+       case LOG_NOTICE:
+               id = DMESG_COLOR_NOTICE;
+               break;
+       case LOG_INFO:
+               id = DMESG_COLOR_INFO;
+               break;
+       case LOG_DEBUG:
+               id = DMESG_COLOR_DEBUG;
+               break;
        default:
                break;
        }

Reply via email to