.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Logger::Syslog 3pm" .TH Logger::Syslog 3pm 2024-03-06 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Logger::Syslog \-\- an intuitive wrapper over Syslog for Perl .SH DESCRIPTION .IX Header "DESCRIPTION" You want to deal with syslog, but you don't want to bother with Sys::Syslog, that module is for you. .PP Logger::Syslog takes care of everything regarding the Syslog communication, all you have to do is to use the function you need to send a message to syslog. .PP Logger::Syslog provides one function per Syslog message level: debug, info, warning, error, notice, critic, alert. .SH NOTES .IX Header "NOTES" Logger::Syslog is compliant with mod_perl, all you have to do when using it in such an environment is to call \fBlogger_init()\fR at the beginning of your CGI, that will garantee that everything will run smoothly (otherwise, issues with the syslog socket can happen in mod_perl env). .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Logger::Syslog; \& \& info("Starting at ".localtime()); \& ... \& if ($error) { \& error("An error occured!"); \& exit 1; \& } \& ... \& notice("There something to notify"); .Ve .SH FUNCTIONS .IX Header "FUNCTIONS" .SS logger_init .IX Subsection "logger_init" Call this to explicitly open a Syslog socket. You can optionally specify a Syslog facility. .PP That function is called when you use the module, if you're not in a mod_perl environment. .PP Examples: .PP .Vb 2 \& # open a syslog socket with default facility (user) \& logger_init(); \& \& # open a syslog socket on the \*(Aqlocal\*(Aq facility \& logger_init(\*(Aqlocal\*(Aq); .Ve .SS logger_close .IX Subsection "logger_close" Call this to close the Syslog socket. .PP That function is called automatically when the calling program exits. .SS logger_prefix .IX Subsection "logger_prefix" That function lets you set a string that will be prefixed to every messages sent to syslog. .PP Example: .PP .Vb 4 \& logger_prefix("my program"); \& info("starting"); \& ... \& info("stopping"); .Ve .SS logger_set_default_facility(facility) .IX Subsection "logger_set_default_facility(facility)" You can choose which facility to use, the default one is "user". Use that function if you want to switch smoothly from a facility to another. .PP That function will close the existing socket and will open a new one with the appropriate facility. .PP Example: .PP .Vb 1 \& logger_set_default_facility("cron"); .Ve .SH LOGGING .IX Header "LOGGING" Logger::Syslog provides one function per Syslog level to let you send messages. If you want to send a debug message, just use \fBdebug()\fR, for a warning, use \&\fBwarning()\fR and so on... .PP All those function have the same signature : thay take a string as their only argument, which is the message to send to syslog. .PP Examples: .PP .Vb 7 \& debug("my program starts at ".localtime()); \& ... \& warning("some strange stuff occured"); \& ... \& error("should not go there !"); \& ... \& notice("Here is my notice"); .Ve .SH LICENSE .IX Header "LICENSE" This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .SH COPYRIGHT .IX Header "COPYRIGHT" This program is copyright 2004\-2006 Alexis Sukrieh .SH AUTHOR .IX Header "AUTHOR" Alexis Sukrieh .PP Very first versions were made at Cegetel (2004\-2005) ; Thomas Parmelan gave a hand for the mod_perl support.