std.logger

Robert Schadek realburner at gmx.de
Fri Aug 23 02:01:15 PDT 2013


On 08/23/2013 10:30 AM, Piotr Szturmaj wrote:
>>> ?
>> Any other Logger:
>> auto myCoolLogger = new XXXXLogger();
>> myCoolLogger.logLevel = LogLevel.Critical;
>>
>>
>> For the default Logger:
>> log.logLevel = LogLevel.Info;
>
> I see, but isn't separate class instance for every log level a bit too
> much? Setting log level before calling log() isn't (IMHO) good either
> (think of multi-threaded logging).
There isn't. Every Logger has a LogLevel, which can be changed. Every
log message also has a LogLevel hence .info() .error() ...
>
> My opinion is that LogLevel should not be encapsulated within Logger
> class.
>
> Instead function overloading should be used (again IMO):
>
> void log(string message);
> void log(LogLevel level, string message);
>
> So having separate classes for different loggers (sinks) is very nice,
> but LogLevel should be specifiable for each message, no matter which
> Logger class is used.
It is.
>
> Then, each _compile-time_ specifiers like .Warning() or .Error()
> should be just a syntactic sugar over log().



More information about the Digitalmars-d mailing list