Software /
code /
prosody
Comparison
core/loggingmanager.lua @ 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 |
parent | 8226:3463d82276de |
child | 8228:cda9db4b881d |
comparison
equal
deleted
inserted
replaced
8226:3463d82276de | 8227:325371632fe6 |
---|---|
192 end | 192 end |
193 | 193 |
194 -- Column width for "source" (used by stdout and console) | 194 -- Column width for "source" (used by stdout and console) |
195 local sourcewidth = sink_config.source_width; | 195 local sourcewidth = sink_config.source_width; |
196 | 196 |
197 return function (name, level, message, ...) | 197 if sourcewidth then |
198 if sourcewidth then | 198 return function (name, level, message, ...) |
199 sourcewidth = math_max(#name+2, sourcewidth); | 199 sourcewidth = math_max(#name+2, sourcewidth); |
200 name = name .. rep(" ", sourcewidth-#name); | 200 write(logfile, timestamps and os_date(timestamps) or "", name, rep(" ", sourcewidth-#name), level, "\t", format(message, ...), "\n"); |
201 else | 201 end |
202 name = name .. "\t"; | 202 else |
203 end | 203 return function (name, level, message, ...) |
204 write(logfile, timestamps and os_date(timestamps) or "", name, level, "\t", format(message, ...), "\n"); | 204 write(logfile, timestamps and os_date(timestamps) or "", name, "\t", level, "\t", format(message, ...), "\n"); |
205 end | |
205 end | 206 end |
206 end | 207 end |
207 log_sink_types.file = log_to_file; | 208 log_sink_types.file = log_to_file; |
208 | 209 |
209 local function log_to_stdout(sink_config) | 210 local function log_to_stdout(sink_config) |