comparison mod_message_logging/mod_message_logging.lua @ 1501:4b55110b0aa8

mod_message_logging: Add timestamp to logs
author Matthew Wild <mwild1@gmail.com>
date Sun, 07 Sep 2014 12:19:25 +0100
parents 045720a5fccd
children ba71d0ad5564
comparison
equal deleted inserted replaced
1500:045720a5fccd 1501:4b55110b0aa8
53 local function write_to_log(log_jid, jid, prefix, body) 53 local function write_to_log(log_jid, jid, prefix, body)
54 if not body then return; end 54 if not body then return; end
55 local f = open_files[log_jid]; 55 local f = open_files[log_jid];
56 if not f then return; end 56 if not f then return; end
57 body = body:gsub("\n", "\n "); -- Indent newlines 57 body = body:gsub("\n", "\n "); -- Indent newlines
58 f:write(prefix or "", prefix and ": " or "", jid, ": ", body, "\n"); 58 f:write(os.date("%H:%M:%S "), prefix or "", prefix and ": " or "", jid, ": ", body, "\n");
59 f:flush(); 59 f:flush();
60 end 60 end
61 61
62 local function handle_incoming_message(event) 62 local function handle_incoming_message(event)
63 local origin, stanza = event.origin, event.stanza; 63 local origin, stanza = event.origin, event.stanza;