Save-Point
Write Errors To file - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Archives (https://www.save-point.org/forum-105.html)
+--- Forum: Creation Asylum Archives (https://www.save-point.org/forum-90.html)
+---- Forum: Scripts & Code Snippets (https://www.save-point.org/forum-92.html)
+----- Forum: RPG Maker XP Code (https://www.save-point.org/forum-93.html)
+----- Thread: Write Errors To file (/thread-6868.html)



Write Errors To file - Derk-Jan - 05-03-2006

Write Errors To file
by Me™ (aka Derk-Jan)
May 3 2006

This is a locked, single-post thread from Creation Asylum. Archived here to prevent its loss.
No support is given.


This script is mainly for developers and Beta/Alpha Testers. It contains out of two poportions. What it does: Everytime an error occurs, it will write down the error, and the time to a file. This works for ALL standard errors and file-errors. Only System/Ruby Errors can not be handled yet (altough I have an idee) This is because the classes have there own Initialize (System Error's Superclass is StandardError, StandardError's Superclass is Expetion.)

Add this above everything:

Code:
class Exception
   alias :old_init :initialize
   def initialize(arg)
       old_init(arg)
       time = Time.strftime("%a %d %b %Y, %X")
       File.open("ErrorLog.txt","a+"){ |fh| fh.puts("On <<#{time}>> the error <<#{arg}>> occured.")}
    end
end

And this in main, below the print

Code:
time = Time.strftime("%a %d %b %Y, %X")
  File.open("ErrorLog.txt","a+"){ |fh| fh.puts("On <<#{time}>> Unable to find the file #{filename}.")}

It took me quite some time to figure this out. I dont NEED credit, but I would LIKE it



(you might want to add: time = Time.now, time = time.strftime("%a %d %b %Y, %X") )