]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: allow to print time delta without timestamp
authorKarel Zak <kzak@redhat.com>
Wed, 20 Jul 2011 15:03:24 +0000 (17:03 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 20 Jul 2011 15:03:24 +0000 (17:03 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/dmesg.1
sys-utils/dmesg.c

index 5a6910aaa0f1544b3ef228efc67b22f76a42c2f3..4531edb559be330c7e060b35156fe7a7f9e1ff0c 100644 (file)
@@ -35,7 +35,8 @@ Clear the ring buffer contents after printing.
 .IP "\fB\-D, \-\-console-off\fP"
 Disable printing messages to the console.
 .IP "\fB\-d, \-\-show-delta\fP"
-Display the time spent between messages.
+Display the timestamp and time delta spent between messages. If used together
+with --notime then only the time delta without the timestamp is printed.
 .IP "\fB\-E, \-\-console-on\fP"
 Enable printing messages to the console.
 .IP "\fB\-f, \-\-facility \fIlist\fP"
index 2be34075ab360485d354155ef2fb423df0fbd5eb..7123c7fb62b652d6e933c4074dd7643606059736 100644 (file)
@@ -512,14 +512,14 @@ static int get_next_record(struct dmesg_control *ctl, struct dmesg_record *rec)
 
                if (*begin == '[' && (*(begin + 1) == ' ' ||
                                      isdigit(*(begin + 1)))) {
-                       if (ctl->notime) {              /* ignore timestamp */
+                       if (ctl->delta || ctl->ctime) {
+                               begin = parse_timestamp(begin + 1, &rec->tv);
+                       } else if (ctl->notime) {
                                while (begin < end) {
                                        begin++;
                                        if (*(begin - 1) == ']')
                                                break;
                                }
-                       } else if (ctl->delta || ctl->ctime) {
-                               begin = parse_timestamp(begin + 1, &rec->tv);
                        }
                }
 
@@ -596,6 +596,8 @@ static void print_buffer(const char *buf, size_t size,
 
                        if (ctl->ctime && *tbuf)
                                printf("[%s ", tbuf);
+                       else if (ctl->notime)
+                               putchar('[');
                        else
                                printf("[%5d.%06d ", (int) rec.tv.tv_sec,
                                                     (int) rec.tv.tv_usec);
@@ -738,9 +740,8 @@ int main(int argc, char *argv[])
                errx(EXIT_FAILURE, _("--raw can't be used together with level, "
                     "facility, decode, delta, ctime or notime options"));
 
-       if (ctl.notime && (ctl.ctime || ctl.delta))
-               errx(EXIT_FAILURE, _("--notime can't be used together with ctime "
-                    "or delta options"));
+       if (ctl.notime && ctl.ctime)
+               errx(EXIT_FAILURE, _("--notime can't be used together with ctime "));
 
        switch (cmd) {
        case SYSLOG_ACTION_READ_ALL: