[Opendnssec-develop] Embedded scripts can replace syslog()
Rick van Rein
rick at openfortress.nl
Fri Aug 28 10:45:08 UTC 2009
Hello Stephen and others,
Attached is a small demonstration program that I set up to enable more
flexible (and more reliable) logging than through ssyslog().
This is a drop-in replacement for syslog() calls, with just a single
extra call for opening a Python script with a user-settable odlog()
function. The rest of the code diverts the syslog()-replacing odlog()
calls to Python.
I tried using a setup with embedded Ruby, but Ruby does not seem to
be mature enough to have such a facility. So I used Python instead,
apologising for emphasising that (build-time) dependency.
The use is simple enough, only the log script path should be set with
an option like --logscript. Example use:
int main (int argc, char *argv []) {
odlog (LOG_INFO, "This appears through syslog");
odlogscript ("demolog");
odopenlog ("odlogdemo", LOG_NDELAY, LOG_DAEMON);
odlog (LOG_INFO, "Now the Python script has started to work");
odlog (LOG_EMERG, "All Hell Just Broke Loose");
odcloselog ();
odlog (LOG_INFO, "And now we're back to plain syslog behaviour");
}
Further code is attached. Just make, set PYTHONPATH=. and run ./odlogdemo
A build requirement is a python-devel package of some kind. Works on Linux.
Enjoy,
-Rick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: syslog-embedded.tgz
Type: application/x-gtar
Size: 3197 bytes
Desc: not available
URL: <http://lists.opendnssec.org/pipermail/opendnssec-develop/attachments/20090828/47148d02/attachment.gtar>
More information about the Opendnssec-develop
mailing list