strptime with dateless time strings

33 views
Skip to first unread message

Joshua Chia

unread,
Nov 18, 2021, 4:01:49 AM11/18/21
to mtail-users
I have log files that span less than 24h and the timestamp text in them have no dates and look like "15:04:05.123456", expressing local time.

The date is implicit in the name of the directory containing the log file, the creation/modification date of the log and the system clock, but I don't know whether or how these can be incorporated in the calculation of the timestamp.

Although each log file spans less than 24h, sometimes a log file can cross midnight, earlier log entries have one date and the rest have the next date.

How can I get mtail to obtain the correct timestamp values? It wrongly assumes January 1st because the first month & first day are the default values.

-syslog_use_current_year fills in the year using the "present year". Is there a special reason something similar does not exist for month & day?

Josh

Jamie Wilkinson

unread,
Nov 25, 2021, 7:25:07 PM11/25/21
to Joshua Chia, mtail-users
You can use the `getfilename` builtin to extract a date, perhaps, but that won't work completely as you say it spans a day.

The special reason that somethin similar doesn't exist for month and day is that no-one asked for it yet :-)

If you don't use any settime, then mtail will use the *current* timestamp, which will be different than the one in the log due to processing delay, but that will get you closer as a workaround.

--
You received this message because you are subscribed to the Google Groups "mtail-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mtail-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mtail-users/2d9a2405-1caa-4b37-a0ef-c460be0d59fcn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages