pydmesg: dmesg with human readable timestamps

Since I used dmesg for the first time I felt there was something wrong about it. Having very accurate timestamps might of course be helpful for many people, but sometimes you just want to know when something happened.

dmesg prints timestamps in the form of seconds.nanoseconds since the system booted. And no, there seems to be no -h option to make it human readable.

Today I felt like writing some Python for that, and pydmesg is the result. Is a simple script that fetches the uptime from /proc/uptime and uses it to print nice dmesg timestamps (timestamp format can be changed by editing the file).

Before:

[499902.343696] uvcvideo: Failed to query (1) UVC ...
[499902.354633] uvcvideo: Failed to query (1) UVC ...
[530442.358520] npviewer.bin[8818]: segfault at ...

After:

[2010-08-21 13:12:37] uvcvideo: Failed to query (1) UVC ...
[2010-08-21 13:12:37] uvcvideo: Failed to query (1) UVC ...
[2010-08-21 21:41:37] npviewer.bin [8818]: segfault at ...

By default precision is set to the second, which I guess is ok for
human beings ;–)

[gist]https://gist.github.com/542780[/gist]

print “hello world!”

Hi!

I used (and still do!) blog about VoIP in Spanish at http://saghul.net, but at some point I wanted to blog a bit on coding stuff, specially Python, and I’m starting today.

Frankly, I’m tired of maintaining a complete blog/CMS like WordPress, I wanted something simple with which I could share some code snippets. Being a blog about code, syntax highlighting was a must. Posterous does a nice job on this by supporting Markdown and algo integration with Gist, a great service GitHub provides. Moreover, Posterous allows me to post by sending an email, I’ve never seen something like this!

So, consider this the hello world :–)

print "hello world!"