NAME
No::Worries::Syslog - syslog handling without worries
SYNOPSIS
use No::Worries::Syslog qw(syslog_open syslog_close syslog_info);
# setup/open syslog
syslog_open(ident => "progname", facility => "daemon");
# report an informational message
syslog_info("foo is %s", $foo);
# close syslog
syslog_close();
DESCRIPTION
This module eases syslog handling by providing convenient wrappers around standard syslog functions.
The functions provide a thin layer on top of Sys::Syslog to make it easier and safer to use. All the functions die() on error and the strings passed to syslog will always be sanitized.
FUNCTIONS
This module provides the following functions (none of them being exported by default):
- syslog_open([OPTIONS])
-
open a "connection" to syslog using Sys::Syslog's openlog(); supported options
facility
: corresponding to openlog()'s eponymous argumentident
: corresponding to openlog()'s eponymous argumentoption
: corresponding to openlog()'s eponymous argument
- syslog_close()
-
close a "connection" to syslog using Sys::Syslog's closelog()
- syslog_sanitize(STRING)
-
sanitize the given string so that it can safely be given to syslog(): UTF-8 encode wide characters, trim trailing spaces, replace tabs by spaces, URI escape non-printable characters and truncate if too long
- syslog_debug(MESSAGE)
-
report a sanitized debugging message to syslog (with LOG_DEBUG priority and
[DEBUG]
prefix) - syslog_debug(FORMAT, ARGUMENTS...)
-
idem but with sprintf()-like API
- syslog_info(MESSAGE)
-
report a sanitized informational message to syslog (with LOG_INFO priority and
[INFO]
prefix) - syslog_info(FORMAT, ARGUMENTS...)
-
idem but with sprintf()-like API
- syslog_warning(MESSAGE)
-
report a sanitized warning message to syslog (with LOG_WARNING priority and
[WARNING]
prefix) - syslog_warning(FORMAT, ARGUMENTS...)
-
idem but with sprintf()-like API
- syslog_error(MESSAGE)
-
report a sanitized error message to syslog (with LOG_ERR priority and
[ERROR]
prefix) - syslog_error(FORMAT, ARGUMENTS...)
-
idem but with sprintf()-like API
- log2syslog(INFO)
-
No::Worries::Log handler to send information to syslog; this is not exported and must be called explicitly
GLOBAL VARIABLES
This module uses the following global variables (none of them being exported):
- $MaximumLength
-
maximum length of a message given to syslog (default: 1000)
- $SplitLines
-
true if multi-line messages should be logged as separate syslog messages (default: true)
SEE ALSO
No::Worries, No::Worries::Die, No::Worries::Log, No::Worries::Warn, Sys::Syslog, URI::Escape.
AUTHOR
Lionel Cons http://cern.ch/lionel.cons
Copyright (C) CERN 2012-2019