Early review of std.logger

Robert Schadek realburner at gmx.de
Mon Oct 14 06:18:57 PDT 2013


On 10/14/2013 02:32 PM, Martin Drasar wrote:
> Having skimmed through the docs I noticed that there are three features
> missing that I use and would like to see in standard logger. First is
> the ability to write to several loggers at once, the second is optional
> formatting of log output and the third is an option to tell logger to
> log only one concrete log level.
>
> All these can be accomplished by writing my own logger that would do
> this, but it would be nice to have some batteries included, e.g.:
>
> 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.
>
> 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.
>
> 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

Thanks, keep it coming


More information about the Digitalmars-d mailing list