summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2019-10-09 14:55:41 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2019-10-09 14:55:41 +0300
commit0a916b8b229d6ffb6d4a1b821221ec16a3b5187f (patch)
treee77e4ee6ee74b5915fb71e53c05c7bff2b17f109
parent3ba18dcf5581f79974ee1aadfe7dca20e2ea6a16 (diff)
downloadmojosyslog-0a916b8b229d6ffb6d4a1b821221ec16a3b5187f.tar.gz
mojosyslog-0a916b8b229d6ffb6d4a1b821221ec16a3b5187f.tar.bz2
Fix to work with Mojolicious 8.25
The version 8.25 introduces the "parent" keyword parameter to the Mojo::Log->new. When present it causes the constructor to return a clone of the parent logger. * lib/Mojo/Log/Syslog.pm (new): Special handling for the "parent" keyword argument. Extract syslog-specific parameters and pass the rest to the parent constructor verbatim.
-rw-r--r--lib/Mojo/Log/Syslog.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/Mojo/Log/Syslog.pm b/lib/Mojo/Log/Syslog.pm
index 3e5992c..87b9013 100644
--- a/lib/Mojo/Log/Syslog.pm
+++ b/lib/Mojo/Log/Syslog.pm
@@ -8,22 +8,24 @@ use Carp;
our $VERSION = '1.01';
sub new {
my $class = shift;
local %_ = @_;
- my $ident = delete $_{ident} || basename($0);
- my $facility = delete $_{facility} || LOG_USER;
- my $level = delete $_{level} || 'debug';
- my $logopt = delete $_{logopt} || 'ndelay,pid';
- if (ref($logopt) eq 'ARRAY') {
- $logopt = join(',', @$logopt);
+
+ $_{level} ||= 'debug';
+ unless ($_{parent}) {
+ my $ident = delete $_{ident} || basename($0);
+ my $facility = delete $_{facility} || LOG_USER;
+ my $logopt = delete $_{logopt} || 'ndelay,pid';
+ if (ref($logopt) eq 'ARRAY') {
+ $logopt = join(',', @$logopt);
+ }
+ openlog($ident, $logopt, $facility);
}
- croak "unrecognized arguments" if keys(%_);
- openlog($ident, $logopt, $facility);
- return $class->SUPER::new(level => $level);
+ return $class->SUPER::new(%_);
}
sub debug { shift->_syslog(debug => LOG_DEBUG => @_) }
sub warn { shift->_syslog(warn => LOG_WARNING => @_) }
sub info { shift->_syslog(info => LOG_INFO => @_) }
sub error { shift->_syslog(error => LOG_ERR => @_) }

Return to:

Send suggestions and report system problems to the System administrator.