Lutron-Smart-Pi
Lutron-Smart-Pi copied to clipboard
Add better logging
The 'print' statements cause issues when trying to run in background on Windows using pythonw.exe.
I added actual logging by adding two logging handlers - one for maintaining the current console outputs for backwards compatability and one TimedRotatingFileHandler that logs all output to 'LutronPi.log' in the current directory with the log file being rotated at midnight. Log file also adds timestamps to all entries.
All 'print' statements were updated to the appropriate logging level (DEBUG, INFO, ERROR).
These changes should be fully backwards compatible but allows the script to be run on Windows with pythonw.exe in the background and optionally as a service (for example using NSSM).