Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --The Log API 1.1
- runningProgram = "test"
- function openLog(name)
- h = fs.open("logs/"..name..".log", "a")
- end
- function closeLog()
- h.close()
- end
- --function setRunningProgram(name)
- -- runningProgram = name
- --end
- function generateLog() --will create the Dir "log" in the root and create a .log file based on the running program (if if is not already there)
- if not fs.exists("log") then
- fs.mkDir("log")
- end
- if runningProgram == nil then
- error("program not specified")
- end
- h = fs.open("logs/"..runningProgram..".log", "a")
- h.writeLine("--- The "..runningProgram.." event log ---")
- h.writeLine(" ")
- h.close()
- end
- function addEntry(type, str)
- local time = os.time()
- local day = os.day()
- h.writeLine("["..day.."]".."["..time.."]".."["..type.."] | #"..str)
- end
- function startLog()
- open = true
- local time = os.time()
- local day = os.day()
- openLog()
- h.writeLine("["..day.."]".."["..time.."] | #STARTING LOG")
- end
- function endLog()
- open = false
- local time = os.time()
- local day = os.day()
- h.writeLine("["..day.."]".."["..time.."] | #ENDING LOG")
- end
- function setPrinterSide(side)
- printside = side
- end
- function printLog(log, fromLn, copies)
- if open == true then
- error("Log must be ended before printing")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement