I think you are using a different version of Win32::EventLog than I am, as
mine doesn't recognise RegisterSource. I am using active state perl
version 5.6.1, which includes Win32::EventLog. What are you using?
Using this version of Win32::EventLog, I can get the code you supplied to
print the error icons by removing the RegisterSource call, and by passing
the event hash into EventLog->Report by reference:
use Win32::EventLog;
sub WriteToEventLog
{
my ($eventType, $text) = @_;
# Win32::EventLog::Message::RegisterSource( "Application", $DisplayName
);
my $Event = Win32::EventLog->new( $DisplayName ) || die;
my $id = "123";
my $DisplayName = "SomeName";
%Event = ('EventID', $id,
'Source', $DisplayName,
'EventType', $eventType,
'Category', NULL,
'Strings', $text,
'Data',NULL
);
my $Result = $Event->Report(\%Event);
$Event->Close();
}
WriteToEventLog (EVENTLOG_ERROR_TYPE, "An error has occurred");
The side effect with this is that you get the annoying "The description for
EventID (123) could not be found. It contains the following insertion
string(s):". I'd dearly like to get rid of this, which I assume using
RegisterSource does?
Hope this is of some help,
Phil Morley
rAuL
<luar@speakea To: "Philip Morley"
sy.net> <[EMAIL PROTECTED]>
cc: rAuL <[EMAIL PROTECTED]>,
16/04/02 [EMAIL PROTECTED],
14:22
[EMAIL PROTECTED]
Subject: Re: EventLog Question
Sorry for taking a week to respond to this but here is my code:
WriteToEventLog (EVENTLOG_ERROR_TYPE, "An error has occurred")
sub WriteToEventLog
{
my ($eventType, $text) = @_;
Win32::EventLog::Message::RegisterSource( "Application", $DisplayName
);
my $Event = Win32::EventLog->new( $DisplayName ) || die;
my $Result = $Event->Report(
{
EventID => EVENT_ID,
Strings => $text,
EventType => $eventType,
}
);
$Event->Close();
}
Again the problem is that while the error message does get written to the
event log, only the INFORMATION icon is displayed rather than the ERROR
icon. This happens under NT 4.0 and 2000.
Thanks
Raul Rodriguez
On 12 Apr 2002, Philip Morley wrote:
>
> No. I see the error or warning icons on my
> viewer. Perhaps you should include a
> snippet of the code you use that writes to
> the Event Log...?
>
> Phil Morley
>
>
>
>
> rAuL <[EMAIL PROTECTED]>
> Sent by: To: perl-win32-a-
> [EMAIL PROTECTED]
> <Perl-Win32-admin@listser-
> v.ActiveState.com>
> eState.com cc: Subject:
> EventLog Question
>
> 12/04/02 16:05
>
>
>
>
>
>
> Whenever I use EVENTLOG_ERROR_TYPE or
> EVENTLOG_WARN_TYPE, I do not see a error or
> warning icon in Event Viewer. Is this normal?
>
> _____________________________________________-
> __
> Perl-Win32-Admin mailing list
> [EMAIL PROTECTED] To
> unsubscribe: http://listserv.ActiveState.com/-
> mailman/mysubs
>
>
>
>
>
> _____________________________________________-
> __
> Perl-Win32-Admin mailing list
> [EMAIL PROTECTED] To
> unsubscribe: http://listserv.ActiveState.com/-
> mailman/mysubs
_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs