std.experimental.logger formal review round 3

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Mon Oct 27 13:41:57 PDT 2014


On 10/27/2014 09:22 AM, Robert burner Schadek wrote:
>
> It is a good think then that the *DisableLogging versions are only used
> inside a template that is used inside a templates. Though version
> statements attached to a phobos compilation should only have impact on
> the unittest of phobos.
>
> Secondly, why would phobos be shipped with certain LogLevel disabled.

Well the question is, how can you avoid paying the overhead for logging 
when you don't need it.

Say I want to add tracing/logging to 
[`parseJson`](http://dlang.org/library/std/json/parseJSON.html) or 
[`findRoot`](http://dlang.org/phobos/std_numeric.html#.findRoot) then I 
have no way to get rid of the logLevel overhead with the version 
identifier and abstract class approach.

When the logLevel is know at CT this overhead can be completely eliminated.
auto json = parseJSON(data, stdoutLogger!(LogLevel.trace)());
auto json = parseJSON(data, stdoutLogger!(LogLevel.warning)());
auto json = parseJSON(data, NullLogger());


More information about the Digitalmars-d mailing list