I started actually writing some code on my new experimental engine today. One of the things I want to do with this engine is write as little code myself as I have to. Also, I’d like to avoid using third party libraries for things Windows already does, like logging. A lot of people would use something like log4cxx, and whilst there’s nothing wrong with that (other than being notoriously difficult to use with MSVC), Windows already has a pretty sophisticated logging API called Windows Events, which unifies both the Windows Event Log, and the Event Tracing for Windows APIs. This is a mature, flexible, high-performance API for logging on Windows, and it is built into the operating system, which to me represents far lower risk than any other options; AND I get built in log-file analysis tools (Windows Event Viewer) to help me peruse my log files.
The catch is that there is a little bit of work involved to wrap around it, as I have found, and the documentation is not awesome. Mind you it is no more work than would be involved in log4cxx to programatically set up your loggers etc.
Today I got to grips with a couple of the Windows SDK samples, and wrote a class which wraps around the Windows Event Trace Session, to allow my engine to set-up and tear-down a session. It still needs a little finessing, but this will come once I have created my own provider (for now I’m using the sample provider app to write events into my tracing session).
I’ll post a short article a little later.