Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Recording column of data in event log using ReportEvent()

52 views
Skip to first unread message

Kent W. Martin

unread,
Jan 15, 1998, 3:00:00 AM1/15/98
to

When my application dies, I am trapping the error and using the IMAGEHLP.DLL
to generate a stack dump such as:
0x00402918 = function1(char *,char *,char,char *,char *)+58h
0x0040160e = _main()+60eh
0x00405516 = _mainCRTStartup()+e6h
0x77f1b304 = GetProcessPriorityBoost()+1b0h
0x00000000 = Test!00000000()

BTW, if you would like the royalty-free C++ source, e-mail me a message!

I want to record this information in NT's event log using ReportEvent(), but
I'm having a problems formatting the data.

The only place I am able to force a new line in the output so the stack
addresses line up is in the .MC file using %n, but that has to be set at
compile time, and at that time I do not know how many lines have to be
displayed (the above example displays 5 lines. Next time the program may
die in main(), in which case I would need to display 4 lines), so I have to
put in the maximum number (99 possible parameters). This leaves my .mc file
containing the following:

MessageId=0x200
Severity=Error
Facility=Application
SymbolicName=MSG_CALL_STACK
Language=English
Exception code: 0x%1 (%2)%n
Exception address: 0x%3%n
%n
--------- Call Stack ---------%n
0x%4%n
0x%5%n
0x%6%n
.
.
0x%98%n
0x%99%n

Unfortunately the unused parameters are displayed in the event viewer,
cluttering up the display.

A brute-force method to solve this would be to have 99 message ID's in my
.MC file, each one having one more parameter added to the end, and having
the logging function determine which message ID to use based on the number
of parameters to be logged. It is easy to do if I can avoid the carpal
tunnel issues, but that is too messy for me.

It seems to me that I should be able to somehow force newlines in one of the
parameters that I send to ReportEvent(), enabling me to send in one long
string for parameter 4.

If I embed newlines in parameter 4's string using \n, the event viewer
replaces each one with a thick vertical line, displaying any remaining text
on the same line.

Does anyone have any ideas on how to solve this?

TIA,

Kent

--
Kent W. Martin
Harris Methodist Health System
kentx...@hmhs.com
(Remove the 'x' from above anti-spam address to send mail)


The Sixth Replicant

unread,
Jan 17, 1998, 3:00:00 AM1/17/98
to

In article <69mgom$pj$1...@client3.news.psi.net> "Kent W. Martin" <kentm...@hmhs.com> writes:
>When my application dies, I am trapping the error and using the IMAGEHLP.DLL
>to generate a stack dump such as:
> 0x00402918 = function1(char *,char *,char,char *,char *)+58h
> 0x0040160e = _main()+60eh
> 0x00405516 = _mainCRTStartup()+e6h
> 0x77f1b304 = GetProcessPriorityBoost()+1b0h
> 0x00000000 = Test!00000000()
>
>It seems to me that I should be able to somehow force newlines in one of the
>parameters that I send to ReportEvent(), enabling me to send in one long
>string for parameter 4.
>
>If I embed newlines in parameter 4's string using \n, the event viewer
>replaces each one with a thick vertical line, displaying any remaining text
>on the same line.

Have you tried <CR><NL> instead of just <NL> ? I don't know for sure that
this works, but I strongly suspect it.

Marc

------------------------------------------------------------------------------
Marc Neuberger m...@netcom.com

Kent W. Martin

unread,
Jan 19, 1998, 3:00:00 AM1/19/98
to

As suggested by someone (the article has already expired so I am not able to
give proper credit), inserting "\r\n" in the parameter string does the
trick!

Kent

--
Kent W. Martin
Harris Methodist Health System
kentx...@hmhs.com
(Remove the 'x' from above anti-spam address to send mail)

Kent Martin wrote in message ...


>When my application dies, I am trapping the error and using the
IMAGEHLP.DLL
>to generate a stack dump such as:
> 0x00402918 = function1(char *,char *,char,char *,char *)+58h
> 0x0040160e = _main()+60eh
> 0x00405516 = _mainCRTStartup()+e6h
> 0x77f1b304 = GetProcessPriorityBoost()+1b0h
> 0x00000000 = Test!00000000()
>

>I want to record this information in NT's event log using ReportEvent(),
but
>I'm having a problems formatting the data.
>

>It seems to me that I should be able to somehow force newlines in one of
the
>parameters that I send to ReportEvent(), enabling me to send in one long
>string for parameter 4.
>
>If I embed newlines in parameter 4's string using \n, the event viewer
>replaces each one with a thick vertical line, displaying any remaining text
>on the same line.
>

Kent W. Martin

unread,
Jan 19, 1998, 3:00:00 AM1/19/98
to
0 new messages