[phobos] Would like to add std.log to the review queue

Jose Armando Garcia jsancio at gmail.com
Mon Jun 13 12:56:22 PDT 2011


On Mon, Jun 13, 2011 at 2:50 PM, Robert Jacques <sandford at jhu.edu> wrote:
> On Sat, 11 Jun 2011 20:49:18 -0400, Jose Armando Garcia <jsancio at gmail.com>
> wrote:
>>
>> Hello everyone,
>>
>> What do I need to do to add std.log to the review queue? The
>> implementation is feature complete and it should work in both Windows
>> and Linux.
>>
>> The documentation: http://jsancio.github.com/phobos/phobos/std_log.html
>> The code: https://github.com/jsancio/phobos/blob/master/std/log.d
>>
>> druntime changes:
>>
>> https://github.com/jsancio/druntime/commit/06ac77dca29b350b7079929588755e6b15ca52a5
>>
>> If you want to give the library a try, probably the best thing to do
>> is clone my forks. I keep them fairly up to date with the official
>> branches. For phobos use the master branch and the branch for druntime
>> is log.
>>
>> Enjoy and thanks,
>> -Jose
>
> I've taken a quick look at the API. I notice you've put all the severity
> levels into the public name space. I.e. fatal, error, etc. And the primary
> use of the severity levels is as template arguments to log, i.e.
> log!warning(). This feels like pointless namespace pollution. Is there a
> reason static struct members, i.e. log.warning(), log.error(), etc., or free
> functions, i.e. logWarning() or log_warning(), are inferior solutions?
>

Functions are not enough. I need them to be templates because of
compile time disabling of logging. Conditionally compiling based on
the version flag needs to be done when the client code is compiled not
when the library/phobos is compiled. I think only templates give me
this functionality but I could be wrong.

I can make them free standing template but to use them the client must:

logInfo!()("Hello world");

Argh! Maybe we can use strings:

log!"info"("Hello word");

or a char:

log!'i'("Hello"); log!'I'("World");

Running out of ideas. Anything better?

-Jose


More information about the phobos mailing list