OutputDebugString override

OutputDebugString override

Simple override for Windows.OutputDebugString which adds a timestamp, thread id and memory, and an overloaded string version to get rid of those pesky pChar casts.

The output shows up in the in the BDS Event Log, or it can be captured while running live with Sysinternal’s DebugView (http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx).

CustomDebugOut.pas – http://pastebin.com/GM7DE18L

#delphi   #sourcecode  

7 thoughts on “OutputDebugString override

  1. Ondrej Kelle – Actually, that one is experimental.  After logging millions and millions of multi-threaded lines with DebugView, it is clear that lines are dropped.  Trying to figure out if this helps. If not, I’ll have to blame DebugView.


  2. I am actually considering doing direct logging to disk by capturing the string and passing it to a background thread which burst-writes the log for minimum IO overhead. Having access to full firehose logged data is gold for researching issues in real-time.


  3. Thanks for the heads up, Lars Fosdal. I’ve had some trouble with OutputDebugString under heavy load, too, but I don’t remember what the problem was. Another thing to be aware of: because of the synchronization, using the API will affect the behaviour of your multi-threaded app.


  4. [ Having access to full firehose logged data is gold for researching issues in real-time.] said by Lars Fosdal .  I totally agree with this! I did that with our real time software, such as city metro system. 1 log file per hour, and  remain files within 1 month.  However, logging info is lesser than outputdbugstring shown  in debugview.  Logging to disk should be an optional.


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.