linted / Skip-Trace

Track down your lost or stolen computer
MIT License
3 stars 1 forks source link

Set up logging for all errors/exceptions #9

Closed msmith533 closed 7 years ago

msmith533 commented 7 years ago

Keep an error log on disk rather than piping all error messages to stdout. This will allow for easier debugging, especially over longer periods of time. The error log needs to be timestamped, and a system for creating new and deleting old, no longer relevant log files needs to be created.

linted commented 7 years ago

would we only want the log file kept during the current execution? If so we could just open a file as write instead of append at the start of the program. That will over write anything that was originally there. After that we could do appends. Personally would prefer not to keep the file open during the duration of the program. The difference would be an open file for days, weeks, or possibly months on end, versus a large number of opens and writes. Of course we could limit the number of opens by opening the file when we get/send a request and closing when we finish with the request.

msmith533 commented 7 years ago

Those are good questions. I've only worked with logging frameworks before, which abstract out all of those decisions. I'd like to research some common implementations.

linted commented 7 years ago

I found This Library for python logging, and this HOW TO that shows how to set up file logging. I think it would be relatively trivial for us to implement this. thoughts?

calebmckay commented 7 years ago

Setting up a logrotate cron-job looks like exactly what you'd need. It can rotate out old log files each day/week or when they reach a certain size. If needed, you could add some user configuration for rotate frequency, though that may be overkill. As for adding the actual logging capability, looks like it'd be a piece of cake with that Python Logging library.

linted commented 7 years ago

I am not sure i want to start dealing with cron jobs if we don't have to, although that looks like an amazing feature. For now lets just swap out the print statements, and have the log file cleared on restart of the service. Any extra log features we can add to a new issue request.

calebmckay commented 7 years ago

I think I misread the article. You don't have to set up a whole cron job for it - there's already a /etc/cron.daily entry for logrotate, so you just have to add an entry to /etc/logrotate.d. Here's an example. But I'm fine with putting that off until after the main logging is in place.

calebmckay commented 7 years ago

Functionality added in Pull Request #12, pending review.