Main Page | Data Structures | File List | Data Fields | Globals

LogEvent Documentation

Version 1

In a nutshell

LogEvent simplifies usage of NT's ReportEvent. The main idea is to encode optional insertion arguments in the message file in both human and machine readable formats. The human readable format consists of a tail added to the SymbolicName. The machine readable format is the same used with printf. It is stored as a different language resource. For example:
MessageId = SymbolicName = MESSAGE_NAME_sdM Language = English The arguments are %1 and %2. The system said "%3". . Language = Format %s%d%M .

This allows to log with the same ease as fprintf

if (/* log needed */) log_event(&log, MESSAGE_NAME_sdM, "argument 1", 2, GetLastError());

Download code and docs

The zip contains .h and .c files that you can include in your app or compile indipendently for testing.

Compile and run the test:

Borland

  cd logevent
  mc -v -U msgs.mc
  brc32 -32 -r msgs.rc
  bcc32 -tWM -v -I. -c -DTEST_MAIN w32event.c
  ilink32 /r /v /Tpe d:\borland\BCC55\Lib\c0x32.obj w32event.obj,w32event.exe,w32event.map,cw32.lib import32.lib,,msgs.res
  w32event

MSVC

See link How to compile using MSVC
  cd logevent
  mc -U msgs.mc
  rc -r msgs.rc
  link -dll -noentry -out:msgs.dll msgs.res
  cl -DTEST_MAIN w32event.c
  w32event msgs.dll
Note: running the test will register the event source. I haven't been able to build msgs.dll with Borland, suggestions appreciated. To use the code, compile it without defining TEST_MAIN and link to your app.

Links

How to compile using MSVC

http://msdn.microsoft.com/library/en-us/tools/tools/sample_message_text_file.asp

How to integrate MC.exe in VC

http://www.codeproject.com/system/mctutorial.asp

Where to get MC.exe apart from buying MSVC

http://download.microsoft.com/download/win98SE/Install/Gold/W98/EN-US/98DDK.EXE
(a smaller download file would be appreciated)

How to reach the text of a specific message

http://www.freevbcode.com/ShowCode.asp?ID=2990
(an official documentation would be appreciated)

Other examples in MSDN

http://msdn.microsoft.com/library/en-us/debug/base/adding_a_source_to_the_registry.asp
http://msdn.microsoft.com/library/en-us/secauthz/security/getting_the_logon_sid_in_c__.asp

Licence

GNU General Public Licence (see COPYING) Copyright (C) 2004 Vesely Alessandro
Generated on Mon Apr 11 14:47:59 2005 for LogEvent by doxygen 1.3.7