From f4aebb575ef73d5f9bce263af4146196c17cf66b Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sun, 10 Sep 2017 13:13:24 -0400 Subject: loggingmanager: Slight cleanup and optimization of file sink --- core/loggingmanager.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'core/loggingmanager.lua') diff --git a/core/loggingmanager.lua b/core/loggingmanager.lua index 1b888a7e..2e9590fe 100644 --- a/core/loggingmanager.lua +++ b/core/loggingmanager.lua @@ -194,14 +194,15 @@ local function log_to_file(sink_config, logfile) -- Column width for "source" (used by stdout and console) local sourcewidth = sink_config.source_width; - return function (name, level, message, ...) - if sourcewidth then + if sourcewidth then + return function (name, level, message, ...) sourcewidth = math_max(#name+2, sourcewidth); - name = name .. rep(" ", sourcewidth-#name); - else - name = name .. "\t"; + write(logfile, timestamps and os_date(timestamps) or "", name, rep(" ", sourcewidth-#name), level, "\t", format(message, ...), "\n"); + end + else + return function (name, level, message, ...) + write(logfile, timestamps and os_date(timestamps) or "", name, "\t", level, "\t", format(message, ...), "\n"); end - write(logfile, timestamps and os_date(timestamps) or "", name, level, "\t", format(message, ...), "\n"); end end log_sink_types.file = log_to_file; -- cgit v1.2.3