I want to create a log of errors that are encountered while running a python script on the raspberry Pi (an embedded module that uses rasbian which is a kind of linux) so that I can inspect it at a later date to see where problems are occurring. I want to append errors each time the script is run, record the date and the error text (eg as printed out by me within an exception or as generated somewhere within python itself)
I guess this must be a common thing to do, so before I go off an write my own, I was wondering if there is a standard way of doing this kind of thing
I have found some suggestions like this, but it doesnt print the date. Also I was wondering if I should pass fsock
to functions as an argument or is it ok to use a global ....
fsock = open('my_app_error.log', 'a')
sys.stderr = fsock
fsock.write("URLError")