Make nulllib.logging optional for other libs
This commit is contained in:
parent
7fdd8a5998
commit
13033ecfa1
@ -1,5 +1,13 @@
|
|||||||
local sharedconfig={}
|
local sharedconfig={}
|
||||||
local logging=require((...):gsub("(.)$", "%1.") .. 'logging')
|
|
||||||
|
local fallback=setmetatable({}, {__index=function() return function() end end})
|
||||||
|
local function optrequire(...)
|
||||||
|
local status, req=pcall(require, ...)
|
||||||
|
if status then return req end
|
||||||
|
return fallback
|
||||||
|
end
|
||||||
|
|
||||||
|
local logging=optrequire((...):gsub("(.)$", "%1.") .. 'logging')
|
||||||
local sharedstate=require((...):gsub("(.)$", "%1.") .. 'sharedstate')
|
local sharedstate=require((...):gsub("(.)$", "%1.") .. 'sharedstate')
|
||||||
sharedstate=require('nulllib.sharedstate')
|
sharedstate=require('nulllib.sharedstate')
|
||||||
|
|
||||||
|
@ -1,5 +1,13 @@
|
|||||||
local sharedstate={}
|
local sharedstate={}
|
||||||
local logging=require((...):gsub("(.)$", "%1.") .. 'logging')
|
local fallback=setmetatable({}, {__index=function() return function() end end})
|
||||||
|
local function optrequire(...)
|
||||||
|
local status, req=pcall(require, ...)
|
||||||
|
if status then return req end
|
||||||
|
return fallback
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local logging=optrequire((...):gsub("(.)$", "%1.") .. 'logging')
|
||||||
|
|
||||||
-- function names
|
-- function names
|
||||||
local is_initialized, callback_value, set_value,
|
local is_initialized, callback_value, set_value,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user