diff options
author | Warner Losh <imp@FreeBSD.org> | 2022-05-06 17:31:18 +0000 |
---|---|---|
committer | Warner Losh <imp@FreeBSD.org> | 2022-05-07 15:32:22 +0000 |
commit | 45ae223ac654c0ab6cdc4eaacca693244802383e (patch) | |
tree | cd9a15b915d572e8ed7e8de6f61df71283e7703a | |
parent | 6910fee62e77afecbaff3be0ff922a34e85a9881 (diff) | |
download | src-45ae223ac654c0ab6cdc4eaacca693244802383e.tar.gz src-45ae223ac654c0ab6cdc4eaacca693244802383e.zip |
-rw-r--r-- | sbin/dmesg/dmesg.8 | 5 | ||||
-rw-r--r-- | sys/kern/subr_msgbuf.c | 12 |
2 files changed, 14 insertions, 3 deletions
diff --git a/sbin/dmesg/dmesg.8 b/sbin/dmesg/dmesg.8 index 13101baf7e78..a924549264cd 100644 --- a/sbin/dmesg/dmesg.8 +++ b/sbin/dmesg/dmesg.8 @@ -78,7 +78,10 @@ the message buffer: The default value is shown next to each variable. .Bl -tag -width indent .It kern.msgbuf_show_timestamp : No 0 -If set to 1, then a timestamp will be added to most lines in the message buffer. +If set to 0, no timetamps are added. +If set to 1, then a 1-second granularity timestamp will be added to most lines +in the message buffer. +If set to 2, then a microsecond granularity timestamp will be added. This may also be set as a boot .Xr loader 8 tunable. diff --git a/sys/kern/subr_msgbuf.c b/sys/kern/subr_msgbuf.c index b41e78dd886e..4664e742c5fb 100644 --- a/sys/kern/subr_msgbuf.c +++ b/sys/kern/subr_msgbuf.c @@ -234,8 +234,16 @@ msgbuf_addstr(struct msgbuf *mbp, int pri, const char *str, int filter_cr) if (msgbuf_show_timestamp && needtime == 1 && (mbp->msg_flags & MSGBUF_NEEDNL) == 0) { - snprintf(buf, sizeof(buf), "[%jd] ", - (intmax_t)time_uptime); + if (msgbuf_show_timestamp == 1) { + snprintf(buf, sizeof(buf), "[%jd] ", + (intmax_t)time_uptime); + } else { + struct timeval tv; + + microuptime(&tv); + snprintf(buf, sizeof(buf), "[%jd.%06d] ", + (intmax_t)tv.tv_sec, (int)tv.tv_usec); + } for (j = 0; buf[j] != '\0'; j++) msgbuf_do_addchar(mbp, buf[j]); needtime = 0; |