This module makes the Windows NT event log accessible to your Perl programs. It allows you to create new records, read records, and create backup logfiles. The new constructor opens a server's event log as an object:
$log = Win32::EventLog->new(source, [server]);
This function opens an event log and returns an object reference. source specifies the name of the source event, and server specifies the name of the server (local is assumed if no server name is given).
Many of the methods for this module require a reference to an empty variable as an argument. This is how the return value of the method will be placed, whether it is a hash or a scalar. The following methods can be used on event log objects.
Clear |
$log->Clear([filename])
Writes the current event log to the file filename (if supplied) and clears the event log.
GetNumber |
$log->GetNumber(\$number)
Returns the number of events as the value of the scalar variable number.
GetOldest |
$log->GetOldest(\$record)
Returns the record number of the oldest record in the event log to the scalar $record.
Read |
$log->Read(flags, offset, \%eventinfo)
Reads an entry from the event log and returns the information in the eventinfo hash. offset specifies the record number you want to start at in the log. flags sets options for how you want to read the log, which can be any combination of the following:
The final argument is the output object for the event read. eventinfo is a reference to a hash that contains keys for each part of the event description. This same structure is used when you report new events to the event log using the Report method. The eventinfo hash looks like this:
%event = ( EventID => val, EventType => val, Category => val, ClosingRecordNumber => val, Source => val, Computer => val, Strings => val, Data => val, );
Report |
$log->Report(\%eventinfo)
Reports an event to the event log. The information for the event to be recorded is given in a hash, %eventinfo, which should contain values for at least the following keys:
EVENTLOG_ERROR_TYPE Error event EVENTLOG_WARNING_TYPE Warning event EVENTLOG_INFORMATION_TYPE Information event EVENTLOG_AUDIT_SUCCESS_TYPE Success Audit event EVENTLOG_AUDIT_FAILURE_TYPE Failure Audit event
Copyright © 2002 O'Reilly & Associates. All rights reserved.