[Interest] Logging best practice.
Bo Thorsen
bo at fioniasoftware.dk
Fri Dec 2 17:12:00 CET 2011
Den 02-12-2011 15:33, Charley Bay skrev:
> On Fri, Dec 2, 2011 at 12:21 AM, Bo Thorsen <bo at fioniasoftware.dk
> <mailto:bo at fioniasoftware.dk>> wrote:
>
> 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.
>
>
> My mistake -- sorry. Yes, a local LoggerHelper would make it re-entrant
> (essential of course).
>
> My original point was to ensure an atomic call to the ultimate logger,
> which the syntax didn't suggest (because of multiple calls in the single
> expression), but yes, a LoggerHelper would provide.
>
> Apologies for my noise.
No worries :)
> As an aside, with the "stream operator" syntax, is there any interest in
> supporting "localization" for logging? The atomic
> "message-format-string" we found easier to localize:
>
> "some value %1 exceeds the limit of %2"
I'm sure some would want to do this, but again this is pretty easy:
qLog(...) << tr("some value %1 exceeds the limit of %2").
arg(1).arg(2);
Personally, I *really* don't like it when someone writes logs (or
comments in the code) in their native language, unless that happens to
be English. But that doesn't mean I can't see that someone will actually
do this.
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