From f001c1df41a635abbef54785d18bdf530db4d720 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 9 Oct 2019 07:51:51 -0700 Subject: [PATCH] hostap-timestamp can now parse LANforge log timestamps as well. --- hostap_timestamp.pl | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hostap_timestamp.pl b/hostap_timestamp.pl index eb8b2c1c..ea6c817c 100755 --- a/hostap_timestamp.pl +++ b/hostap_timestamp.pl @@ -1,5 +1,7 @@ #!/usr/bin/perl +# Convert LANforge logs and hostapd log timestamps to human readable timestamp. + use POSIX qw( strftime ); while (<>) { @@ -12,6 +14,15 @@ while (<>) { my $dt = strftime("%Y-%m-%d %H:%M:%S", localtime($time_sec)); print "$dt.$usec_pad $rest\n"; } + elsif ($ln =~ /^(\d+): (.*)/) { + my $tot_msec = $1; + my $rest = $2; + my $sec = int($tot_msec / 1000); + my $msec = $tot_msec % 1000; + my $msec_pad = sprintf("%03d", $msec); + my $dt = strftime("%Y-%m-%d %H:%M:%S", localtime($sec)); + print "$dt.$msec_pad $rest\n"; + } else { print $ln; }