Advertisement
kssr3951

ut(utilities)(API)

Apr 18th, 2015
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.92 KB | None | 0 0
  1. -- -------------------------------
  2. -- ut - utilities(API)
  3. -- -------------------------------
  4. -- ---------------
  5. -- Logger
  6. -- ---------------
  7. -- do logging?
  8. DEBUG__DO_LOGGING           = true
  9. -- local log
  10. DEBUG__LOCAL_ENABLED        = true
  11. DEBUG__LOCAL_LOG_FILE_NAME  = "debug.log"
  12. -- remote log
  13. DEBUG__REMOTE_ENABLED       = false
  14. DEBUG__REMOTE_ADDR          = 20
  15. DEBUG__REMOTE_MODEM_DIR     = "right"
  16. function debug(txt)
  17.   if DEBUG__DO_LOGGING then
  18.     if DEBUG__LOCAL_ENABLED then
  19.       local hFile
  20.       if fs.exists(DEBUG__LOCAL_LOG_FILE_NAME) then
  21.         hFile = fs.open(DEBUG__LOCAL_LOG_FILE_NAME, "a");
  22.       else
  23.         hFile = fs.open(DEBUG__LOCAL_LOG_FILE_NAME, "w");
  24.       end
  25.       hFile.writeLine(txt);
  26.       hFile.close();
  27.     end
  28.     if DEBUG__REMOTE_ENABLED then
  29.       rednet.open(DEBUG__REMOTE_MODEM_DIR)
  30.       rednet.send(DEBUG__REMOTE_ADDR, txt)
  31.       rednet.close()
  32.     end
  33.   end
  34. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement