Oct-16-2020, 11:26 PM
Hey Everyone,
Does anyone have any good ideas for Error Logging?
Obviously, Try-Except will be used. but I am curious how you guys handle the actual logging.
Right now, I have all the logging stored in a file named after the date. then the error is appended to it with the time.
Here is an example:
File Name: Thu-Oct-15-2020.txt
I am running into two problems:
one: as you can see, if an error occurs, but isn't "program ending", it will inform me of the error every time it happens. which means I end up with the same being logged, multiple times. I'd like a way for the program to look up if its happened before, and simply ignore it if it's already logged. Or at least, just append the time. The only way I can think about doing this is with Mysql, or another DB. Anyone have any ideas?
two: When the error details show up in the terminal, it gives me all the information. Including what function was called when the error occurred, and in what file. When I transfer it to the file, it's just the error. the code format I use is:
I am assuming there is methods within e that need to be called to do it?
Does anyone have any good ideas for Error Logging?
Obviously, Try-Except will be used. but I am curious how you guys handle the actual logging.
Right now, I have all the logging stored in a file named after the date. then the error is appended to it with the time.
Here is an example:
File Name: Thu-Oct-15-2020.txt
1 2 3 4 5 6 7 8 |
20 : 15 : 43 : CCS811 Sensor Needs to be recalibrated 20 : 15 : 59 : CCS811 Sensor Needs to be recalibrated 20 : 16 : 15 : CCS811 Sensor Needs to be recalibratedp |
one: as you can see, if an error occurs, but isn't "program ending", it will inform me of the error every time it happens. which means I end up with the same being logged, multiple times. I'd like a way for the program to look up if its happened before, and simply ignore it if it's already logged. Or at least, just append the time. The only way I can think about doing this is with Mysql, or another DB. Anyone have any ideas?
two: When the error details show up in the terminal, it gives me all the information. Including what function was called when the error occurred, and in what file. When I transfer it to the file, it's just the error. the code format I use is:
1 2 3 4 |
Try: code to be done except Exceptions as e: appendtotextfilefunction(e) |