Early review of std.logger

Martin Drasar drasar at ics.muni.cz
Mon Oct 14 06:31:31 PDT 2013


On 14.10.2013 15:18, Robert Schadek wrote:
> On 10/14/2013 02:32 PM, Martin Drasar wrote:
>> 1) MultiLogger class that takes references to other loggers and just
>> forwards the call to the log function.
> will be done, see the reply to Sönke's post.

Cool

>> 2) Optional string parameter that describes the desired log output (i.e.
>> format and position of timestamp, line, file, message, ...) for
>> different needs, e.g. machine vs. human read log.
> I thought about that, but I'm not sure if that won't the logger to
> complex.  IMO it is better to have some reasonable hard-coded default
> than a log format parser. If the user needs something else, subclassing
> a logger and changing the format is a 7 liner. And this is the design
> Idea behind the logger.

True, it would definitely make the logger more complex. Default
implementation would just help developers that want this feature avoid
the pitfalls of string formatting (e.g. buffers vs. allocation as was
discussed in previous thread on std.logger).

>> 2.1) Allow more than one string to be logged. For example I want to add
>> component name, task identifier, etc., but I want to let correct
>> formatting on the logger.
> logf("name %s, taskId %s", name, taskId); already works

This was tightly coupled with the previous request, i.e. not using
string format and logging one string, but passing several strings and
let the target logger assemble them as it see fit.

> Thanks, keep it coming

How about being able to log only certain log level(s) and not only
greater or equal?

Martin


More information about the Digitalmars-d mailing list