Implementing std.log

Jens Mueller jens.k.mueller at gmx.de
Mon May 9 13:12:50 PDT 2011


Andrei Alexandrescu wrote:
> On 5/7/11 3:43 PM, Jose Armando Garcia wrote:
> >Hey folks,
> >
> >For the past couple of days I took the liberty of partially
> >implementing a logging module for D.
> [snip]
> 
> Nice work. Also thanks for contacting me offline.
> 
> As I mentioned I'd already decided I'll take a stab at implementing
> a logging module inspired in design from glog. I was tired of the
> endless discussions on what a logging API should look like. This
> ironically is leading now to an embarrassment of riches - we now
> have two proposals on the table. I subjectively prefer mine for the
> simple reason that it includes exactly what I wanted from a logging
> subsystem with a light syntax.
> 
> The documentation is at
> http://d-programming-language.org/phobos-prerelease/std_log.html.
> 
> The source code is at http://erdani.com/log.d, with informative
> title only; to compile the code you'd need some changes in
> std.format as well (I extended the positional parameter syntax to
> allow ranges of positions). Todos include slight refactoring to
> avoid bloat in generated code per call, OS portability (I only
> tested on OSX), and getting threading right by fixing the
> shared-related compiler bugs.
> 
> Looking forward to more discussion of the matter.

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

Jens


More information about the Digitalmars-d mailing list