diff options
author | Yorhel <git@yorhel.nl> | 2020-12-25 13:42:41 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2020-12-25 13:42:41 +0100 |
commit | dd18ccc27c55c870fa403fa56a1b098b5a12fc18 (patch) | |
tree | 3be3215c40e9fe81d6ee5b716d0f18f5b8ca5c09 | |
parent | f68842f87baf3023836518712815c4f451b0db41 (diff) |
Fix logging during initialization
-rw-r--r-- | lib/TUWF.pm | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/TUWF.pm b/lib/TUWF.pm index f460306..fa80f58 100644 --- a/lib/TUWF.pm +++ b/lib/TUWF.pm @@ -516,13 +516,15 @@ sub capture { # writes a message to the log file. date, time and URL are automatically added +our $_recursive_log = 0; sub log { my($self, $msg) = @_; # temporarily disable the warnings-to-log, to avoid infinite recursion if # this function throws a warning. - my $recursive = !defined $SIG{__WARN__}; + my $recursive = $_recursive_log; local $SIG{__WARN__} = undef; + local $_recursive_log = 1; my $uri = $self->{_TUWF}{Req} ? $self->reqURI : '[init]'; chomp $msg; @@ -537,8 +539,8 @@ sub log { flock $F, 4; close $F; } - # Also always dump stuff to STDERR if we're running a standalone HTTP server. - warn $msg if $self->{_TUWF}{http}; + # Also always dump stuff to STDERR during init or if we're running a standalone HTTP server. + warn $msg if $self->{_TUWF}{http} || !$self->{_TUWF}{Req}; } |