mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-03-10 09:16:53 +00:00
92_FileLog.pm: add clear command (Forum #64655)
git-svn-id: https://svn.fhem.de/fhem/trunk@13069 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
6e5e23d67a
commit
89d5e5af53
@ -256,7 +256,8 @@ FileLog_Set($@)
|
||||
my $me = $hash->{NAME};
|
||||
|
||||
return "no set argument specified" if(int(@a) < 2);
|
||||
my %sets = (reopen=>0, absorb=>1, addRegexpPart=>2, removeRegexpPart=>1);
|
||||
my %sets = (reopen=>0, clear=>0, absorb=>1, addRegexpPart=>2,
|
||||
removeRegexpPart=>1);
|
||||
|
||||
my $cmd = $a[1];
|
||||
if(!defined($sets{$cmd})) {
|
||||
@ -267,12 +268,16 @@ FileLog_Set($@)
|
||||
}
|
||||
return "$cmd needs $sets{$cmd} parameter(s)" if(@a-$sets{$cmd} != 2);
|
||||
|
||||
if($cmd eq "reopen") {
|
||||
if(($cmd eq "reopen") or ($cmd eq "clear")) {
|
||||
if(!FileLog_Switch($hash)) { # No rename, reopen anyway
|
||||
my $fh = $hash->{FH};
|
||||
my $cn = $hash->{currentlogfile};
|
||||
$fh->close();
|
||||
$fh = new IO::File(">>$cn");
|
||||
if($cmd eq "clear") {
|
||||
$fh = new IO::File(">$cn");
|
||||
} else {
|
||||
$fh = new IO::File(">>$cn");
|
||||
}
|
||||
return "Can't open $cn" if(!defined($fh));
|
||||
$hash->{FH} = $fh;
|
||||
}
|
||||
@ -1137,6 +1142,11 @@ FileLog_regexpFn($$)
|
||||
logfile.
|
||||
</ul>
|
||||
</li>
|
||||
<li>clear
|
||||
<ul>
|
||||
Clears and reopens the logfile.
|
||||
</ul>
|
||||
</li>
|
||||
<li>addRegexpPart <device> <regexp>
|
||||
<ul>
|
||||
add a regexp part, which is constructed as device:regexp. The parts
|
||||
@ -1432,6 +1442,10 @@ FileLog_regexpFn($$)
|
||||
Erneutes Öffnen eines FileLogs nach händischen
|
||||
Änderungen in dieser Datei.
|
||||
</ul></li>
|
||||
<li>clear
|
||||
<ul>
|
||||
Löschen und erneutes Öffnen eines FileLogs.
|
||||
</ul></li>
|
||||
<li>addRegexpPart <device> <regexp>
|
||||
<ul>
|
||||
Fügt ein regexp Teil hinzu, der als device:regexp aufgebaut ist.
|
||||
|
Loading…
x
Reference in New Issue
Block a user