projects
/
prosody.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
75b6361
)
loggingmanager: Call setvbuf on output files, defaulting to line-buffered, instead...
author
Matthew Wild
<mwild1@gmail.com>
Thu, 4 Feb 2016 14:56:49 +0000
(14:56 +0000)
committer
Matthew Wild
<mwild1@gmail.com>
Thu, 4 Feb 2016 14:56:49 +0000
(14:56 +0000)
core/loggingmanager.lua
patch
|
blob
|
history
diff --git
a/core/loggingmanager.lua
b/core/loggingmanager.lua
index 15d2ee3c468bb7c5db356518270d35cbb94029f9..259c2c4411eca9bf71aed8355dec730f7498a856 100644
(file)
--- a/
core/loggingmanager.lua
+++ b/
core/loggingmanager.lua
@@
-15,6
+15,7
@@
local math_max, rep = math.max, string.rep;
local os_date = os.date;
local getstyle, setstyle = require "util.termcolours".getstyle, require "util.termcolours".setstyle;
local os_date = os.date;
local getstyle, setstyle = require "util.termcolours".getstyle, require "util.termcolours".setstyle;
+-- COMPAT: This should no longer be needed since the addition of setvbuf calls
if os.getenv("__FLUSH_LOG") then
local io_flush = io.flush;
local _io_write = io_write;
if os.getenv("__FLUSH_LOG") then
local io_flush = io.flush;
local _io_write = io_write;
@@
-157,7
+158,6
@@
local function reload_logging()
logging_config = config.get("*", "log") or default_logging;
logging_config = config.get("*", "log") or default_logging;
-
for name, sink_maker in pairs(old_sink_types) do
log_sink_types[name] = sink_maker;
end
for name, sink_maker in pairs(old_sink_types) do
log_sink_types[name] = sink_maker;
end
@@
-185,6
+185,10
@@
function log_sink_types.stdout(sink_config)
timestamps = default_timestamp; -- Default format
end
timestamps = default_timestamp; -- Default format
end
+ if sink_config.buffer_mode ~= false then
+ io.stdout:setvbuf(sink_config.buffer_mode or "line");
+ end
+
return function (name, level, message, ...)
sourcewidth = math_max(#name+2, sourcewidth);
local namelen = #name;
return function (name, level, message, ...)
sourcewidth = math_max(#name+2, sourcewidth);
local namelen = #name;
@@
-220,6
+224,10
@@
do
timestamps = default_timestamp; -- Default format
end
timestamps = default_timestamp; -- Default format
end
+ if sink_config.buffer_mode ~= false then
+ io.stdout:setvbuf(sink_config.buffer_mode or "line");
+ end
+
return function (name, level, message, ...)
sourcewidth = math_max(#name+2, sourcewidth);
local namelen = #name;
return function (name, level, message, ...)
sourcewidth = math_max(#name+2, sourcewidth);
local namelen = #name;
@@
-247,7
+255,12
@@
function log_sink_types.file(sink_config)
if not logfile then
return empty_function;
end
if not logfile then
return empty_function;
end
- local write, flush = logfile.write, logfile.flush;
+
+ if sink_config.buffer_mode ~= false then
+ logfile:setvbuf(sink_config.buffer_mode or "line");
+ end
+
+ local write = logfile.write;
local timestamps = sink_config.timestamps;
local timestamps = sink_config.timestamps;
@@
-264,7
+277,6
@@
function log_sink_types.file(sink_config)
else
write(logfile, name, "\t" , level, "\t", message, "\n");
end
else
write(logfile, name, "\t" , level, "\t", message, "\n");
end
- flush(logfile);
end;
end
end;
end