Jump to content



Photo

Eventlogs - AutoItEventMsg.dll


  • Please log in to reply
11 replies to this topic

#1 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,746 posts

Posted 12 June 2008 - 11:23 AM

I've created a Event Messages dll which keeps custom application eventlogs clear of garbage.

Typically event logs created in autoit Have a long message before actually getting to the point, this is the Eventvwr trying to read the message file dll.

With_Crap.JPG

Using the attahced DLL and include file you can create nice clean events with the name of your application.

Without_Crap.JPG

Attached File  AutoItEventMsg.zip   2.47K   1094 downloads

Plain Text         
#include "_CustomEventLog.au3" $MyEventName = "AutoIt" $EventLog = _SetLog($MyEventName,"AutoIteventmsg.dll") If NOT @error then     _RegisterEvent($EventLog, $SUCCESS, $App_Started, @ScriptName)     _RegisterEvent($EventLog, $INFORMATION, $App_OK, "Just confirming this app is OK")     _RegisterEvent($EventLog, $ERROR, $App_Error, "This app is not feeling very well" & @crlf & "Can someone call a doctor")     _RegisterEvent($EventLog, $WARNING, $App_Warning, "There is no crap in this event log")     _RegisterEvent($EventLog, $INFORMATION, $App_Information, "Nothing to see here")     _RegisterEvent($EventLog, $INFORMATION, $App_Free, "This is my Free string" & @crlf & "with nothing at the begining")     _RegisterEvent($EventLog, $SUCCESS, $App_Stopped, @ScriptName) EndIf ;or using the normal AutoIt includes $EventLog = _SetLog($MyEventName,"AutoIteventmsg.dll") Global $aData[1]=[0] $hEventLog = _EventLog__RegisterSource("",$EventLog) _EventLog__Report($hEventLog, $INFORMATION, "None", $App_Information, "","Another message without the crap", $aData) _EventLog__Close ($hEventLog)


Edit: Added some more examples
Edit2: Updated the Dll with version info and other stuff!

Edited by ChrisL, 13 June 2008 - 08:52 AM.








#2 arcker

arcker

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 556 posts

Posted 12 June 2008 - 04:50 PM

Excellent IDEA !!
will use this on my server !!
really good IDEA and initiative :)
-- Arck System _ Soon --Ideas make everything"La critique est facile, l'art est difficile"Projects :Au3Service = Run your exe as service / Updated 27/05/2011 Get it Here

#3 Valuater

Valuater

    www.PayFreeWireless.com

  • MVPs
  • 11,078 posts

Posted 12 June 2008 - 05:06 PM

Cool!!!

8)

Posted Image

Clic The Pic!!!


#4 James

James

    jbrooksuk

  • MVPs
  • 9,470 posts

Posted 12 June 2008 - 05:27 PM

So this cleans up the event log only?

#5 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,746 posts

Posted 12 June 2008 - 05:33 PM

So this cleans up the event log only?


If you create an application and you want to use the event log you can include this dll, then when the eventlog entry is created it knows to look at the dll for the error codess I specified plus your string of data. Then you don't get the long message about event viewer could not locate the dll yada yada yada

#6 perlabsrat

perlabsrat

    Seeker

  • Active Members
  • 6 posts

Posted 01 May 2009 - 03:03 PM

If you create an application and you want to use the event log you can include this dll, then when the eventlog entry is created it knows to look at the dll for the error codess I specified plus your string of data. Then you don't get the long message about event viewer could not locate the dll yada yada yada



First off great work, its just what I needed...

I do have 2 questions.


1. I am in a lab and this event logger is going to be a part of some tools so I can log when events happen when each of the tools run.
I am installing/copying my exe and your dll to a directory "C:\scripts". This install process is started via a bat file on a usb key (kickoff.bat) so the current path is the key when I run kickoff.bat.

I modified my exe to read from $CmdLineRaw - One of the first things I do right after I copy the logger is run a command like:

call c:\scripts\eventlogger.exe tools install started

The problem is that it seems that because the current directory path is on the key at run time of kickoff.bat I have to change my current directory from the key to c:\scripts and then call the logger or nothing will be written to the event log. I have done this using pushd and popd but I was courious as to why the bat file needs the current dir to be where the exe and dll are located.

Also just to try it, I attempted to run regsvr32.exe against the dll but it said it "AutoITEventMSG.dll was loaded, but the DLL Registerserver entry point was not found. This file can not be registerd"

Can you or anyone explain why the current dir needs to be changed for the event to fire correctly?



2. Is there any way to have this code log the same event in both the system and application log. Because of the work we are doing us I need a way to place markers in the event logs at key moments so I can see all that happens in both logs. Having the event duplicated will help to better troubleshoot issues for us.


Thanks.

#7 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,746 posts

Posted 26 May 2009 - 09:00 PM

First off great work, its just what I needed...

I do have 2 questions.


1. I am in a lab and this event logger is going to be a part of some tools so I can log when events happen when each of the tools run.
I am installing/copying my exe and your dll to a directory "C:\scripts". This install process is started via a bat file on a usb key (kickoff.bat) so the current path is the key when I run kickoff.bat.

I modified my exe to read from $CmdLineRaw - One of the first things I do right after I copy the logger is run a command like:

call c:\scripts\eventlogger.exe tools install started

The problem is that it seems that because the current directory path is on the key at run time of kickoff.bat I have to change my current directory from the key to c:\scripts and then call the logger or nothing will be written to the event log. I have done this using pushd and popd but I was courious as to why the bat file needs the current dir to be where the exe and dll are located.

Also just to try it, I attempted to run regsvr32.exe against the dll but it said it "AutoITEventMSG.dll was loaded, but the DLL Registerserver entry point was not found. This file can not be registerd"

Can you or anyone explain why the current dir needs to be changed for the event to fire correctly?



2. Is there any way to have this code log the same event in both the system and application log. Because of the work we are doing us I need a way to place markers in the event logs at key moments so I can see all that happens in both logs. Having the event duplicated will help to better troubleshoot issues for us.


Thanks.

Sorry I've only just seen this.

First

$MyEventName = "AutoIt" $EventLog = _SetLog($MyEventName,"c:\scripts\AutoIteventmsg.dll")


Should register the dll for the application to use c:\scripts\AutoIteventmsg.dll
Without the code I can't really comment.

You cant register the dll with regserver, it's not that type of dll, it has no COM objects.

2. I think the easiest way is you would need to duplicate my 2 functions but change it to the system log not application

#8 lowray1975

lowray1975

    Seeker

  • Active Members
  • 39 posts

Posted 10 August 2009 - 04:08 AM

Hello Chris,

I have two questions although before I get to those I would like to say thank you for writing the DLL for our use!

First, do you know if the DLL works properly in Vista and 2008 Server?

Second, would you be willing to share the source code? I'm worried that if I put this into mass production that in the future it may not work with a new version of MS Windows and having the source code would allow me to update in the future.

Thoughts?

Thanks again!

- Josh

Edited by lowray1975, 10 August 2009 - 04:09 AM.


#9 bap

bap

    Seeker

  • New Members
  • 1 posts

Posted 28 September 2009 - 09:45 PM

Hello Chris,

First of all thank you for sharing your work. Very helpful!
Is there any chance that you would share the code for the library (AutoIteventmsg.dll)?

Bap

I've created a Event Messages dll which keeps custom application eventlogs clear of garbage.

Typically event logs created in autoit Have a long message before actually getting to the point, this is the Eventvwr trying to read the message file dll.

With_Crap.JPG

Using the attahced DLL and include file you can create nice clean events with the name of your application.

Without_Crap.JPG

Attached File  AutoItEventMsg.zip   2.47K   1094 downloads

Plain Text         
#include "_CustomEventLog.au3" $MyEventName = "AutoIt" $EventLog = _SetLog($MyEventName,"AutoIteventmsg.dll") If NOT @error then     _RegisterEvent($EventLog, $SUCCESS, $App_Started, @ScriptName)     _RegisterEvent($EventLog, $INFORMATION, $App_OK, "Just confirming this app is OK")     _RegisterEvent($EventLog, $ERROR, $App_Error, "This app is not feeling very well" & @crlf & "Can someone call a doctor")     _RegisterEvent($EventLog, $WARNING, $App_Warning, "There is no crap in this event log")     _RegisterEvent($EventLog, $INFORMATION, $App_Information, "Nothing to see here")     _RegisterEvent($EventLog, $INFORMATION, $App_Free, "This is my Free string" & @crlf & "with nothing at the begining")     _RegisterEvent($EventLog, $SUCCESS, $App_Stopped, @ScriptName) EndIf ;or using the normal AutoIt includes $EventLog = _SetLog($MyEventName,"AutoIteventmsg.dll") Global $aData[1]=[0] $hEventLog = _EventLog__RegisterSource("",$EventLog) _EventLog__Report($hEventLog, $INFORMATION, "None", $App_Information, "","Another message without the crap", $aData) _EventLog__Close ($hEventLog)

Edit: Added some more examples
Edit2: Updated the Dll with version info and other stuff!



#10 memnon

memnon

    Adventurer

  • Active Members
  • PipPip
  • 120 posts

Posted 12 November 2009 - 09:59 AM

really nice, i love this little script


i have only one question - is it possible to set the Eventid itself, too? (i get all events marked with Eventid 3)
das beste Windows Support Forum: Windows 2000 Helpline und tschüss den WindowsfehlernProgrammieren: Autoit 3 - wer braucht noch VBS ?!Programmieren: Autoit 3 Forum?

#11 ChrisL

ChrisL

    Mass Spanner!

  • Active Members
  • PipPipPipPipPipPip
  • 1,746 posts

Posted 22 February 2010 - 09:46 PM

really nice, i love this little script


i have only one question - is it possible to set the Eventid itself, too? (i get all events marked with Eventid 3)

Bit of a late reply.

I'd created ID's 1 to 8.

Global Const $App_Started = 0x1 Global Const $App_Stopped = 0x2 Global Const $App_OK = 0x3 Global Const $App_Warning = 0x4 Global Const $App_Error = 0x5 Global Const $App_Information = 0x6 Global Const $App_Free = 0x7 Global Const $App_Fatal_Error = 0x8


#12 doudou

doudou

    reverse engineer, the evil twin of the obverse decomposer

  • Active Members
  • PipPipPipPipPipPip
  • 335 posts

Posted 23 February 2010 - 05:28 PM

Thx for this, Chris. I usually juggle with the message compiler which somewhat over-dimensioned for a quick scripting job, Your solution is perfect for this purpose.
UDFS:Apps:Coder's last words before final release: WE APOLOGIZE FOR INCONVENIENCE




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users