Review of Jose Armando Garcia Sancio's std.log

Steven Schveighoffer schveiguy at yahoo.com
Wed Mar 7 04:28:36 PST 2012


On Tue, 06 Mar 2012 23:10:58 -0500, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 3/6/12 7:43 PM, Jonathan M Davis wrote:
>> Because the level that you log something at and what you want to do in  
>> terms
>> of exceptions aren't necessarily related at all. It could easily be  
>> that you
>> want to log something and then do some series of operations before  
>> throwing -
>> even if the log level is the most severe level, and you intend to throw  
>> an
>> Error to kill the program. And as others have pointed out, you might  
>> want to
>> log a series of messages. Having std.log throw on the first one makes  
>> it so
>> that you can't log any others.
>
> Then I guess you'd be well advised to use the function that "logs to the  
> error log", not the one that "logs to the error log and then throws".  
> No? I mean you're explaining how a screwdriver is not appropriate for  
> pounding nails.

As has been repeatedly pointed out, the fatal and critical levels are  
different levels than the error level.  Also, they cannot be turned off.   
Access to those levels should not be coupled with throwing an exception.   
Convenience functions to log at those levels and then throw an exception  
are perfectly acceptable.  They just shouldn't be the only/default  
mechanism.

A screwdriver is not appropriate for driving nails, but neither is an  
explosive-tipped hammer.

-Steve


More information about the Digitalmars-d mailing list