Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Sys::Syslog and LOG_EMERG

by Crackers2 (Parson)
on Aug 11, 2006 at 23:04 UTC ( [id://566972]=note: print w/replies, xml ) Need Help??


in reply to Sys::Syslog and LOG_EMERG

In short, RTFM...
From the Sys::Syslog POD

=head1 SYNOPSIS use Sys::Syslog; # all except setlogsock( +), or: use Sys::Syslog qw(:DEFAULT setlogsock); # default set, plus setl +ogsock() use Sys::Syslog qw(:standard :macros); # standard functions, pl +us macros setlogsock $sock_type; openlog $ident, $logopt, $facility; # don't forget this syslog $priority, $format, @args; $oldmask = setlogmask $mask_priority; closelog;

Note the line marked "don't forget this"

Basically, when logging to syslog you need both a priority and a facility. The command-line logger tool defaults to "user" as facility, but Sys::Syslog apparently does not, so you need the openlog call to set the facility.

Update: Actually adding openlog doesn't seem to fix it, so that wasn't much help I'm afraid.

Replies are listed 'Best First'.
Re^2: Sys::Syslog and LOG_EMERG
by pileofrogs (Priest) on Aug 11, 2006 at 23:13 UTC

    hmmm... nice guess, but it still doesn't work.

    The code:

    use Sys::Syslog qw(:standard :macros); openlog('foo', '', 'user'); syslog(LOG_EMERG,"%s","Foo");

    ...produces the same error.

      Looks like a real bug in Sys::Syslog. Below the code from Syslog.pm around line 632:

      if ($_ eq 'kern' || $num <= 0) { croak "syslog: invalid level/facility: $_" }

      Changing this to

      if ($_ eq 'kern' || $num < 0) { croak "syslog: invalid level/facility: $_" }

      makes the code work for me.

      Update:Of course that change means you won't get an error message anymore if you forget to specify a priority (e.g. syslog(LOG_USER,"test")). I'm sure someone will come up with the right solution though.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://566972]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2024-04-18 03:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found