mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-19 00:26:03 +00:00
FileLog: reopen renames the file if necessary
git-svn-id: https://svn.fhem.de/fhem/trunk@5044 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
d78dfe1398
commit
ba3854b030
@ -109,12 +109,13 @@ FileLog_Switch($)
|
||||
$fh = new IO::File ">>$cn";
|
||||
if(!defined($fh)) {
|
||||
Log3 $log, 0, "Can't open $cn";
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
$log->{currentlogfile} = $cn;
|
||||
$log->{FH} = $fh;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#####################################
|
||||
@ -198,12 +199,14 @@ FileLog_Set($@)
|
||||
return "$cmd needs $sets{$cmd} parameter(s)" if(@a-$sets{$cmd} != 2);
|
||||
|
||||
if($cmd eq "reopen") {
|
||||
my $fh = $hash->{FH};
|
||||
my $cn = $hash->{currentlogfile};
|
||||
$fh->close();
|
||||
$fh = new IO::File(">>$cn");
|
||||
return "Can't open $cn" if(!defined($fh));
|
||||
$hash->{FH} = $fh;
|
||||
if(!FileLog_Switch($hash)) { # No rename, reopen anyway
|
||||
my $fh = $hash->{FH};
|
||||
my $cn = $hash->{currentlogfile};
|
||||
$fh->close();
|
||||
$fh = new IO::File(">>$cn");
|
||||
return "Can't open $cn" if(!defined($fh));
|
||||
$hash->{FH} = $fh;
|
||||
}
|
||||
|
||||
} elsif($cmd eq "addRegexpPart") {
|
||||
my %h;
|
||||
|
Loading…
x
Reference in New Issue
Block a user