comparison mod_mam/mod_mam.lua @ 2042:752eee154891

mod_mam: Add some debug logging
author Kim Alvefur <zash@zash.se>
date Thu, 04 Feb 2016 13:38:06 +0100
parents 464edd03099a
children 50c188cf0ae3
comparison
equal deleted inserted replaced
2041:7c61ab512d0b 2042:752eee154891
282 return false; 282 return false;
283 end 283 end
284 284
285 cleanup_after = tonumber(n) * ( multipliers[m] or 1 ); 285 cleanup_after = tonumber(n) * ( multipliers[m] or 1 );
286 286
287 module:log("debug", "archive_expires_after = %d -- in seconds", cleanup_after);
288
287 if not archive.delete then 289 if not archive.delete then
288 module:log("error", "archive_expires_after set but mod_%s does not support deleting", archive._provided_by); 290 module:log("error", "archive_expires_after set but mod_%s does not support deleting", archive._provided_by);
289 return false; 291 return false;
290 end 292 end
291 293
303 if user then 305 if user then
304 module:log("debug", "Removing old messages for user %q", user); 306 module:log("debug", "Removing old messages for user %q", user);
305 local ok, err = archive:delete(user, { ["end"] = os.time() - cleanup_after; }) 307 local ok, err = archive:delete(user, { ["end"] = os.time() - cleanup_after; })
306 if not ok then 308 if not ok then
307 module:log("warn", "Could not expire archives for user %s: %s", user, err); 309 module:log("warn", "Could not expire archives for user %s: %s", user, err);
310 else
311 -- :affected() is a recent addition for eg SQLite3 in LuaDBI
312 pcall(function(stmt)
313 module:log("debug", "Removed %d messages", stmt:affected());
314 end, err);
308 end 315 end
309 cleanup[user] = nil; 316 cleanup[user] = nil;
310 end 317 end
311 return math.random(cleanup_interval, cleanup_interval * 2); 318 return math.random(cleanup_interval, cleanup_interval * 2);
312 end); 319 end);