[Interest] Logging best practice.
Bo Thorsen
bo at fioniasoftware.dk
Fri Dec 2 08:21:55 CET 2011
Den 02-12-2011 08:21, Bo Thorsen skrev:
> Den 01-12-2011 22:46, Charley Bay skrev:
>>
>> qLog(Type) << "string=" << str << ", int=" << i;
>>
>> That code is not re-entrant,
>
> Wrong.
>
> class LoggerHelper {
> ...
> ~LoggerHelper() {
> doActualLogging();
> }
> };
>
> LoggerHelper& operator<<(LoggerHelper&, const T&) {
> // Log T here
> }
Forgot to write that qLog should of course return a LoggerHelper. Maybe
obvious from the code, though.
Bo Thorsen,
Fionia Software.
--
Expert Qt and C++ developer for hire
Contact me if you need expert Qt help
http://www.fioniasoftware.dk
More information about the Interest
mailing list