util-linux/sys-utils dmesg support for additional human readable timestamp
PATCH 1/1 util-linux/sys-utils dmesg support for additional human readable timestamp
The dmesg logs have timestamps in seconds since boot format which can be converted to other formats. However, there is no option to include both the original timestamp as present in the buffer along with the converted timestamp in the specified format.
This change updates the --time-format option in dmesg to enable the user to specify it multiple times with different formats with each input providing a timestamp format among the currently supported choices. This enables seeing the dmesg logs in both seconds since boot and human readable format simultaneously in each row of the log output. The sequence of timestamp format follows the order
in which the user provides the desired formats.
--- sys-utils/dmesg.1.adoc | 4 +- sys-utils/dmesg.c | 257 ++++++++++++++++++++++++++--------------- 2 files changed, 168 insertions(+), 93 deletions(-)
sys-utils/dmesg.1.adoc +3 -1
@@ -133,9 +133,11 @@ Display record until the specified time. Supported is the subsecond granularity. Do not print kernel's timestamps. *--time-format* _format_:: -Print timestamps using the given _format_, which can be *ctime*, *reltime*, *delta* or *iso*. The first three formats are aliases of the time-format-specific options. The *iso* format is a *dmesg* implementation of the ISO-8601 timestamp format. The purpose of this format is to make the comparing of timestamps between two systems, and any other parsing, easy. The definition of the *iso* timestamp is: YYYY-MM-DD<T>HH:MM:SS,<microseconds><-+><timezone offset from UTC>. ++Print timestamps using the given _format_, which can be *ctime*, *reltime*, *delta*, *iso* or *raw*. The first three formats are aliases of the time-format-specific options. The *raw* format uses the default timestamp format showing seconds since boot. The *iso* format is a *dmesg* implementation of the ISO-8601 timestamp format. The purpose of this format is to make the comparing of timestamps between two systems, and any other parsing, easy. The definition of the *iso* timestamp is: YYYY-MM-DD<T>HH:MM:SS,<microseconds><-+><timezone offset from UTC>. + The *iso* format has the same issue as *ctime*: the time may be inaccurate when a system is suspended and resumed. ++ +*--time-format* may be used multiple times with different values for _format_ to output each specified format. *-u*, *--userspace*:: Print userspace messages.
sys-utils/dmesg.c +165 -92
400 lines not on this page · raw message
Signature · 1 line
2.41.0
Karel Zak
maintainersys-utils/dmesg.1.adoc
Quoted 4 lines · Rishabh Thukral
sys-utils/dmesg.1.adoc +0
-0
Added as a PR (to make sure it pass CI)
https://github.com/util-linux/util-linux/pull/2641
Quoted 1 line
+#define
TOTAL_DMESG_TIMESTAMP_FORMATS_SUPPORTED8
I did a small change to the code to make some names shorter :-)
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com