Log::Syslog::Native - access to POSIX syslog facility
NAME
Log::Syslog::Native - access to POSIX syslog facility
SYNOPSIS
use Log::Syslog::Native;
my $logger = Log::Syslog::Native.new(facility => Log::Syslog::Native::Mail);
$logger.warning("Couldn't activate wormhole interface");
METHODS
There are provided a number of methods to post a log at a given priority.
All of these can take a sprintf
format and a list of values. The sprintf
may throw an exception if a mismatch between format and supplied values is
detected or if there is an un-recognised %
format code in the format.
Whilst the POSIX syslog
function is documented to be able to accept a
format and a variadic list of values, this is currently emulated with Raku's
builtin sprintf
due to a native call limitation so the acceptable format
string may differ from the system documentation.
The enum
s documented below will need to be used fully qualified with
Log::Syslog::Native::
from user code.
method new
method new(Str :$ident, Int :$option, Facility :$facility)
The constructor for the object. ident
will set the identity field
for the log messages and default to $*PROGRAM-NAME
. option
is the
OR of log option enum values as described below, it defaults to Pid +|
ODelay
which for most purposes should not need changing. facility
is a value of the Facility
enum as described below, it defaults to
Local0
and setting it may, depending on the syslog configuration on
your system, alter how and where the messages are logged to.
enum LogLevel
These correspond to the log priority
and will typically be passed to the
log
method. The exact meaning of the priorites may depend on the
system's logging configuration, but the descriptions come from the syslog.h.
Emergency
System is unusable
Alert
Action must be taken immediately
Critical
Critical conditions
Error
Error conditions
Warning
Warning conditions
Notice
Normal but significant condition
Info
Informational
Debug
Debug-level messages
enum LogFacility
A value of this type may be supplied to the facility
argument of the
constructor, depending on the configuration of the logging system different
values may cause the message to be logged in a different manner. Clearly some
of these refer to actual facilities that may not even exist on a modern
system and may be repurposed if you have access to the configuration.
Kernel
Kernel messages
User
Random user-level messages
Mail
Mail system
Daemon
System daemons
Auth
Security/authorization messages
Syslog
Messages generated internally by syslogd
Lpr
Line printer subsystem
News
Network news subsystem
Uucp
UUCP subsystem
Cron
Clock daemon
Authpriv
Security/authorization messages (private)
Ftp
FTP daemon
Local0
Reserved for local use
Local1
Reserved for local use
Local2
Reserved for local use
Local3
Reserved for local use
Local4
Reserved for local use
Local5
Reserved for local use
Local6
Reserved for local use
Local7
Reserved for local use
enum LogOptions
A binary OR of these values can be passed to the option
argument of the
constructor, though a sensible set of defaults is provided.
Pid
Log the pid with each message
Console
Log on the console if errors in sending
ODelay
Delay open until first syslog() (default)
NDelay
Don't delay open
NoWait
Don't wait for console forks: DEPRECATED
Perror
Log to stderr as well