aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_scansion_record.lua
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
commit491c573ed2a1c91aae993cee92030690017baa6a (patch)
tree87c886c6e10ea820923130b492a77119be816bfe /plugins/mod_scansion_record.lua
parent74ae56ade698a5530125926ac74509e80f9c8ff8 (diff)
downloadprosody-491c573ed2a1c91aae993cee92030690017baa6a.tar.gz
prosody-491c573ed2a1c91aae993cee92030690017baa6a.zip
mod_scansion_record: Merge header and log into one file at shutdown
Diffstat (limited to 'plugins/mod_scansion_record.lua')
-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);