aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2018-09-22 18:43:09 +0200
committerKim Alvefur <zash@zash.se>2018-09-22 18:43:09 +0200
commitf7204447a6af049cdd5ba1e5dcdfbdbbf538f1f9 (patch)
tree87c886c6e10ea820923130b492a77119be816bfe /plugins
parent18537a7bceae249e824a245025f493f62ae3b6b2 (diff)
downloadprosody-f7204447a6af049cdd5ba1e5dcdfbdbbf538f1f9.tar.gz
prosody-f7204447a6af049cdd5ba1e5dcdfbdbbf538f1f9.zip
mod_scansion_record: Merge header and log into one file at shutdown
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_scansion_record.lua13
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/mod_scansion_record.lua b/plugins/mod_scansion_record.lua
index defbbee4..abcbf749 100644
--- a/plugins/mod_scansion_record.lua
+++ b/plugins/mod_scansion_record.lua
@@ -9,11 +9,11 @@ local dm = require "util.datamanager";
local record_id = id.medium():lower();
local record_date = os.date("%Y%b%d"):lower();
-local header_file = dm.getpath(record_id, "scansion", record_date, "sch", true);
-local record_file = dm.getpath(record_id, "scansion", record_date, "scs", true);
+local header_file = dm.getpath(record_id, "scansion", record_date, "scs", true);
+local record_file = dm.getpath(record_id, "scansion", record_date, "log", true);
local head = io.open(header_file, "w");
-local scan = io.open(record_file, "w");
+local scan = io.open(record_file, "w+");
local function record(string)
scan:write(string);
@@ -96,10 +96,15 @@ record[[
module:hook_global("server-stopping", function ()
record("# recording ended on "..dt.datetime().."\n");
- module:log("info", "Scansion recording available in %s", record_file);
+ module:log("info", "Scansion recording available in %s", header_file);
end);
prosody.events.add_handler("server-cleanup", function ()
+ scan:seek("set", 0);
+ for line in scan:lines() do
+ head:write(line, "\n");
+ end
scan:close();
+ os.remove(record_file);
head:close()
end);