NAME

SYNOPSIS

This is base class for the usage of the logparser parsing. Usually you will implement a subclass of this class implementing the following methods:

new

You can define whatever new parameters you want in this method, but usually only the object variable pattern (the regular expression to match in the file) is needed

evalBegin

This is an extract of code which initializes all the variables that you might need during the run of logparser

evalIterate

This method will be invoked for each line of the log file.

evalEnd

This method usually records in the properties hash reference the key, value pairs that you want ot record in the output.

DESCRIPTION

For a more detailed description on how to use this class please check logparser.

This document is a detailed reference of the different methods provided in this class

METHODS

new

Receives (at the moment) no arguments. It creates an object of SNMP::LogParserDriver

name

Permits to retrieve or set the name of the object as in

print "name: ".$self->name;

or

$self->name("myname");

logfile

Permits to retrieve or set the logfile of the object as in

print "logfile: ".$self->logfile;

or

$self->logfile("/var/log/logfile");

pattern

Permits to retrieve or set the regular expression pattern of the object as in

print "pattern: ".$self->pattern;

or

$self->pattern("^myregex$");

savespace

Permits to retrieve or set the savespace of the object as in

print "savespace: ".Dumper($self->savespace);

or

$self->savespace(\%mysavespace);

The savespace is usually a reference to a hash file. The value of the savespace variable will be restored in the beginning of each invocation of logparser and saved at the end of the invocation. Tipically things like counters are saved in each invocation of the savespace.

workspace

Permits to retrieve or set a variable that will be maintained across iterative parsings of the log, but will not be maintained across logparser invocations

print "workspace: ".Dumper($self->workspace);

or

$self->workspace(\%workspace);

The workpace is usually a reference to a hash file. The value of the workspace variable will only last for each invocation of logparser. Tipically things like local variable are saved in in the workspace.

properties

Permits to retrieve or set the properties of the object as in

print "properties: ".$self->properties;

or

$self->properties(\%myproperties);

The properties of an object are the key/value pairs that will be stored in the propertiesFile of the logparser.conf file.

logger

Permits to retrieve or set the logger of the object as in

print $self->logger->debug("debug message");

or

$logger = Log::Log4perl->get_logger(LOG_TAG);
$self->logger($logger);

evalBegin

This method is usually overriden in the child class. This method will be invoked before any line of the file is parsed.

Typically counters will be initialised here if they have not been initialised before:

As a valued partner and proud supporter of MetaCPAN, StickerYou is
happy to offer a 10% discount on all Custom Stickers,
Business Labels, Roll Labels,
Vinyl Lettering or Custom Decals. StickerYou.com
is your one-stop shop to make your business stick.
Use code METACPAN10 at checkout to apply your discount.