made stuff more verbose

and also fixed modload using an outdated variant of the log library
This commit is contained in:
Ponali
2025-09-21 18:41:41 +02:00
parent 39897457f9
commit cf26f610b4
2 changed files with 170 additions and 159 deletions
+10 -2
View File
@@ -10,8 +10,12 @@ local moduleTypes = {}
local function loadModule(modName) local function loadModule(modName)
local moduleData = modules[modName] local moduleData = modules[modName]
table.remove(moduleList, table.find(moduleList, modName)) table.remove(moduleList, table.find(moduleList, modName))
if not moduleData then return end if not moduleData then
log.kernel.warn(string.format("[modload: %s] Could not find module data.", modName))
return
end
if not moduleData.check() then if not moduleData.check() then
log.kernel.info(string.format("[modload: %s] Module not ready - skipping", modName))
return return
end end
if moduleData.dependencies then if moduleData.dependencies then
@@ -31,15 +35,19 @@ local function loadModule(modName)
end end
end end
--print(modName) --print(modName)
log.kernel.info(string.format("[modload: %s] Loading module", modName))
if moduleData.init then -- I have no idea why this would not exist, but it's a failsafe if moduleData.init then -- I have no idea why this would not exist, but it's a failsafe
moduleData.init() moduleData.init()
end end
end end
for _, modName in pairs(moduleList) do -- Get all the module types for _, modName in pairs(moduleList) do -- Get all the module types
log.kernel.info(string.format("[modload: %s] Getting data from module", modName))
local moduleData = require(fs.concat(modulePath, modName)) -- TODO: Make this not actually throw an error, rather put something in the log and move on local moduleData = require(fs.concat(modulePath, modName)) -- TODO: Make this not actually throw an error, rather put something in the log and move on
if type(moduleData) ~= "table" then if type(moduleData) ~= "table" then
log.add(string.format("[modload: %s] Module returned invalid type (%s) - skipping",modName,type(moduleData)),"error") log.kernel.error(
string.format("[modload: %s] Module returned invalid type (%s) - skipping", modName, type(moduleData))
)
goto continue goto continue
end end
modules[modName] = moduleData modules[modName] = moduleData
+6 -3
View File
@@ -32,7 +32,9 @@ function _G._PUBLIC.tsched.runAsTask(path, ...)
local userland = table.copy(_PUBLIC) local userland = table.copy(_PUBLIC)
userland._G = userland userland._G = userland
userland.load = function(chunk, chunkname, mode, env) userland.load = function(chunk, chunkname, mode, env)
if not env or env == _G then env = userland end -- if they SOMEHOW get the kernel environment they're not running jack shit if not env or env == _G then
env = userland
end -- if they SOMEHOW get the kernel environment they're not running jack shit
return load(chunk, chunkname, mode, env) return load(chunk, chunkname, mode, env)
end end
userland.require = reqgen(userland.load) userland.require = reqgen(userland.load)
@@ -65,8 +67,9 @@ function _G._PUBLIC.tsched.addTask(func, name)
table.insert(tsched.tasks, taskInfo) table.insert(tsched.tasks, taskInfo)
idCounter = idCounter + 1 idCounter = idCounter + 1
if taskInfo.parent then if taskInfo.parent then
log.kernel.info("Created task " .. name .. " with PID " .. idCounter - 1 .. " by parent with PID " .. taskInfo log.kernel.info(
.parent) "Created task " .. name .. " with PID " .. idCounter - 1 .. " by parent with PID " .. taskInfo.parent
)
else else
log.kernel.info("Created task " .. name .. " with PID " .. idCounter - 1 .. " (no parent found)") log.kernel.info("Created task " .. name .. " with PID " .. idCounter - 1 .. " (no parent found)")
end end