Changeset

8227:325371632fe6

loggingmanager: Slight cleanup and optimization of file sink
author Waqas Hussain <waqas20@gmail.com>
date Sun, 10 Sep 2017 13:13:24 -0400
parents 8226:3463d82276de
children 8228:cda9db4b881d
files core/loggingmanager.lua
diffstat 1 files changed, 7 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/core/loggingmanager.lua	Sun Sep 10 13:05:45 2017 -0400
+++ b/core/loggingmanager.lua	Sun Sep 10 13:13:24 2017 -0400
@@ -194,14 +194,15 @@
 	-- 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
-		write(logfile, timestamps and os_date(timestamps) or "", name, level, "\t", format(message, ...), "\n");
+	else
+		return function (name, level, message, ...)
+			write(logfile, timestamps and os_date(timestamps) or "", name, "\t", level, "\t", format(message, ...), "\n");
+		end
 	end
 end
 log_sink_types.file = log_to_file;