This is my second weekend when both my little daughter and I are home all weekend sick. I’m so gracious to only be sick on weekends, which I’m sure my employer appreciates a lot :p
Either way, I got an itch when I checked out Herb’s Effective Concurrency Columns and “Know when to use an active object instead of a mutex” and I just had to upgrade my Active Object C++0x. I moved it to Qt code instead from C++0x since that’s what I’ve available at my current assignment. It turned out very nice. With some unit gtesting and with QWaitCondition I get my Active Object to wait/sleep until it has anything to process and not the silly “yield/sleep x-time, then check if anything is in the queue, then if not sleep x-time again (iterative)” (that I used for my C++0x Active Object — but with a comment that it could easily be improved)
< edit: 2011-11-29 you can see the C++11, and Qt active objects here
https://github.com/KjellKod/active-object they are efficienly using waitcondition. You can also find a straight C++03 version but that uses currently the inefficient yield/sleep then poll message retrieval >
I’m also thinking about doing my own logger. We need one at my client but it’s pretty low priority but since it seems lika fun job I will do it open-source at home instead. I checked out a few nice loggers like Glog, Ezlogger and Log4C++ and felt them all lacking…
- GLOG, nice API but horrible documentation. Almost all of the forum’s question is because it is not well documented, unless you want to read through all the source code — which is not so nice with all the macros in place.
- EzLogger, previously unknown to me but seems to have nice functionalites when looking in forums.
- Log4C++ (not so nice public API but just like GLOG it has in essence the functionality we want, I just don’t like the ugly calls)
All of them suffers however from one important criterion that makes them a no-go choice. None of them are asynchronous. It is unacceptable for my assignment to have the thread that puts out a log entry to also pay for the CPU time it takes to write that entry to file.
Most of them has lots-and-lots of features that we don’t need and with a horrible documentation of these features. All this, plus the lack of asynchronous calling makes me want to carve out my own.
Nice and easy syntax like GLOG
LOG(INFO) << "This is just a test of putting a value in the log entry: " << 100;
and with SWERR/Assert/Design-By-Contract mimimalistic functionality like
CHECK(some_expression) << "If this failed, we will "crash" with this message and our watchdog will make us rise again like the Phoenix";
So with a mimimalistic approach, using the nice and easy usage API above but with my Active-Qt-Object as backbone we get a very easy to use logger with asynchronous calling and easy to modify for others since it’s not cluttered with may-be-good functionality.