GC free Writer

David d at dav1d.de
Fri Feb 8 13:59:58 PST 2013


Am 08.02.2013 22:53, schrieb Lee Braiden:
> On Fri, 08 Feb 2013 16:57:39 +0100, David wrote:
>> I am currently implementing a logging module, I want to make logging to
>> stderr/stdout/"any file" possible, also during runtime-shutdown (logging
>> from dtors)
>>
>> Atm it lookes like this:
>>
>> ----
>> void log(LogLevel level, Args...)(Args args) {
>>     string message = format(args);
>>
>>     ... pass string to writer
>> }
>> ---
> 
> Will this module be published for others to use?  If so, can I suggest a 
> feature?
> 
> One thing that's really important with logging, but rarely available, is 
> not levels, but code areas.  I believe python, for example, allows you to 
> name log sections:
> 
>     logger("mainsection.subsection.subsubsection1", "message1")
>     logger("mainsection.subsection.subsubsection2", "message2")
> 
> and then you can enable, say, everything related to "subsection", but 
> then filter out everything in "subsubsection2".
> 
> That's really important, when debugging/auditing complex apps, without 
> actually wanting to modify the code just to find out what's going on.  
> Especially since modifying the code can CHANGE what's going on.
> 
> 

Well, here it is:
https://github.com/Dav1dde/BraLa/blob/master/brala/utils/log.d

You can't name section, but you can create loggers with different names.
But this actually a good idea (design is similiar, but less complex and
powerful, to logbook http://packages.python.org/Logbook/ )


More information about the Digitalmars-d-learn mailing list