Std Phobos 2 and logging library?
Steven Schveighoffer
schveiguy at yahoo.com
Fri Apr 10 11:28:49 PDT 2009
On Fri, 10 Apr 2009 12:20:46 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Zz wrote:
>> Hi,
>> Are there any plans for a logging library in Std Phobos 2.0?
>> Zz
>
> I wanted to add logging support for a while now but am undecided about
> the API to use. Log4J is quite popular but quite complicated. There are
> a number of simpler APIs out there but I couldn't figure out which is
> the best.
>
> If anyone has ideas and/or code to contribute, that would be great.
Having experience with Tango's logger, here are the things I like about it:
1. lazy evaluation. This is key, because it removes the whole requirement
in log4* which requires you to check if the logger is active before doing
some expensive calculation. With lazy evaluation, you move the check into
the log function. BTW, this is a *HUGE* potential win for macros (if they
are ever implemented), since you can get rid of the lazy eval. See my
post:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=12431
2. No heap activity. This is to keep the logger from bogging down the
program with memory allocations.
3. Thread safe.
Other than that, Tango's is pretty similar to log4* varieties. I think
the general design of log4* libs is pretty well tested and solid, but
using some nifty features of D that can't be had in other languages makes
it even more useful. So I'd start with that design and see what can be
improved. Similar to how you approached algorithms (start with stl, see
what d features can be applied to it).
-Steve
More information about the Digitalmars-d
mailing list