98_FhemTestUtils.pm: add FhemTestUtils_getLogTime (Forum #111061)

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@22660 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2020-08-24 10:17:42 +00:00
parent fc9dcaee2b
commit 0ae4de0126

View File

@ -73,6 +73,22 @@ FhemTestUtils_resetLogs()
@logs=();
}
sub
FhemTestUtils_getLogTime
{
my $arg = shift;
foreach my $line (@logs) {
if($line =~ m/^([0-9\.]+ [0-9:\.]+)\s.*$arg/ms) {
my @a = split("[\. :]", $1);
my $time = mktime($a[5],$a[4],$a[3],$a[2],$a[1]-1,$a[0]-1900,0,0,-1);
$time += $a[6]/1000 if(@a == 7); # attrg global mseclog is active
return $time;
}
}
return;
}
1;
@ -99,6 +115,9 @@ FhemTestUtils_resetLogs()
Return the logs matching the regexp argument (with grep).
Note, that loglevel filtering with verbose ist still active.
</li>
<li>FhemTestUtils_getLogTime($)<br>
Return the timestamp of the first log matching the argument.
</li>
<li>FhemTestUtils_resetEvents()<br>
Reset the internal event buffer.
</li>