Logger for D (was: Using glog's design for Phobos?)

so so at so.do
Fri Aug 27 19:07:58 PDT 2010


> Hello?
> Couldn't it be just like this?
>
> enum log_level {
>    note, // or info whatever
>    warning,
>    error,
>    fatal,
> }
>
> string log_direct(string filename); // returns last log file directed.
> void log(A...)(A a)
> {
>    if(typof(a[0]) == log_level)
>      do_level_thingy();
>
>    ... // rest.
> }
>
> version(debug)  void debug_log(A...)(A a) { log(a); }
> else            void debug_log(A...)(A a) {}
>
> void main()
> {
>    std::string old_file = log_direct(new_file); // if you like to change  
> it that is
>    log("log me pretty", arg1, ....);
>    log(error, "log me pretty error", arg1, ...);
>    log(warning, "log me pretty warning", arg1, ...);
> }
>
> Isn't that good/beautiful/flexible enough?
> Please don't start with instantiated loggers, they are ugly so ugly and  
> unnecessary!
>
> Thanks.
>

Damn i should learn to read it a few times before posting!

"Hello?"
Hello!

"ugly so ugly"
one of them would do i guess :)

-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


More information about the Digitalmars-d mailing list