Bug 161331
Summary: | perl sys::syslog formatting bug | ||
---|---|---|---|
Product: | Red Hat Enterprise Linux 3 | Reporter: | Tru Huynh <pasteur> |
Component: | perl | Assignee: | Jason Vas Dias <jvdias> |
Status: | CLOSED NOTABUG | QA Contact: | David Lawrence <dkl> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 3.0 | CC: | perl-devel |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | x86_64 | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2005-11-03 00:08:12 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Tru Huynh
2005-06-22 14:39:31 UTC
perldoc Sys::Syslog ... openlog $ident, $logopt, $facility; ... openlog $ident, $logopt, $facility $ident is prepended to every message. $logopt contains zero or more of the words pid, ndelay, nowait. The cons option is ignored, since the failover mechanism will drop down to the console automat- ically if all other media fail. $facility specifies the part of the system here $ident is DEFINED and set as en empty string ("") but tested as non-empty instead of undefined... upstream ? You are saying this is an issue in RHEL4 perl too? What about FC4? yes, RHEL4 has the same issue perl-5.8.5-12.1.x86_64 I don't have any FC4 installed to try on, sorry. 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. |