Review of Jose Armando Garcia Sancio's std.log

Jose Armando Garcia jsancio at
Mon Feb 13 19:16:29 PST 2012

On Tue, Feb 14, 2012 at 12:02 AM, Jonathan M Davis <jmdavisProg at> wrote:
> On Monday, February 13, 2012 23:58:38 Jose Armando Garcia wrote:
>> On Mon, Feb 13, 2012 at 4:19 PM, Jonathan M Davis <jmdavisProg at>
> wrote:
>> > On Monday, February 13, 2012 17:49:49 David Nadlinger wrote:
>> >> You define the Severity enum members starting with fatal as 0. Why not
>> >> the other way round – so that severityA < severityB would do what you
>> >> (or at least I) would expect?
>> >
>> > syslog defines 0 (LOG_EMERG) as the strongest and 7 (LOG_DEBUG) as the
>> > weakest. The greater the number, the more logging output, you're going
>> > to see. So, he's following syslog in that respect, though he doesn't
>> > have as many log levels. He should probably add at least debug. He also
>> > aliases them to module-level symbols for some reason, which is a big
>> > no-no IMHO.
>> I am trying to minimize the number of predefined log levels. One of
>> the big problems I see with having too many log levels is that the
>> programmer never knows which one to use. I think std.log makes this
>> very clear:
>> 1. Log at fatal if you want the application to assert
>> 2. Log at critical if you want the thread to throw
>> 3. Log at error if you detect a programming bug (invariant violation)
>> but you wish to continue and cross your finger
>> 4. Log at warning if you detected peculiar condition yet the program
>> was coded to handle it.
>> 5. Log at info if you want to document an action/state.
>> 6. verbose log for trace/debugging specific parts of a program.
>> I think it would help me that instead of suggesting another level we
>> instead state what we think the user would like to do or log but the
>> framework as defined doesn't let the user do.
> Personally, I'd just copy what syslog does in terms of log levels. Then
> std.log can use syslog and everything maps wonderfully.
Do you think that our users will really want to send "debug" message
to syslog? Either way I don't think that is a reason to add debug
level. If we used the common denominator to determine the set of
features  that set would be quite large. The implementation of the
Logger interface can do its best to map the severity from std.log to
something syslog likes.

This is exactly what SLF4J does with Log4J, java.util.logger, syslog, etc.

> - Jonathan M Davis

More information about the Digitalmars-d mailing list