| 1 |
Unix::Syslog -- Perl interface to the UNIX system logger |
|---|
| 2 |
======================================================== |
|---|
| 3 |
|
|---|
| 4 |
Copyright (C) 1999,2000,2001,2002 Marcus Harnisch |
|---|
| 5 |
|
|---|
| 6 |
Introduction |
|---|
| 7 |
============ |
|---|
| 8 |
|
|---|
| 9 |
This Module provides access to the system logger available on most |
|---|
| 10 |
UNIX system via Perl's XSUBs (Perl's C interface). |
|---|
| 11 |
|
|---|
| 12 |
I wrote this module because of some features I missed in Sys::Syslog |
|---|
| 13 |
(see FAQ below) and also to do my first steps into the secrets of |
|---|
| 14 |
Perl's XSUBs. |
|---|
| 15 |
|
|---|
| 16 |
Copyright and distribution |
|---|
| 17 |
========================== |
|---|
| 18 |
|
|---|
| 19 |
This program is free software; you can redistribute it and/or modify |
|---|
| 20 |
it under the terms of the Artistic License. A copy of the license (see |
|---|
| 21 |
file Artistic in this directory) must be included in the package. |
|---|
| 22 |
|
|---|
| 23 |
Installation |
|---|
| 24 |
============ |
|---|
| 25 |
|
|---|
| 26 |
Unix::Syslog is a Perl module that makes use of XSUBs and hence |
|---|
| 27 |
requires a working C compiler and library. Execute the following |
|---|
| 28 |
commands to install this package (`make test' prints the results of a |
|---|
| 29 |
test suite. Execute `make install' only if the required tests finished |
|---|
| 30 |
successfully or if you know what you are doing): |
|---|
| 31 |
|
|---|
| 32 |
perl Makefile.PL |
|---|
| 33 |
make test |
|---|
| 34 |
make install |
|---|
| 35 |
|
|---|
| 36 |
Notes about the test suite |
|---|
| 37 |
========================== |
|---|
| 38 |
|
|---|
| 39 |
Some of the tests may fail because the respective constants are not |
|---|
| 40 |
available on certain systems. You should be able to distinguish these |
|---|
| 41 |
tests from those that fail because of a malfunction by carefully |
|---|
| 42 |
reading the output of the test routines. |
|---|
| 43 |
|
|---|
| 44 |
The tests that write messages to syslog cannot return a success status |
|---|
| 45 |
since the underlying libc functions don't return appropriate |
|---|
| 46 |
information. To verify that these tests work correctly, you should |
|---|
| 47 |
configure syslogd so that the facility `local7' and priority `info' |
|---|
| 48 |
will be written to a file. |
|---|
| 49 |
|
|---|
| 50 |
OS dependent behaviour and portability |
|---|
| 51 |
====================================== |
|---|
| 52 |
|
|---|
| 53 |
This package uses system specific functions. Programs that uses this |
|---|
| 54 |
package may not be portable in any case. If you plan to write portable |
|---|
| 55 |
code using this package, please consult the manuals of the systems you |
|---|
| 56 |
wish to run the software on. Then modify your program accordingly. |
|---|
| 57 |
|
|---|
| 58 |
As of version 0.99 Unix::Syslog provides two functions priorityname() |
|---|
| 59 |
and facilityname() that return the names of priority and facility, |
|---|
| 60 |
respectively. This functionality is only enabled if an according |
|---|
| 61 |
`#define' is enabled through Makefile.PL. By default this statement is |
|---|
| 62 |
commented out. |
|---|
| 63 |
|
|---|
| 64 |
Known bugs |
|---|
| 65 |
========== |
|---|
| 66 |
|
|---|
| 67 |
OS Description Workaround |
|---|
| 68 |
--------------------------------------------------------------------------- |
|---|
| 69 |
Linux On systems using glibc2 (<= version 2.1), None possible. |
|---|
| 70 |
setting the log mask has no effect. |
|---|
| 71 |
|
|---|
| 72 |
Frequently Asked Questions |
|---|
| 73 |
========================== |
|---|
| 74 |
|
|---|
| 75 |
1. What is the benefit of using this module instead of Sys::Syslog? |
|---|
| 76 |
|
|---|
| 77 |
Sys::Syslog always opens a network connection to the syslog |
|---|
| 78 |
service. At least on Linux systems this may lead to some |
|---|
| 79 |
trouble, because |
|---|
| 80 |
|
|---|
| 81 |
o Linux syslogd (from package sysklogd) does not listen to the |
|---|
| 82 |
network by default. Most people working on stand-alone |
|---|
| 83 |
machines (including me) didn't see any reason why to |
|---|
| 84 |
enable this option. Others didn't enable it for security |
|---|
| 85 |
reasons. |
|---|
| 86 |
|
|---|
| 87 |
OS-independent, some sysadmins may run a firewall on |
|---|
| 88 |
their network that blocks connections to port 514/udp. |
|---|
| 89 |
|
|---|
| 90 |
o By default Linux syslogd doesn't forward messages which have |
|---|
| 91 |
already already received from the network to other log |
|---|
| 92 |
hosts. There are reasons not to enable this option |
|---|
| 93 |
unless it is really necessary. Looping messages |
|---|
| 94 |
resulting from a misconfiguration may break down your |
|---|
| 95 |
(log-)system. |
|---|
| 96 |
|
|---|
| 97 |
Peter Stamfest <peter.stamfest@eunet.at> pointed out some |
|---|
| 98 |
other advantages of Unix::Syslog, I didn't came across my |
|---|
| 99 |
self. |
|---|
| 100 |
|
|---|
| 101 |
o LOG_PERROR works. |
|---|
| 102 |
|
|---|
| 103 |
o works with perl -Tw without warnings and problems due to |
|---|
| 104 |
tainted data as it is the case for Sys::Syslog in some |
|---|
| 105 |
special applications. [Especially when running a script |
|---|
| 106 |
as root] |
|---|
| 107 |
|
|---|
| 108 |
2. Well, is there any reason to use Sys::Syslog any longer? |
|---|
| 109 |
|
|---|
| 110 |
Yes! In contrary to Unix::Syslog, Sys::Syslog works even if |
|---|
| 111 |
you don't have a syslog daemon running on your system as |
|---|
| 112 |
long as you are connected to a log host via a network and |
|---|
| 113 |
have access to the syslog.h header file of your log host to |
|---|
| 114 |
generate the initial files for Sys::Syslog (see |
|---|
| 115 |
Sys::Syslog(3) for details). Unix::Syslog only logs to your |
|---|
| 116 |
local syslog daemon which in turn may be configured to |
|---|
| 117 |
distribute the message over the network. |
|---|
| 118 |
|
|---|
| 119 |
3. Are calls to the functions provided by Unix::Syslog compatible |
|---|
| 120 |
to those of Sys::Syslog? |
|---|
| 121 |
|
|---|
| 122 |
Currently not. Sys::Syslog requires strings to specify many |
|---|
| 123 |
of the arguments to the functions, while Unix::Syslog uses |
|---|
| 124 |
numeric constants accessed via macros as defined in |
|---|
| 125 |
syslog.h. Although the strings used by Sys::Syslog are also |
|---|
| 126 |
defined in syslog.h, it seems that most people got used to |
|---|
| 127 |
the numeric arguments. I will implement the string based |
|---|
| 128 |
calls if there are enough people ($min_people > 10**40) |
|---|
| 129 |
complaining about the lack of compatibility. |
|---|
| 130 |
|
|---|
| 131 |
Comments, Bug reports and Suggestions |
|---|
| 132 |
===================================== |
|---|
| 133 |
|
|---|
| 134 |
Please direct anything you wish to tell me about this package to the |
|---|
| 135 |
address given below. |
|---|
| 136 |
|
|---|
| 137 |
Have fun, |
|---|
| 138 |
Marcus Harnisch <marcus.harnisch@gmx.net> |
|---|