realtime logging

Posted by Ion Todirel on Stack Overflow See other posts from Stack Overflow or by Ion Todirel
Published on 2010-04-18T22:47:53Z Indexed on 2010/04/19 0:23 UTC
Read the original article Hit count: 595

Filed under:
|
|
|
|

I have an application which has a loop, part of a "Scheduler", which runs at all time and is the heart of the application. Pretty much like a game loop, just that my application is a WPF application and it's not a game. Naturally the application does logging at many points, but the Scheduler does some sensitive monitoring, and sometimes it's impossible just from the logs to tell what may have gotten wrong (and by wrong I don't mean exceptions) or the current status.

Because Scheduler's inner loop runs at short intervals, you can't do file I/O-based logging (or using the Event Viewer) in there. First, you need to watch it in real-time, and secondly the log file would grow in size very fast. So I was thinking of ways to show this data to the user in the realtime, some things I considered:

  • Display the data in realtime in the UI
  • Use AllocConsole/WriteConsole to display this information in a console
  • Use a different console application which would display this information, communicate between the Scheduler and the console app using pipes or other IPC techniques
  • Use Windows' Performance Monitor and somehow feed it with this information
  • ETW

Displaying in the UI would have its issues. First it doesn't integrate with the UI I had in mind for my application, and I don't want to complicate the UI just for this. This diagnostics would only happen rarely. Secondly, there is going to be some non-trivial data protection, as the Scheduler has it's own thread.

A separate console window would work probably, but I'm still worried if it's not too much threshold. Allocating my own console, as this is a windows app, would probably be better than a different console application (3), as I don't need to worry about IPC communication, and non-blocking communication. However a user could close the console I allocated, and it would be problematic in that case. With a separate process you don't have to worry about it.

Assuming there is an API for Performance Monitor, it wouldn't be integrated too well with my app or apparent to the users. Using ETW also doesn't solve anything, just a random idea, I still need to display this information somehow.

What others think, would there be other ways I missed?

© Stack Overflow or respective owner

Related posts about logging

Related posts about ui