Logger: avoid formatting for strings without additional args

This commit is contained in:
Denis Feklushkin 2019-04-23 23:01:44 +07:00
parent 6c260768fd
commit fc9bef86af

View file

@ -804,13 +804,17 @@ package void initializeLogModule()
private nothrow void doLog(S, T...)(LogLevel level, string mod, string func, string file, int line, S fmt, lazy T args) private nothrow void doLog(S, T...)(LogLevel level, string mod, string func, string file, int line, S fmt, lazy T args)
{ {
try { try {
static if(T.length != 0)
auto args_copy = args; auto args_copy = args;
foreach (l; getLoggers()) foreach (l; getLoggers())
if (l.minLevel <= level) { // WARNING: TYPE SYSTEM HOLE: accessing field of shared class! if (l.minLevel <= level) { // WARNING: TYPE SYSTEM HOLE: accessing field of shared class!
auto ll = l.lock(); auto ll = l.lock();
auto rng = LogOutputRange(ll, file, line, level); auto rng = LogOutputRange(ll, file, line, level);
static if(T.length != 0)
/*() @trusted {*/ rng.formattedWrite(fmt, args_copy); //} (); // formattedWrite is not @safe at least up to 2.068.0 /*() @trusted {*/ rng.formattedWrite(fmt, args_copy); //} (); // formattedWrite is not @safe at least up to 2.068.0
else
rng.put(fmt);
rng.finalize(); rng.finalize();
} }
} catch(Exception e) debug assert(false, e.msg); } catch(Exception e) debug assert(false, e.msg);