Skip Menu |

This queue is for tickets about the Unix-Syslog CPAN distribution.

Report information
The Basics
Id: 4611
Status: rejected
Priority: 0/
Queue: Unix-Syslog

People
Owner: Nobody in particular
Requestors: joshua.groom [...] ird.govt.nz
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: syslogging a '%'
Hi, I have been using Unix::Syslog for about 6 months now with no problems but I have found something which causes it to die. running the code: #!/usr/bin/perl use Unix::Syslog qw(:macros); use Unix::Syslog qw(:subs); openlog('test', 'pid', LOG_LOCAL0); syslog(LOG_INFO,"% n"); causes: Modification of a read-only value attempted at /usr/local/lib/perl/5.8.0/Unix/Syslog.pm line 58. This happened both on a solaris 9 machine and a linux machine running 2.4.22 both with perl 5.8.0 both using Unix::Syslog 0.100 I realise that this is an odd thing to print with syslog. I encountered it when I was printing out lines from a file to syslog... Cheers.
On Di. 09. Dez. 2003, 02:03:34, guest wrote: Show quoted text
> Hi, > I have been using Unix::Syslog for about 6 months now with no problems > but I have found something which causes it to die. > > running the code: > #!/usr/bin/perl > use Unix::Syslog qw(:macros); > use Unix::Syslog qw(:subs); > openlog('test', 'pid', LOG_LOCAL0); > syslog(LOG_INFO,"% n"); > > causes: > Modification of a read-only value attempted at > /usr/local/lib/perl/5.8.0/Unix/Syslog.pm line 58. > > > This happened both on a solaris 9 machine and a linux machine running > 2.4.22 both with perl 5.8.0 both using Unix::Syslog 0.100 > > I realise that this is an odd thing to print with syslog. I > encountered it when I was printing out lines from a file to syslog... > > > Cheers.
From: Marcus Harnisch
On Thu May 18 05:23:04 2006, guest wrote: Show quoted text
> > I have been using Unix::Syslog for about 6 months now with no problems
Glad to hear that. Thanks. Show quoted text
> > but I have found something which causes it to die. > > > > running the code: > > #!/usr/bin/perl > > use Unix::Syslog qw(:macros); > > use Unix::Syslog qw(:subs); > > openlog('test', 'pid', LOG_LOCAL0); > > syslog(LOG_INFO,"% n");
Remember that the second argument to syslog(3) is a format string, such as the ones used in printf(), etc. `%' is special in format strings. To print a literal string such as the one above you should use syslog(LOG_INFO, "%s", "% n"); instead. Show quoted text
> > I realise that this is an odd thing to print with syslog. I > > encountered it when I was printing out lines from a file to syslog...
It's not just odd, it is an illegal format string. I agree, that the error message could be more helpful though. But that's an issue with the sprintf() routine used internally by Unix::Syslog, not with the module itself. Hope that helps. Thanks for using Unix::Syslog -- Marcus
I guess I've never closed that bug. Oh, in the spirit of Larry Wall that there is always more than one solution to a problem you could also write: syslog(LOG_INFO, "%% n"); Regards, Marcus