Please do not reply directly to this email. All additional
comments should be made in the comments box of this bug report.
Summary: perl sys::syslog formatting bug
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=161331
jvdias(a)redhat.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |CLOSED
Resolution| |NOTABUG
------- Additional Comments From jvdias(a)redhat.com 2005-11-02 19:08 EST -------
Yes, this happens in all currently shipped Red Hat perl versions .
I'm not sure this is really a bug - the 'man Sys::Syslog' man-page states:
"
openlog $ident, $logopt, $facility
...
syslog $priority, $format, @args
...
If you didn’t use openlog() before using syslog(), syslog
will try to guess the $ident by extracting the shortest prefix
of $format that ends in a ":".
"
So what is happening is that since you specified no 'ident' for openlog,
Syslog.pm tries to extract the ident from the message, and thinks it is ':'.
The "ident" is then used to prefix the message, ie. is the message
'tag',
followed by ": " .
The 'tag' field is not optional, as shown by the prototype of the c
openlog call:
void openlog(const char *ident, int option, int facility);
The string pointed to by ident is prepended to every message, and is
typically set to the program name, and if the LOG_PID option is supplied,
it will be suffixed with the process id in brackets, to form the usual
syslog tag of 'program[pid]:' .
There are several ways to workaround this situation :
1. Provide an "ident" to openlog - eg., in your example:
$ perl -e 'use Sys::Syslog; openlog $0, "", ""; syslog
"info", "::a"; closelog;'
This would emit the syslog line:
<date> <host> -e: ::a
Usually $0 will be the name of the script, which is '-e' for perl command line
expressions .
2. Use a proper printf format as the second argument to syslog:
$ perl -e 'use Sys::Syslog; syslog "info", "%s",
"::a";'
logs the line:
<date> <host> <user>: ::a
The openlog is optional, meaning that syslog will open a log socket for you.
Unless Sys::Syslog were to arbitrarily disallow an 'ident' value of ':',
(which could be an executable file name), it cannot fix this bug and
still provide the feature of embedding the ident tag in the message.
So this is not a bug - use one of the workarounds given above.
--
Configure bugmail:
https://bugzilla.redhat.com/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.