Implementing std.log

Jacob Carlborg doob at me.com
Mon May 9 10:24:50 PDT 2011


On 2011-05-09 08:52, Andrei Alexandrescu wrote:
> On 5/7/11 3:43 PM, Jose Armando Garcia wrote:
>> Hey folks,
>>
>> For the past couple of days I took the liberty of partially
>> implementing a logging module for D.
> [snip]
>
> Nice work. Also thanks for contacting me offline.
>
> As I mentioned I'd already decided I'll take a stab at implementing a
> logging module inspired in design from glog. I was tired of the endless
> discussions on what a logging API should look like. This ironically is
> leading now to an embarrassment of riches - we now have two proposals on
> the table. I subjectively prefer mine for the simple reason that it
> includes exactly what I wanted from a logging subsystem with a light
> syntax.
>
> The documentation is at
> http://d-programming-language.org/phobos-prerelease/std_log.html.
>
> The source code is at http://erdani.com/log.d, with informative title
> only; to compile the code you'd need some changes in std.format as well
> (I extended the positional parameter syntax to allow ranges of
> positions). Todos include slight refactoring to avoid bloat in generated
> code per call, OS portability (I only tested on OSX), and getting
> threading right by fixing the shared-related compiler bugs.
>
> Looking forward to more discussion of the matter.
>
>
> Andrei

I assume the "initLogging" function needs the application command line 
because you want to have the name of the application? If that's the 
case, I don't like that is handled via the application command line. I 
have a function that gets the path of the current process:

http://dsource.org/projects/tango/attachment/ticket/1536/process.d

This links to a file attached to a Tango ticket but don't worry, I've 
written the whole file myself and I intend to change the license to the 
Boost License. It's written with D1 (obviously) but it's very easy to 
port to D2, the only dependencies are C functions.

Feel free to port it to D2 and use it in you're logging library if you 
want to.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list