Hello all. Probably lots of faults as I'm new to programming, but what I'm trying to do is get the process pid in the logfile, like this entry:
Jan 19 10:29:09 mgmt yum[26377]: Installed: perl-Unix-Syslog-1.1-3.el6 +.x86_64
I'm using Unix::Syslog to do the logging but I suspect my problem is related to perl rather than that module specifically. My code:
use constant LOGINFO => 'LOG_INFO'; use constant LOGPID => 'LOG_PID'; # Open syslog channel openlog('my-program.pl', @{[ LOGPID ]}, 3); # Daemonise $daemon->Init(); syslog (@{[ LOGINFO ]}, "my-program.pl started and daemonised"); # Run the thing &main_function(); closelog();
But what I get in syslog is this:
Jan 19 17:20:46 mgmt my-program.pl: my-program.pl started and daemonis +ed
..and the following error on starting the program:
Argument "LOG_PID" isn't numeric in subroutine entry at ./my-program.p +l line 66.
It seems it want a numeric value, but is there a numeric value for LOG_PID? Also it seems I should be able to put text in here so I can specify multiple option rather than just one. Any help appreciated. spoov

In reply to Numeric values required in Unix::Syslog? by spoovy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.