Implementing std.log

Jens Mueller jens.k.mueller at gmx.de
Wed May 11 00:21:06 PDT 2011


Andrei Alexandrescu wrote:
> On 5/9/11 3:12 PM, Jens Mueller wrote:
> >I think every() behaves strangely. Because the counter is per function.
> >But it should be per logging statement. std.log differs here from glog
> >and this seems incorrect to me. everyMs() has a similar problem.
> 
> Actually, they behave correctly. The counters for every and everyMs
> are static and generated per instantiation of the function. Since
> each instantiation is determined by __FILE__ and __LINE__, there is
> a different counters for each __FILE__/__LINE__ combination.

Oh yes. Now I see. I missed the template arguments. Sorry. Now I also
understand why you want to cut down the possible code bloat.

> >Even though I believe log.vlog is necessary I often find it difficult to
> >come up with an appropriate level for a given statement. With normal
> >logging it is often obvious whether info, warning, error, critical, or
> >fatal is appropriate. But this is a minor problem and more a matter of
> >coding style.
> 
> No need to use vlog. But a variety of programs (e.g. ssh) decide
> quite precisely what will be logged at each verbosity level.

Maybe it helps that you provide -v as incremental options. Glog does not
do it like this. But I think allowing incremental options helps here. It
tells the user to use vlog(0) for the least verbose messages and so on
incrementally for more verbosity.

> >I'd like to try out the code. I'd be very pleased if you can make a
> >compiling version available on github. I'd like to test whether there is
> >no code generated if -version=strip_log_error etc. is specified. I.e.
> >whether the call to an empty function will always be removed.
> 
> Thanks for your interest. I just committed the code to my repo:
> 
> https://github.com/andralex/phobos
> 
> You'd need the latest dmd and druntime to compile Phobos.

Thanks. I'll try it out.

Jens


More information about the Digitalmars-d mailing list