The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Log::Dispatch::UnixSyslog - log events to syslog with Unix::Syslog

VERSION

version 0.002

SYNOPSIS

  use Log::Dispatch;
  use Log::Dispatch::UnixSyslog;

  my $log = Log::Dispatch->new;

  $log->add(
    Log::Dispatch::UnixSyslog->new(
      ident => 'super-cool-daemon',
      min_level => 'debug',
      flush_if  => sub { (shift)->event_count >= 60 },
    )
  );

  while (@events) {
    $log->warn($_);
  }

DESCRIPTION

This provides a Log::Dispatch log output plugin that sends things to syslog. "But there's already Log::Dispatch:Syslog!" you cry. Well, that uses Sys::Syslog, which is core, but it's overcomplicated and inefficient, too. This plugin uses Unix::Syslog, which does a lot less, and should be more efficient at doing it.

PERL VERSION

This module should work on any version of perl still receiving updates from the Perl 5 Porters. This means it should work on any version of perl released in the last two to three years. (That is, if the most recently released version is v5.40, then this module should work on both v5.40 and v5.38.)

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

METHODS

new

 my $output = Log::Dispatch::UnixSyslog->new(\%arg);

This method constructs a new Log::Dispatch::UnixSyslog output object. In addition to the standard parameters documented in Log::Dispatch::Output, this takes the following arguments:

  ident     - a string to prepend to all messages in the system log; required
  facility  - which syslog facility to log to (as a string); required
  logopt    - the numeric value of the openlog options parameter; (default: 0)

log_message

This is the method which performs the actual logging, as detailed by Log::Dispatch::Output.

AUTHOR

Ricardo SIGNES <cpan@semiotic.systems>

CONTRIBUTOR

Ricardo Signes <rjbs@semiotic.systems>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Ricardo SIGNES.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.