Review: std.logger

NCrashed via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 11 11:16:27 PDT 2014


On Friday, 11 July 2014 at 14:36:34 UTC, Dicebot wrote:
> Round of a formal review before proceeding to voting. Subject 
> for Phobos inclusion : http://wiki.dlang.org/Review/std.logger 
> authored by Robert Schadek.
>
> Code:
>     https://github.com/D-Programming-Language/phobos/pull/1500
> Documentation:
>     
> http://burner.github.io/phobos/phobos-prerelease/std_logger_core.html
>     
> http://burner.github.io/phobos/phobos-prerelease/std_logger_stdiologger.html
>     
> http://burner.github.io/phobos/phobos-prerelease/std_logger_filelogger.html
>     
> http://burner.github.io/phobos/phobos-prerelease/std_logger_multilogger.html
>     
> http://burner.github.io/phobos/phobos-prerelease/std_logger_nulllogger.html
>     
> http://burner.github.io/phobos/phobos-prerelease/std_logger_templatelogger.html
> DUB package:
>     http://code.dlang.org/packages/logger
>
> Previous discussion thread:
>     
> http://forum.dlang.org/post/mailman.313.1377180809.1719.digitalmars-d@puremagic.com
>
> ======================================================================
>
> Summary of changes since last discussion (by Robert):
>
>
> * logger is now a package of multiple files
> * a lot more documentation
> * log and logf now behave as their write and writef counterparts
> * for logging with an explicit LogLevel call logl loglf
> * for logging with an explicit condition call logc logcf
> * for logging with an explicit LogLevel and explicit condition 
> call
> loglc loglcf
> * the log function with an explicit LogLevel like info, 
> warning, ... can
> be extended into c, f or cf and therefore require a condition 
> and/or are
> printf functions
> * unittest have been updated
> * dub package for easy testing
>
> ======================================================================
>
> This is one of long sanding Phobos candidates Robert has put 
> some great effort into. As far as I know it is already used in 
> several D projects and it is a good moment to make it official.
>
> Review goals, as usual : verify that API is robust enough to 
> build more complicated logging systems on top of it, verify 
> Phobos style compatibility, check if provided documentation is 
> complete and friendly enough.
>
> Base for review process is defined by 
> http://wiki.dlang.org/Review/Process

Mistype at std.logger.core.Tracer: "Tracer generates trace calls 
to the passed logger wenn the Tracer struc" wenn should be "when".

The API is well done. The only thing I want to have in the 
package is a delayed logger: delayed logger wraps another logger, 
accumulates messages and writes to inner logger by explicit call.

That is useful while testing. Major part of diagnostic 
information is needed only when test is failed:
```
unittest
{
     auto logger = new DelayedLogger(myCustomLogger);
     scope(failure) logger.flush;

     // some activity that can throw
}
```




More information about the Digitalmars-d mailing list