diff options
author | Waqas Hussain <waqas20@gmail.com> | 2017-09-10 13:13:24 -0400 |
---|---|---|
committer | Waqas Hussain <waqas20@gmail.com> | 2017-09-10 13:13:24 -0400 |
commit | f4aebb575ef73d5f9bce263af4146196c17cf66b (patch) | |
tree | cc156054619fb9b58c71786feb7cc597bec5045d | |
parent | 00cb31f022a3325e4e182b666f85a6b4e05b7a7e (diff) | |
download | prosody-f4aebb575ef73d5f9bce263af4146196c17cf66b.tar.gz prosody-f4aebb575ef73d5f9bce263af4146196c17cf66b.zip |
loggingmanager: Slight cleanup and optimization of file sink
-rw-r--r-- | core/loggingmanager.lua | 13 |
1 files changed, 7 insertions, 6 deletions
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; |