looking at the amount of duplication between these branches, you might want to look at how lipstick does compile-time debugging:

https://github.com/nemomobile/lipstick/blob/qt4/src/components/switcherpixmapitem.cpp#L33

then you could e.g. CONTACTS_DEBUG() << "foo" and it wouldn't be built-in unless DEBUG_OVERLOAD was defined, so you could just sprinkle them liberally