samdeman22

Log API

Mar 5th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.05 KB | None | 0 0
  1. --The Log API 1.0
  2.  
  3. function openLog(name)
  4.     h = fs.open("log/"..name..".log", a)
  5. end
  6.  
  7. function closeLog()
  8.     h.close()
  9. end
  10.  
  11. 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)
  12.  
  13.     local runningProgram = shell.getRunningProgram()
  14.    
  15.     if not fs.exists("log") then
  16.         fs.mkDir("log")
  17.     end
  18.    
  19.     if not fs.exists("log/"..runningProgram..".log")
  20.         h = fs.open("log/"..runningProgram..".log", a)
  21.         h.writeLine("--- The "..runningProgram.." event log ---")
  22.         h.writeLine(" ")
  23.         h.close()
  24.     end
  25. end
  26.  
  27. function addEntry(type, str)
  28.     local time = os.time()
  29.     local day = os.day()
  30.     h.writeLine("["..day.."]".."["..time.."]".."["..type.."] | #"..str)
  31. end
  32.  
  33. function startLog()
  34.     local time = os.time()
  35.     local day = os.day()
  36.     h.writeLine("["..day.."]".."["..time.."] | #STARTING LOG")
  37. end
  38.  
  39. function endLog()
  40.     local time = os.time()
  41.     local day = os.day()
  42.     h.writeLine("["..day.."]".."["..time.."] | #ENDING LOG")
  43.    
  44. end
  45.  
  46. function printLog(log, fromPage, toPage,)
  47.    
  48. end
Advertisement
Add Comment
Please, Sign In to add comment