hvisage / metalog

metalog is a syslog replacement that allows regular expresion matching
GNU General Public License v2.0
35 stars 10 forks source link

Add support for %[nnn]N nanoseconds in stamp_fmt #7

Closed rokonrad closed 4 years ago

rokonrad commented 4 years ago

Hi! During usage of metalog I've had the wish to have a more precise timestamps than seconds. By looking over the busybox code (coreutils/date.c) I've found an example how nanoseconds can be implemented.

Therefore I adopted the busybox snippet a little and tested this snippet positively (in a seperate test binary I'v also tested with valgrind: No leaks are possible...).

With this pull request it's possible to use %[nnn]N as conversion specification where nnn is optional. By default all 9 numbers are printed. By using nnn < 9 one can shorten it to e.g. milliseconds by using %3N.

Would be nice to have it merged here :-)

Cheers Roman