made all logs from tsched start with [tsched]

i also converted some stuff to use string.format, and lazyvim also
reformatted them again
This commit is contained in:
Ponali
2025-10-15 19:03:49 +02:00
parent d771a1fe39
commit 26c1f055d8
2 changed files with 19 additions and 9 deletions
+9 -4
View File
@@ -76,10 +76,15 @@ function module.init()
idCounter = idCounter + 1 idCounter = idCounter + 1
if taskInfo.parent then if taskInfo.parent then
log.kernel.info( log.kernel.info(
"Created task " .. name .. " with PID " .. idCounter - 1 .. " by parent with PID " .. taskInfo.parent string.format(
"[tsched] Created task %s with PID %d by parent with PID %d",
name,
idCounter - 1,
taskInfo.parent
)
) )
else else
log.kernel.info("Created task " .. name .. " with PID " .. idCounter - 1 .. " (no parent found)") log.kernel.info(string.format("[tsched] Created task %s with PID %d (no parent found)", name, idCounter - 1))
end end
return task, taskInfo return task, taskInfo
end end
@@ -90,11 +95,11 @@ function module.init()
for index, task in pairs(tsched.tasks) do for index, task in pairs(tsched.tasks) do
if task.id == id then if task.id == id then
table.remove(tsched.tasks, index) table.remove(tsched.tasks, index)
log.kernel.info("Removed task with PID " .. id) log.kernel.info(string.format("[tsched] Removed task with PID %d", id))
return true return true
end end
end end
log.kernel.warn("Tried to remove task that doesn't exist - PID " .. id) log.kernel.warn(string.format("[tsched] Tried to remove task that doesn't exist - PID %d", id))
return false return false
end end
+10 -5
View File
@@ -9,11 +9,16 @@ function handleError(errormsg)
local traceback = debug.traceback() local traceback = debug.traceback()
if errormsg == nil then -- TODO: Replace with proper error handling if errormsg == nil then -- TODO: Replace with proper error handling
print("\27[91munknown error" .. "\n \n" .. traceback) print("\27[91munknown error" .. "\n \n" .. traceback)
log.kernel.error(string.format("Process ID %d has crashed!\n\n%s", tsched.currentTask.id, traceback)) log.kernel.error(string.format("[tsched] Process ID %d has crashed!\n\n%s", tsched.currentTask.id, traceback))
else else
print("\27[91m" .. tostring(errormsg) .. "\n \n" .. traceback) print("\27[91m" .. tostring(errormsg) .. "\n \n" .. traceback)
log.kernel.error( log.kernel.error(
string.format("Process ID %d has crashed: %s\n\n%s", tsched.currentTask.id, tostring(errormsg), traceback) string.format(
"[tsched] Process ID %d has crashed: %s\n\n%s",
tsched.currentTask.id,
tostring(errormsg),
traceback
)
) )
end end
end end
@@ -27,7 +32,7 @@ local function runTasks()
handleError(errorMessage) handleError(errorMessage)
end end
if not tsched.tasks[i] then if not tsched.tasks[i] then
log.kernel.warn("Attempted to update a non-existent task. This is likely because it was removed.") log.kernel.warn("[tsched] Attempted to update a non-existent task. This is likely because it was removed.")
elseif coroutine.status(tsched.tasks[i].task) == "dead" then elseif coroutine.status(tsched.tasks[i].task) == "dead" then
_PUBLIC.tsched.removeTask(tsched.tasks[i].id) _PUBLIC.tsched.removeTask(tsched.tasks[i].id)
--ocelot.log("Removed coroutine") --ocelot.log("Removed coroutine")
@@ -39,7 +44,7 @@ local function runTasks()
end end
end end
log.kernel.info("Starting startup apps...") log.kernel.info("[tsched] Starting startup apps...")
local handle, data, tmpdata = filesystem.open("/halyde/config/startupapps.json", "r"), "", nil local handle, data, tmpdata = filesystem.open("/halyde/config/startupapps.json", "r"), "", nil
repeat repeat
tmpdata = handle:read(math.huge or math.maxinteger) tmpdata = handle:read(math.huge or math.maxinteger)
@@ -61,7 +66,7 @@ log.setPrintLogs(false)
while true do while true do
runTasks() runTasks()
if #_G.tsched.tasks == 0 then if #_G.tsched.tasks == 0 then
log.kernel.warn("No more tasks left! Shutting down...") log.kernel.warn("[tsched] No more tasks left! Shutting down...")
computer.shutdown() computer.shutdown()
end end
end end