Logger::Syslog(3pm)

πŸ“¦
version 1.1 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– Logger::Syslog β€” the perl manual page, bestie edition πŸ’–

okay so this is Logger::Syslog(3pm), and it lives in the User Contributed Perl Documentation corner of your system. pull up a chair 🫢


✨ NAME ✨

Logger::Syslog β€” an intuitive wrapper over Syslog for Perl. it's giving "syslog but make it easy" πŸ’…


🌸 DESCRIPTION 🌸

so like. you want to deal with syslog, but you do not want to bother with Sys::Syslog. bestie, this module is for you. no cap.

Logger::Syslog takes care of everything regarding the Syslog communication β€” all you have to do is use the function you need to send a message to syslog. that's it. that's the whole vibe. ✨

and it's so organized too: Logger::Syslog provides one function per Syslog message level β€” debug, info, warning, error, notice, critic, alert. one function per level, iconic behavior honestly πŸ‘‘


πŸ’œ NOTES πŸ’œ

Logger::Syslog is compliant with mod_perl. all you have to do when using it in such an environment is call logger_init() at the beginning of your CGI, and that will garantee that everything will run smoothly. πŸ™ˆ

lowkey important: if you don't do that, issues with the syslog socket can happen in mod_perl env. so like. call it. please. 😭

πŸ¦‹ SYNOPSIS πŸ¦‹

use Logger::Syslog;

info("Starting at ".localtime());
...
if ($error) {
    error("An error occured!");
    exit 1;
}
...
notice("There something to notify");

πŸŽ€ FUNCTIONS πŸŽ€

🌈 logger_init

call this to explicitly open a Syslog socket. you can optionally specify a Syslog facility. ✨

that function is called when you use the module, if you're not in a mod_perl environment.

examples, bestie:

# open a syslog socket with default facility (user)
logger_init();

# open a syslog socket on the 'local' facility
logger_init('local');

🌈 logger_close

call this to close the Syslog socket. 🫢

that function is called automatically when the calling program exits. so it's got your back even when you forget. main character energy.

🌈 logger_prefix

that function lets you set a string that will be prefixed to every message sent to syslog. so cute, so useful.

example:

logger_prefix("my program");
info("starting");
...
info("stopping");

🌈 logger_set_default_facility(facility)

you can choose which facility to use, and the default one is "user". use that function if you want to switch smoothly from a facility to another. ✨

heads up: that function will close the existing socket and will open a new one with the appropriate facility. so it's a whole glow-up, not just a lil tweak πŸ’…

example:

logger_set_default_facility("cron");

⭐ LOGGING ⭐

Logger::Syslog provides one function per Syslog level to let you send messages. want to send a debug message? just use debug(). a warning? use warning(). and so on... iykyk 😌

all those functions have the same signature: thay take a string as their only argument, which is the message to send to syslog.

examples:

debug("my program starts at ".localtime());
...
warning("some strange stuff occured");
...
error("should not go there !");
...
notice("Here is my notice");

πŸ”₯ LICENSE πŸ”₯

this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. periodt. 🫢


this program is copyright 2004-2006 Alexis Sukrieh.


πŸ’– AUTHOR πŸ’–

Alexis Sukrieh <sukria@sukria.net> ✨

very first versions were made at Cegetel (2004-2005); Thomas Parmelan gave a hand for the mod_perl support. shoutout to the OGs 🫑


okay that's the whole page, we ate and left no crumbs πŸ“ this was Logger::Syslog(3pm), rendered with perl v5.38.2, dated 2024-03-06 β€” mwah, love u, go log something responsibly πŸ’…βœ¨

πŸ“¦ where this page comes from