Review: std.logger

ponce via Digitalmars-d digitalmars-d at puremagic.com
Tue Jul 22 00:27:37 PDT 2014


On Sunday, 20 July 2014 at 16:15:53 UTC, linkrope wrote:
> At least in the code of our company, logging a formatted string 
> is the basic use case.
> The function for the basic use case should not require a suffix 
> letter.

I'm in 100% disagreement. If you don't add the f suffix, users 
will write:

info(<user provided string that could contain format>);

This is a crash if the user provided string happens to contains 
"%s".
I wouldn't use such an API which makes format bugs hard to find.



> 2. No support for 24/7 (server) applications
>
> In my opinion, I really need logging for applications that 
> possibly run forever.
> With the FileLogger, the file will grow forever.
> That's why most other frameworks provide something like a 
> RollingFileLogger or some "logrotate-aware" FileLogger.

Do you realize rolling loggers are not there because they are 
supposed to be in another layer as subclasses of Logger?


> By the way: Instead of what I really need, I get a NullLogger.
> I have no clue, why I never ever missed such an oddity.

I asked for it. And I use it, because I write libraries that log 
warnings but don't forcefully require the users to provide a 
Logger if they don't want to.
And that way, I can still write "logger.warningf" without "if" 
everywhere.



More information about the Digitalmars-d mailing list