Implementing std.log

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue May 10 17:47:50 PDT 2011


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.

> 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.

> 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.


Andrei


More information about the Digitalmars-d mailing list