Software /
code /
prosody-modules
Changeset
5714:78f766372e2c
mod_storage_appendmap: Include timestamps when appending data
Meant to give some sense of when each piece of data was added, to aid in
debugging changes or manual rollbacks.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 05 Nov 2023 21:06:23 +0100 |
parents | 5713:ea6c18ec0669 |
children | 5715:aa94d5bb6b10 |
files | mod_storage_appendmap/mod_storage_appendmap.lua |
diffstat | 1 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_storage_appendmap/mod_storage_appendmap.lua Sun Nov 05 21:03:30 2023 +0100 +++ b/mod_storage_appendmap/mod_storage_appendmap.lua Sun Nov 05 21:06:23 2023 +0100 @@ -1,11 +1,13 @@ local dump = require "util.serialization".serialize; local load = require "util.envload".envloadfile; +local datetime = require "util.datetime".datetime; local dm = require "core.storagemanager".olddm; local REMOVE = {}; -- Special value for removing keys local driver = {}; +local timestamps = module:get_option_boolean("appendmap_timestamps", true); local keywords = { ["do"] = true; ["and"] = true; ["else"] = true; ["break"] = true; @@ -82,6 +84,9 @@ function map:set_keys(user, keyvalues) local data = serialize_map(keyvalues); + if timestamps then + data = "-- " .. datetime() .. "\n" .. data; + end return dm.append_raw(user, module.host, self.store, "map", data); end @@ -94,6 +99,9 @@ return os.remove(filename); end local data = serialize_pair(key, value); + if timestamps then + data = "-- " .. datetime() .. "\n" .. data; + end return dm.append_raw(user, module.host, self.store, "map", data); end @@ -110,6 +118,9 @@ function keyval:set(user, keyvalues) local data = serialize_map(keyvalues); + if timestamps then + data = "-- " .. datetime() .. "\n" .. data; + end return dm.store_raw(dm.getpath(user, module.host, self.store, "map"), data); end