On 04.03.2012 2:17, Andrei Alexandrescu wrote:
On 3/3/12 5:51 AM, Sönke Ludwig wrote:
Am 17.02.2012 21:48, schrieb Andrei Alexandrescu:
On 2/17/12 12:06 PM, Jose Armando Garcia wrote:
info("%s message", Severity.info);

I think defaulting to formatted stuff may be confusing.

Andrei

Do you often log static messages? In my experience the majority of
logging calls contains dynamic information and using a format string is
the most convenient and readable form (compared to concatenating using
multiple arguments).

An additional infof(), warnf() etc. would be an acceptable alternative,
although not very pretty. But if you'd always have to write
info.format() or something similar, then this would be a real turn-off,
at least for me.

I think it's fine to default to formatted. Also, it just occurred to me
that we can adjust the formatting primitives to leave any "%"s alone if
there are no matching arguments. Consider:

log.info("100% done!");

This is technically an error, but since D has static knowledge there are
no variadics, it could simply output the string. That's faster, too,
because no validation of the string is necessary.

Thoughts?

I would say just separate them please. Let it work as writeln/writefln and nobody is hurt.

With all manner of magic rules the innocent will catch a bullet sooner or latter. And it's always happens kind of point-blank, when the code is shipped & forgotten.
Turning on imagination, e.g. for rarely used stuff:
log.warn("100%done for task %s, yet the client timed out", taskName);


--
Dmitry Olshansky

Reply via email to