mirror of
https://github.com/appgurueu/modlib.git
synced 2024-11-22 23:33:53 +01:00
Make logfiles Minetest-independent
This commit is contained in:
parent
f516cc6bb8
commit
1ed07d6015
2
init.lua
2
init.lua
@ -78,7 +78,7 @@ end
|
|||||||
local load_module, get_resource, loadfile_exports
|
local load_module, get_resource, loadfile_exports
|
||||||
modlib = setmetatable({
|
modlib = setmetatable({
|
||||||
-- TODO bump on release
|
-- TODO bump on release
|
||||||
version = 63,
|
version = 64,
|
||||||
modname = minetest and minetest.get_current_modname(),
|
modname = minetest and minetest.get_current_modname(),
|
||||||
dir_delim = rawget(_G, "DIR_DELIM") or "/",
|
dir_delim = rawget(_G, "DIR_DELIM") or "/",
|
||||||
_RG = setmetatable({}, {
|
_RG = setmetatable({}, {
|
||||||
|
@ -2,11 +2,11 @@ lua_log_file = {}
|
|||||||
local files = {}
|
local files = {}
|
||||||
local metatable = {__index = lua_log_file}
|
local metatable = {__index = lua_log_file}
|
||||||
|
|
||||||
-- TODO register on shutdown
|
|
||||||
|
|
||||||
function lua_log_file.new(file_path, root)
|
function lua_log_file.new(file_path, root)
|
||||||
local self = setmetatable({file_path = assert(file_path), root = root}, metatable)
|
local self = setmetatable({file_path = assert(file_path), root = root}, metatable)
|
||||||
files[self] = true
|
if minetest then
|
||||||
|
files[self] = true
|
||||||
|
end
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,11 +53,13 @@ function lua_log_file:close()
|
|||||||
files[self] = nil
|
files[self] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_on_shutdown(function()
|
if minetest then
|
||||||
for self in pairs(files) do
|
minetest.register_on_shutdown(function()
|
||||||
self.file:close()
|
for self in pairs(files) do
|
||||||
end
|
self.file:close()
|
||||||
end)
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
-- TODO use shorthand notations
|
-- TODO use shorthand notations
|
||||||
function lua_log_file:dump(value)
|
function lua_log_file:dump(value)
|
||||||
|
Loading…
Reference in New Issue
Block a user