# HG changeset patch # User Kim Alvefur # Date 1537634589 -7200 # Node ID dd452f932b67662bd1b5242a3cb42c4b8eeadef3 # Parent 0c5177738ffd0163e4d7e0307c364bcbd763a13a mod_scansion_record: Merge header and log into one file at shutdown diff -r 0c5177738ffd -r dd452f932b67 plugins/mod_scansion_record.lua --- a/plugins/mod_scansion_record.lua Sat Sep 22 18:32:22 2018 +0200 +++ b/plugins/mod_scansion_record.lua Sat Sep 22 18:43:09 2018 +0200 @@ -9,11 +9,11 @@ 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 @@ 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);