]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: improve reltime colors
authorKarel Zak <kzak@redhat.com>
Tue, 14 Oct 2014 08:20:19 +0000 (10:20 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Oct 2014 08:20:19 +0000 (10:20 +0200)
[  +0.004034] sd 113:0:0:0: [sdb] Attached SCSI disk
[Oct10 13:04]  sdb: unknown partition table
[  +0.034011]  sdb: sdb1 sdb2 sdb3 sdb4 < sdb5 sdb6 >

.. the "Oct10 13:04" is possible to colorize by "timebreak"
scheme (default is bold green).

Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/dmesg.1
sys-utils/dmesg.c

index 8a267f86777c0a96b0dea8e7919c36e41dd1106f..bf525e4e982ef6d635c97225a2938aa1f756b200 100644 (file)
@@ -204,6 +204,10 @@ The message sub-system prefix (e.g. "ACPI:").
 .B time
 The message timestamp.
 .TP
+.B timebreak
+The message timestamp in short ctime format in \fB\-\-reltime\fR 
+or \fB\-\-human\fR output.
+.TP
 .B alert
 The text of the message with the alert log priority.
 .TP
index 661aaa9d9889c43ad84f63a769b08098eb78c184..1a1ace4ab40b17e4f3cb723e77a278cef6c52f83 100644 (file)
@@ -71,6 +71,7 @@ struct dmesg_color {
 enum {
        DMESG_COLOR_SUBSYS,
        DMESG_COLOR_TIME,
+       DMESG_COLOR_TIMEBREAK,
        DMESG_COLOR_ALERT,
        DMESG_COLOR_CRIT,
        DMESG_COLOR_ERR,
@@ -82,6 +83,7 @@ static const struct dmesg_color colors[] =
 {
        [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_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 },
@@ -921,6 +923,7 @@ static void print_record(struct dmesg_control *ctl,
                if (cur.tm_min != ctl->lasttm.tm_min ||
                    cur.tm_hour != ctl->lasttm.tm_hour ||
                    cur.tm_yday != ctl->lasttm.tm_yday) {
+                       dmesg_enable_color(DMESG_COLOR_TIMEBREAK);
                        printf("[%s] ", short_ctime(&cur, buf, sizeof(buf)));
                } else {
                        if (delta < 10)