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 | 0867e29552f4fd7c041f696be1b45a3a78b84cfd (patch) | |
tree | cc156054619fb9b58c71786feb7cc597bec5045d | |
parent | 79acb207db938b5f8c6384fa36a0d2467f763b9a (diff) | |
download | prosody-0867e29552f4fd7c041f696be1b45a3a78b84cfd.tar.gz prosody-0867e29552f4fd7c041f696be1b45a3a78b84cfd.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; |