Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Perl Modules

    Tie::Syslog 1.07

    Download button

    No screenshots available
    Downloads: 254  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Broc Seib | More programs
    Perl Artistic License / FREE
    July 18th, 2009, 14:05 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Tie::Syslog description

    Tie a filehandle to Syslog

    Tie::Syslog is a Perl module allows you to tie a filehandle (output only) to syslog. This becomes useful in general when you want to capture any activity that happens on STDERR and see that it is syslogged for later perusal. You can also create an arbitrary filehandle, say LOG, and send stuff to syslog by printing to this filehandle. This module depends on the Sys::Syslog module to actually get info to syslog.

    Tie your filehandle to syslog using a glob to the filehandle. When it is tied to the 'Tie::Syslog' class, you may optionally pass four arguments that determine the behavior of the output bound to syslog.

    You first specify a facility and priority to direct your filehandle traffic to the proper channels in syslog. I suggest reviewing a manpage for syslog on your local system to identify what the facilities and priorities actually are. Nonetheless, this first argument is specified as a string consisting of the facility followed by a dot, followed by the priority. For example, the default setting is 'local0.error'. (Note: I believe Linux uses 'err' rather than 'error'.) If you do not specify a first arg, this default is used.

    The second argument is an identifier string. This is the string that shows up in evey line of output that syslog writes. You may use this identifier to help sort out syslog lines produced by different applications (with different id's.) If you do not specify a value for this argument, it will default to the name of the running program. (This is derived from the special $0 variable, stripping off everything up to the final appearing forward slash character.)

    The third argument is a string of comma separated log options specific to syslog. Current documentation supports 'pid,cons,ndelay,nowait'. Check your local listings, as you may pass values that are only part of your local system. I suggest checking your man pages for syslog, and perhaps looking inside your site_perl/$archname/sys/syslog.ph for other such values. If you do not pass this third argument, it defaults to the string 'pid', which makes syslog put a [12345] pid value on each line of output.

    The fourth argument is either the string 'inet' or 'unix'. This is passed to the Sys::Syslog::setlogsock() call to specify the socket type to be used when opening the connection to syslog. If this argument is not specified, then the default used is 'inet'. Many perl installations still have original Sys::Syslog which does not have the setlogsock() routine. There is also no $VERSION constant to test in Sys::Syslog, so we'll test the symbol table to see if the routine exists. If the routine does not exist, then the fourth argument is silently ignored. I did not want to require people to have "the latest" version of perl just to use this module.

    Note: You can now optionally pass a reference to a Filehandle as the *very* first arg (before the 'Tie::Syslog' even...) The *only* time you'd do this is if you are experiencing trouble using your tied filehandle with other code that expects to do calls like fileno() and binmode() to operate on this tied filehandle. The TIEHANDLE api gives us no way (that I have found) to get access to the actual tied variable, or filehandle in this case. So, I have resorted to just passing it in as a arg right up front and just storing it in the object. **THERE ARE PROBLEMS WITH THIS!!!** Be aware, those of you this may affect...

    SYNOPSIS

     use Tie::Syslog;

     ###
     ## Pass up to four args:
     ## facility.priority ('local0.error') ## note Linux uses 'err'
     ## identity ('my_program')
     ## log options ('pid')
     ## setlogsock ('inet'|'unix')
     ###
     tie *MYLOG, 'Tie::Syslog','local0.error','my_program','pid','inet';

     print MYLOG "I made an error."; ## this will be syslogged
     printf MYLOG "Error %d", 42; ## syslog as "Error 42"

     untie *MYLOG;

     ###
     ## Special case: pass a ref to file glob as first arg.
     ## This stores the filehandle and uses it to implement calls
     ## like fileno() and binmode() etc...
     ###
     tie *STDERR, *STDERR, 'Tie::Syslog','local0.error','my_app','pid','inet';

     ###
     ## yeah, it looks funny, but is the only way...?
     ###



    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Syslog tie | tie filehandle | Perl module | Syslog | filehandle | tie

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM