Implementing std.log

Denis Koroskin 2korden at gmail.com
Wed Apr 20 09:31:08 PDT 2011


On Wed, 20 Apr 2011 20:09:30 +0400, Robert Clipsham  
<robert at octarineparrot.com> wrote:

> Hey folks,
>
> I've just finished porting my web framework from D1/Tango to D2/Phobos,  
> and in the transition lost logging functionality. As I'll be writing a  
> logging library anyway, I wondered if there'd be interest in a std.log?  
> If so, is there a current logging library we would like it to be based  
> on, or should we design from scratch?
>
> I know there has been discussion about Google's  
> http://google-glog.googlecode.com/svn/trunk/doc/glog.html and another  
> candidate may be http://logging.apache.org/log4j/ . Do we want a  
> comprehensive logging library, or just the basics? (Possibly with some  
> method for extension if needed).
>

For me, Logger needs to be simple but feature complete. Here is my ideal  
syntax:

Logger log = new Logger();
log.warn("bewarned");
log.error("error code: %d", 42);
log.fatal("Derp");
log.wtf("how is this even possible!?"); // What a Terrible Failure!
// somewhat related:  
http://www.reddit.com/r/programming/comments/c6u6f/new_android_22_froyo_api_logwtf/

It would be great if you could configure log output with an external  
(xml?) file, e.g. formatting (show timestamps in a specified form, include  
thread id, call-stack etc for each error level), suppress (but still log)  
some of the error levels, being able to redirect log to file instead of  
console, etc. Ideally, it would monitor config changes and apply them  
on-fly, too.

In addition, I believe Andrei wouldn't like to type more than 7 characters  
to add log entry, but I think we could negotiate :)


More information about the Digitalmars-d mailing list