From fc9bef86af63b490bc9fb4446a8e199047cac9b6 Mon Sep 17 00:00:00 2001 From: Denis Feklushkin Date: Tue, 23 Apr 2019 23:01:44 +0700 Subject: [PATCH] Logger: avoid formatting for strings without additional args --- source/vibe/core/log.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/vibe/core/log.d b/source/vibe/core/log.d index 8aa8661..b0863ac 100644 --- a/source/vibe/core/log.d +++ b/source/vibe/core/log.d @@ -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) { try { - auto args_copy = args; + static if(T.length != 0) + auto args_copy = args; foreach (l; getLoggers()) if (l.minLevel <= level) { // WARNING: TYPE SYSTEM HOLE: accessing field of shared class! auto ll = l.lock(); auto rng = LogOutputRange(ll, file, line, level); - /*() @trusted {*/ rng.formattedWrite(fmt, args_copy); //} (); // formattedWrite is not @safe at least up to 2.068.0 + static if(T.length != 0) + /*() @trusted {*/ rng.formattedWrite(fmt, args_copy); //} (); // formattedWrite is not @safe at least up to 2.068.0 + else + rng.put(fmt); rng.finalize(); } } catch(Exception e) debug assert(false, e.msg);