Possibility to modify Syslog options (#2251)

This commit is contained in:
Clément OUDOT 2020-06-25 10:52:07 +02:00
parent 196ef49ca4
commit f806e82849
2 changed files with 6 additions and 2 deletions

View File

@ -69,7 +69,9 @@ logLevel = warn
; For Syslog logging, you can also overwrite facilities. Default values:
;logger = Lemonldap::NG::Common::Logger::Syslog
;syslogFacility = daemon
;syslogOptions = cons,pid,ndelay
;userSyslogFacility = auth
;userSyslogOptions = cons,pid,ndelay
;
; 2.2 - Using Log4perl
;

View File

@ -3,7 +3,7 @@ package Lemonldap::NG::Common::Logger::Syslog;
use strict;
use Sys::Syslog qw(:standard);
our $VERSION = '2.0.5';
our $VERSION = '2.0.9';
sub new {
my ( $class, $conf, %args ) = @_;
@ -11,11 +11,13 @@ sub new {
my $self = bless {}, $class;
if ( $args{user} ) {
$self->{facility} = $conf->{userSyslogFacility} || 'auth';
$self->{options} = $conf->{userSyslogOptions} || 'cons,pid,ndelay';
}
else {
$self->{facility} = $conf->{syslogFacility} || 'daemon';
$self->{options} = $conf->{syslogOptions} || 'cons,pid,ndelay';
}
eval { openlog( 'LLNG', 'cons,pid,ndelay', $self->{facility} ) };
eval { openlog( 'LLNG', $self->{options}, $self->{facility} ) };
no warnings 'redefine';
my $show = 1;
foreach (qw(error warn notice info debug)) {