Add log tool
adds log tool for viewing logs
This commit is contained in:
+12
-2
@@ -1,5 +1,6 @@
|
|||||||
local component = require("component")
|
local component = require("component")
|
||||||
local computer = require("computer")
|
local computer = require("computer")
|
||||||
|
local filesystem = require("filesystem")
|
||||||
|
|
||||||
local function printstat(text)
|
local function printstat(text)
|
||||||
local cursorPosX, cursorPosY = terminal.getCursorPos()
|
local cursorPosX, cursorPosY = terminal.getCursorPos()
|
||||||
@@ -7,7 +8,14 @@ local function printstat(text)
|
|||||||
terminal.write(text .. "\n", false)
|
terminal.write(text .. "\n", false)
|
||||||
end
|
end
|
||||||
|
|
||||||
terminal.write(_OSLOGO, false)
|
local logo = ""
|
||||||
|
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
|
||||||
|
repeat
|
||||||
|
tmpdata = handle:read(math.inf or math.maxinteger)
|
||||||
|
logo = logo .. (tmpdata or "")
|
||||||
|
until not tmpdata
|
||||||
|
|
||||||
|
terminal.write(logo, false)
|
||||||
local cursorPosX, cursorPosY = terminal.getCursorPos()
|
local cursorPosX, cursorPosY = terminal.getCursorPos()
|
||||||
terminal.setCursorPos(cursorPosX, cursorPosY - 17)
|
terminal.setCursorPos(cursorPosX, cursorPosY - 17)
|
||||||
printstat("\27[92mOS\27[0m: " .. _OSVERSION)
|
printstat("\27[92mOS\27[0m: " .. _OSVERSION)
|
||||||
@@ -18,7 +26,9 @@ for _, _ in component.list() do
|
|||||||
end
|
end
|
||||||
printstat("\27[92mComponents\27[0m: " .. tostring(componentCounter))
|
printstat("\27[92mComponents\27[0m: " .. tostring(componentCounter))
|
||||||
printstat("\27[92mCoroutines\27[0m: " .. tostring(#tsched.getTasks()))
|
printstat("\27[92mCoroutines\27[0m: " .. tostring(#tsched.getTasks()))
|
||||||
printstat("\27[92mBattery\27[0m: "..tostring(math.floor(computer.energy() / computer.maxEnergy() * 1000 + 0.5) / 10).."%")
|
printstat(
|
||||||
|
"\27[92mBattery\27[0m: " .. tostring(math.floor(computer.energy() / computer.maxEnergy() * 1000 + 0.5) / 10) .. "%"
|
||||||
|
)
|
||||||
local totalMemory = computer.totalMemory()
|
local totalMemory = computer.totalMemory()
|
||||||
local usedMemory = computer.totalMemory() - computer.freeMemory()
|
local usedMemory = computer.totalMemory() - computer.freeMemory()
|
||||||
local totalMemoryString
|
local totalMemoryString
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
local loadfile = ...
|
local loadfile = ...
|
||||||
local filesystem = assert(loadfile("/lib/filesystem.lua")(loadfile))
|
local filesystem = assert(loadfile("/lib/filesystem.lua")(loadfile))
|
||||||
_G._OSVERSION = "HALYDE VERSION" -- TODO: Put this in a separate config file
|
_G._OSVERSION = "HALYDE VERSION" -- TODO: Put this in a separate config file
|
||||||
_G._OSLOGO = ""
|
|
||||||
_G._PUBLIC = {}
|
_G._PUBLIC = {}
|
||||||
_G._PUBLIC.unicode = assert(loadfile("/lib/unicode.lua")(loadfile))
|
_G._PUBLIC.unicode = assert(loadfile("/lib/unicode.lua")(loadfile))
|
||||||
local component = assert(loadfile("/lib/component.lua")(loadfile))
|
local component = assert(loadfile("/lib/component.lua")(loadfile))
|
||||||
@@ -15,13 +14,6 @@ local log = assert(loadfile("/lib/log.lua")(loadfile))
|
|||||||
|
|
||||||
log.kernel.info("Bound GPU to screen " .. tostring(screenAddress))
|
log.kernel.info("Bound GPU to screen " .. tostring(screenAddress))
|
||||||
|
|
||||||
local handle, tmpdata = filesystem.open("/halyde/config/oslogo.ans", "r"), nil
|
|
||||||
repeat
|
|
||||||
tmpdata = handle:read(math.huge)
|
|
||||||
_OSLOGO = _OSLOGO .. (tmpdata or "")
|
|
||||||
until not tmpdata
|
|
||||||
handle:close()
|
|
||||||
|
|
||||||
log.kernel.info("Loaded OS logo")
|
log.kernel.info("Loaded OS logo")
|
||||||
|
|
||||||
_G.package = { ["preloaded"] = {} }
|
_G.package = { ["preloaded"] = {} }
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ function module.init()
|
|||||||
"print",
|
"print",
|
||||||
"_VERSION",
|
"_VERSION",
|
||||||
"_OSVERSION",
|
"_OSVERSION",
|
||||||
"_OSLOGO",
|
|
||||||
"assert",
|
"assert",
|
||||||
"error",
|
"error",
|
||||||
"getmetatable",
|
"getmetatable",
|
||||||
@@ -39,7 +38,7 @@ function module.init()
|
|||||||
"table",
|
"table",
|
||||||
"checkArg",
|
"checkArg",
|
||||||
"utf8",
|
"utf8",
|
||||||
"convert"
|
"convert",
|
||||||
}
|
}
|
||||||
for _, value in ipairs(publicTable) do
|
for _, value in ipairs(publicTable) do
|
||||||
_G._PUBLIC[value] = table.copy(_G[value])
|
_G._PUBLIC[value] = table.copy(_G[value])
|
||||||
|
|||||||
Reference in New Issue
Block a user