Make logfiles Minetest-independent

This commit is contained in:
Lars Mueller 2021-04-21 21:28:27 +02:00
parent f516cc6bb8
commit 1ed07d6015
2 changed files with 11 additions and 9 deletions

@ -78,7 +78,7 @@ end
local load_module, get_resource, loadfile_exports
modlib = setmetatable({
-- TODO bump on release
version = 63,
version = 64,
modname = minetest and minetest.get_current_modname(),
dir_delim = rawget(_G, "DIR_DELIM") or "/",
_RG = setmetatable({}, {

@ -2,11 +2,11 @@ lua_log_file = {}
local files = {}
local metatable = {__index = lua_log_file}
-- TODO register on shutdown
function lua_log_file.new(file_path, root)
local self = setmetatable({file_path = assert(file_path), root = root}, metatable)
if minetest then
files[self] = true
end
return self
end
@ -53,11 +53,13 @@ function lua_log_file:close()
files[self] = nil
end
if minetest then
minetest.register_on_shutdown(function()
for self in pairs(files) do
self.file:close()
end
end)
end
-- TODO use shorthand notations
function lua_log_file:dump(value)