Watchdog::Base - Watchdog base class


Watchdog documentation Contained in the Watchdog distribution.

Index


Code Index:

NAME

Top

Watchdog::Base - Watchdog base class

SYNOPSIS

Top

  use Watchdog::Base;

DESCRIPTION

Top

Watchdog::Base is the Watchdog base class.

CLASS METHODS

Top

new($name,$host,$port,$file)

Returns a new Watchdog::Base object. $name is a string which will identify the service to a human. $host is the name of the host providing the service (default is 'localhost'). $port is the port on which the service listens.

OBJECT METHODS

Top

id()

Return a string describing the name of a service and the host (and optionally the port) on which it runs.

AUTHOR

Top

new Maintainer: Clemens Gesell <clemens.gesell@vegatron.org>

Paul Sharpe <paul@miraclefish.com>

COPYRIGHT

Top


Watchdog documentation Contained in the Watchdog distribution.
package Watchdog::Base;

use strict;
use Alias;
use base qw(Watchdog::Util);
use vars qw($VERSION $NAME $HOST $PORT $FILE);

$VERSION = '0.09';

my %fields = (
	      NAME    => undef,
	      HOST    => 'localhost',
	      PORT    => undef,
	      FILE    => '',
);

sub new($$$) {
  my $DEBUG = 0;
  my $proto = shift;
  my $class = ref($proto) || $proto;
  my $self  = bless { _PERMITTED => \%fields, %fields, },$class;
  attr $self;

  print STDERR "Watchdog::Base::new() $NAME $HOST $PORT $FILE\n" if $DEBUG;
  my $arg;
  for (\$NAME,\$HOST,\$PORT,\$FILE) {
    $$_ = $arg if $arg = shift;
  }
  print STDERR "Watchdog::Base::new() $NAME $HOST $PORT $FILE\n" if $DEBUG;

  return $self;
}
1;

#------------------------------------------------------------------------------

sub id() {
  my $self = attr shift;
  my $id = "$NAME\@$HOST";
  $id .= ":$PORT" if defined($PORT);
  $id .= "/$FILE" if ($FILE eq '');
  return $id;
}

#------------------------------------------------------------------------------