NAME

Solaris::DevLog - Read from a Solaris Syslog stream

SYNOPSIS

  use Solaris::DevLog;
  my $devlog = new Solaris::DevLog();

  while (1) (
    # block until a message is available
    $devlog->select(undef);

    # get the message
    my ($status, $ctl, $msg) = $devlog->getmsg();
    print "Message priority $ctl->{pri}: $msg\n"
      unless $status;
  }

DESCRIPTION

Solaris::DevLog facilitates the reading of syslog messages via Solaris streams, and supports the syslog door mechanism.

See example.pl for a working example.

ATTRIBUTES

The DevLog class has the following attributes. See the section below on getting/setting these attributes.

stream_path the path to log stream (eg. /dev/log)
door_fd the path to the door file
stream_fd the file descriptor for the log stream
door_fd the file descriptor for the door

CREATING AND INITIALIZING AN INSTANCE

    use DevLog;
    my $path = '/dev/log';
    my $door = '/etc/.syslog_door';
    my $devlog = new DevLog ($path, $door);

The constructor takes the path to the log device and the path the door file. If these are omitted, the values shown above are used.

METHODS

GET A MESSAGE

  my ($status, $ctl, $msg) = $devlog->getmsg();
  print "log message was $msg\n";
  print "priority was $ctl->{pri}\n";

Gets the next available message on the log stream. Returns:

  • status integer as returned by the system call getmsg

  • ctl hash reference containing the fields of the log_ctl structure:

    -

    mid ID number of the module or driver submitting the message

    -

    sid ID number for a particular minor device

    -

    level Tracing level for selective screening

    -

    flags Message disposition. See strlog

    -

    ltime Time in machine ticks since boot

    -

    ttime Time in seconds since 1970

    -

    seq_no Sequence number

    -

    pri Priority = (facility|level)

  • msg string containing the log message

SELECT

  my $timeout = undef;
  my ($nfound) = $devlog->select($timeout);

This method works like the select system call on the log stream. The timeout argument works as described for select; set it to undef to block, or give it a timeout in seconds to poll.

FLAGS

The following flag values from stdlog.h are available, and can be imported with the 'flags' tag:

  use Solaris::DevLog qw(:flags);

  SL_FATAL        # 0x01    indicates fatal error 
  SL_NOTIFY       # 0x02    logger must notify administrator 
  SL_ERROR        # 0x04    include on the error log 
  SL_TRACE        # 0x08    include on the trace log 
  SL_CONSOLE      # 0x10    include on the console log 
  SL_WARN         # 0x20    warning message 
  SL_NOTE         # 0x40    notice message 

SET THE DEBUGGING LEVEL

    my $flags = {Create->1, Trace->1};
    Solaris::DevLog::debug($flags);
    -or-
    $devlog->debug($flags);

The debug method may be called as a class or instance method; calling it as a class method will affect all objects created after the call. It takes a hash ref which defines the state of debugging flags. The currently defined debugging flags are:

   Trace: prints warnings when calling methods
   Create: prints warnings when creating/destroying instances

GET/SET AN ATTRIBUTE

    $value = $devlog-><attribute_name>();
    -or-
    $newvalue = $devlog-><attribute_name>($newvalue);

Attributes of objects of this class and subclasses can be accessed via a generic autoloaded accessor method. To get the value of an attribute, call the method with the same name. To set an attribute, or create a new one, supply the value as an argument.

Note: attributes are stored in a subhash of the object named "Data", to avoid potential collisions with required and utility methods.

EXAMPLE

  use DevLog;
  my @initial_values = ("some value");
  my $object = new DevLog (@initial_values);
  print $object->attribute_1('a new value');

AUTHOR

Greg Bossert <bossert@fuaim.com>, <greg@netzwert.ag>

Special thanks to Netzwert AG <http://www.netzwert.ag> for supporting the development of this module.

SEE ALSO

getmsg (Solaris).

strlog (Solaris).

COPYRIGHT AND LICENCE

Copyright (c) 2002 Greg Bossert

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