added logging support
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
local yaml = require("utils/yaml")
|
||||
local loader = {}
|
||||
loader.__index = loader
|
||||
|
||||
local loaderLog = log:child("loader")
|
||||
|
||||
function loader:new(path_or_file)
|
||||
local c = {}
|
||||
setmetatable(c, loader)
|
||||
c.source = path_or_file
|
||||
local file = love.filesystem.read(path_or_file .. "/index.yml")
|
||||
|
||||
if not file then
|
||||
loaderLog:error("Unable to load file: %s/index.yml", path_or_file)
|
||||
end
|
||||
|
||||
c.index = yaml.parse(file)
|
||||
|
||||
for i,v in pairs(c.index.categories) do
|
||||
local link = love.filesystem.read(path_or_file .. "/" .. v.name .. ".yml")
|
||||
if not link then
|
||||
loaderLog:error("Error! Cannot find file: %s/%s.yml", path_or_file,v.name)
|
||||
else
|
||||
local category = yaml.parse(link)
|
||||
c.index.categories[i].questions = category.questions
|
||||
c.index.categories[i].global = category.global or {}
|
||||
c.index.categories[i].cosmetics = category.cosmetics or {}
|
||||
end
|
||||
end
|
||||
return c
|
||||
end
|
||||
|
||||
function loader:getCategories()
|
||||
return self.index.categories
|
||||
end
|
||||
|
||||
function loader:getSettings()
|
||||
return self.index.settings
|
||||
end
|
||||
|
||||
return loader
|
||||
Reference in New Issue
Block a user