Software /
code /
prosody
Changeset
9369:dd452f932b67
mod_scansion_record: Merge header and log into one file at shutdown
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 22 Sep 2018 18:43:09 +0200 |
parents | 9368:0c5177738ffd |
children | 9370:7872abb9fc1f |
files | plugins/mod_scansion_record.lua |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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);