Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.56 and Syslog.pm - unable to catch the die #20

Open
targzeta opened this issue Jul 20, 2016 · 1 comment
Open

Version 2.56 and Syslog.pm - unable to catch the die #20

targzeta opened this issue Jul 20, 2016 · 1 comment

Comments

@targzeta
Copy link

targzeta commented Jul 20, 2016

Hi, on commit 13e4bcc you had ignored the die signal before any Sys::Syslog call (row 98 of the file Syslog.pm).

For me is critical to know if a message has been written by the syslogd (I have to produce legal logs).

See this little snippet of code:

use Log::Log4perl;

sub DIE_handler() {
  print 'DIE Handler - ' . "@_";

  exit(1);
}

sub main() {
  my $conf = q(
    log4perl.rootLogger=TRACE, syslog

    log4perl.appender.syslog = Log::Dispatch::Syslog
    log4perl.appender.syslog.facility = mail
    log4perl.appender.syslog.socket.type = tcp
    log4perl.appender.syslog.socket.port = 514
    log4perl.appender.syslog.layout = Log::Log4perl::Layout::SimpleLayout
  );

  Log::Log4perl::init(\$conf);

  my $logger = Log::Log4perl::get_logger();

  $SIG{__DIE__} = \&DIE_handler;
  $logger->trace('TRACE');

  print "Log message has been written!\n";
}

main();

My syslog appender is setted on TCP:514. Now, If I shut down the syslogd, with v2.54 I correctly have:

DIE Handler - no connection to syslog available
        - tcp connect: Connection refused at /opt/perl/lib/site_perl/5.16.3/Log/Dispatch/Syslog.pm line 109.

with v2.56 conversely:

Log message has been written!

As you can see, with the v2.56 my code says that the log message has been written, but it isn't true because the syslogd were down!

I think that this is a regression even because as the Sys::Syslog man page says, If we want to ignore the die, we can use the nofatal option:

nofatal - When set to true, openlog() and syslog() will only emit warnings instead of dying if the connection to the syslog can't be established.

Thank you in advance,
Emanuele

@autarch
Copy link
Member

autarch commented Aug 14, 2016

This change came from #18 with some additional massaging. I think the idea was that logging often gets done in error handlers, and having the loggin itself throw an error set $@ can cause a lot of problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants