Newer
Older
Kristify / src / libs / Basalt / libraries / basaltLogs.lua
@Erb3 Erb3 on 14 Nov 2022 566 bytes Get ready to develop backend
local logDir = ""
local logFileName = "basaltLog.txt"

local defaultLogType = "Debug"

fs.delete(logDir~="" and logDir.."/"..logFileName or logFileName)

local mt = {
    __call = function(_,text, typ)
        if(text==nil)then return end
        local dirStr = logDir~="" and logDir.."/"..logFileName or logFileName
        local handle = fs.open(dirStr, fs.exists(dirStr) and "a" or "w")
        handle.writeLine("[Basalt]["..(typ and typ or defaultLogType).."]: "..tostring(text))
        handle.close()
    end,
}

return setmetatable({}, mt)

--Work in progress