The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Net::Frame::Layer::Syslog - Syslog layer object

SYNOPSIS

   use Net::Frame::Simple;
   use Net::Frame::Layer::Syslog qw(:consts);

   my $layer = Net::Frame::Layer::Syslog->new(
      facility  => NF_SYSLOG_FACILITY_LOCAL7,
      severity  => NF_SYSLOG_SEVERITY_INFORMATIONAL,
      timestamp => (current time MMM DD HH:MM:SS),
      host      => (hostname),
      tag       => ($0[$$]),
      content   => 'syslog message',
   );

   #
   # Read a raw layer
   #

   my $layer = Net::Frame::Layer::Syslog->new(raw => $raw);

   print $layer->print."\n";
   print 'PAYLOAD: '.unpack('H*', $layer->payload)."\n"
      if $layer->payload;

DESCRIPTION

This modules implements the encoding and decoding of the Syslog layer.

RFC: ftp://ftp.rfc-editor.org/in-notes/rfc3164.txt

See also Net::Frame::Layer for other attributes and methods.

ATTRIBUTES

facility

Syslog facility. See CONSTANTS for more information.

severity

Syslog severity. See CONSTANTS for more information.

timestamp

Timestamp. Default is set to current time in format: MMM DD HH:MM:SS

host

Hostname. Default is set to current host.

tag

Tag. Default is set to: program_name[process_id]

content

Syslog message.

The following are inherited attributes. See Net::Frame::Layer for more information.

raw
payload
nextLayer

METHODS

new
new (hash)

Object constructor. You can pass attributes that will overwrite default ones. See SYNOPSIS for default values.

  <###>Mmm dd hh:mm:ss hostname tag content
  |___||_____________| |______| |_________|
    |     Timestamp    Hostname   Message
    |
   Priority -> (facility and severity)
message
message (hash)

Object constructor. Same as new but only takes message as input. Value of message is the entire Syslog message. This allows custom messages that do not follow strict RFC 3164 guidelines. Default message is same as constructed with new.

The following are inherited methods. Some of them may be overriden in this layer, and some others may not be meaningful in this layer. See Net::Frame::Layer for more information.

layer
computeLengths
pack
unpack
encapsulate
getLength
getPayloadLength
print
dump

USEFUL SUBROUTINES

Load them: use Net::Frame::Layer::Syslog qw(:subs);

priorityAton (facility, severity)

Takes Syslog facility and severity and returns priority.

priorityNtoa (priority [,1])

Takes Syslog priority and returns numeric facility and severity. Optional flag returns facility and severity names.

   my ($facility, $severity) = priorityNtoa( ... )

CONSTANTS

Load them: use Net::Frame::Layer::Syslog qw(:consts);

NF_SYSLOG_FACILITY_KERNEL
NF_SYSLOG_FACILITY_USER
NF_SYSLOG_FACILITY_MAIL
NF_SYSLOG_FACILITY_SYSTEM
NF_SYSLOG_FACILITY_SECURITY
NF_SYSLOG_FACILITY_INTERNAL
NF_SYSLOG_FACILITY_PRINTER
NF_SYSLOG_FACILITY_NEWS
NF_SYSLOG_FACILITY_UUCP
NF_SYSLOG_FACILITY_CLOCK
NF_SYSLOG_FACILITY_SECURITY2
NF_SYSLOG_FACILITY_FTP
NF_SYSLOG_FACILITY_NTP
NF_SYSLOG_FACILITY_AUDIT
NF_SYSLOG_FACILITY_ALERT
NF_SYSLOG_FACILITY_CLOCK2
NF_SYSLOG_FACILITY_LOCAL0
NF_SYSLOG_FACILITY_LOCAL1
NF_SYSLOG_FACILITY_LOCAL2
NF_SYSLOG_FACILITY_LOCAL3
NF_SYSLOG_FACILITY_LOCAL4
NF_SYSLOG_FACILITY_LOCAL5
NF_SYSLOG_FACILITY_LOCAL6
NF_SYSLOG_FACILITY_LOCAL7

Syslog facilities.

NF_SYSLOG_SEVERITY_EMERGENCY
NF_SYSLOG_SEVERITY_ALERT
NF_SYSLOG_SEVERITY_CRITICAL
NF_SYSLOG_SEVERITY_ERROR
NF_SYSLOG_SEVERITY_WARNING
NF_SYSLOG_SEVERITY_NOTICE
NF_SYSLOG_SEVERITY_INFORMATIONAL
NF_SYSLOG_SEVERITY_DEBUG

Syslog severities.

SEE ALSO

Net::Frame::Layer

AUTHOR

Michael Vincent

COPYRIGHT AND LICENSE

Copyright (c) 2012, Michael Vincent

You may distribute this module under the terms of the Artistic license. See LICENSE.Artistic file in the source distribution archive.