diff --git a/framework/update_archive.py b/framework/update_archive.py index e38dad5..f0ffadb 100644 --- a/framework/update_archive.py +++ b/framework/update_archive.py @@ -38,7 +38,7 @@ def update_archive(self): Out_Wind_Max=now.Out_Wind_Max, Out_Rain_Minute=rain_amount, Now_Feel=now.Now_Feel) - logging.getLogger("thread").info(" Sensor Data Archived.") + logging.getLogger("thread-archive").info(" Sensor data archived.") # # This deletes old rain data from the 'rain' table. This data is no longer needed, @@ -57,4 +57,4 @@ def update_clean_old(self): if (datetime.datetime.now() - rain.time) > datetime.timedelta(days = how_many_days_of_rain_data_to_keep): rain.destroySelf() number_cleaned = number_cleaned + 1 - logging.getLogger("thread").info(" Rain Table Cleaned. (" + str(number_cleaned) + " entries purged in " + str((time.time() - start)*1000) + "ms)") \ No newline at end of file + logging.getLogger("thread-clean").info(" Rain table cleaned. (" + str(number_cleaned) + " entries purged in " + str((time.time() - start)*1000) + "ms)") \ No newline at end of file diff --git a/framework/update_feels_like.py b/framework/update_feels_like.py index dd73877..f0f673d 100644 --- a/framework/update_feels_like.py +++ b/framework/update_feels_like.py @@ -24,4 +24,4 @@ def update_feels_like(self): now = Table_Now.get(1) now.Now_URL = NOW_URL now.Now_Feel = NOW_Feel - logging.getLogger("thread").info(" Updated Feels Like Data.") \ No newline at end of file + logging.getLogger("thread-feels").info(" Updated feels like info.") \ No newline at end of file diff --git a/framework/update_rain_compile.py b/framework/update_rain_compile.py index ed4941b..3d5465e 100644 --- a/framework/update_rain_compile.py +++ b/framework/update_rain_compile.py @@ -32,4 +32,4 @@ def update_rain_compile(self): now.Out_Rain_Last_24h = rain_24h now.Out_Rain_Today = rain_today - logging.getLogger("thread").info(" Compiled Rain Data.") \ No newline at end of file + logging.getLogger("thread-rain_compile").info(" Compiled rain pulse data.") \ No newline at end of file diff --git a/framework/update_sensor_rain.py b/framework/update_sensor_rain.py index a21c3a8..11a07b8 100644 --- a/framework/update_sensor_rain.py +++ b/framework/update_sensor_rain.py @@ -21,4 +21,4 @@ def update_sensor_rain(self): now = Table_Now.get(1) now.sync() now.Out_Rain_Since_Reset = now.Out_Rain_Since_Reset + rainTipAmount - logging.getLogger("thread").info(" Caused A Fake Rain Pulse.") \ No newline at end of file + logging.getLogger("thread-rain_fake").info(" Caused a fake rain pulse.") \ No newline at end of file diff --git a/framework/update_sensors.py b/framework/update_sensors.py index e672ef2..c58a00f 100644 --- a/framework/update_sensors.py +++ b/framework/update_sensors.py @@ -39,12 +39,12 @@ def run(self): time.sleep(1) #Then tell deamon threads to die, and reap their souls - logging.getLogger("thread").info(" Telling sensor threads to die...") + logging.getLogger("thread-sensors").info(" Telling sensor threads to die...") for thread in sensor_threads: thread.stop() for thread in sensor_threads: thread.join(how_long_to_wait_before_killing_deamons) - logging.getLogger("thread").debug(" Sensor threads have been killed!") + logging.getLogger("thread-sensors").debug(" Sensor threads have been killed!") # Thread for updating the outside T/H sensor class update_outside(stoppable_thread): @@ -58,7 +58,7 @@ def run(self): now.Out_Temp = sum(OUT_Temp_Q['Q']) / float(len(OUT_Temp_Q['Q'])) now.Out_Humid = sum(OUT_Humid_Q['Q']) / float(len(OUT_Humid_Q['Q'])) - logging.getLogger("sensor").debug(" Updated Outside Sensor Data.") + logging.getLogger("sensor").debug(" Updated outside sensor data.") time.sleep(how_often_to_check_temp) # Thread for updating the attic T/H sensor @@ -73,7 +73,7 @@ def run(self): now.Attic_Temp = sum(ATT_Temp_Q['Q']) / float(len(ATT_Temp_Q['Q'])) now.Attic_Humid = sum(ATT_Humid_Q['Q']) / float(len(ATT_Humid_Q['Q'])) - logging.getLogger("sensor").debug(" Updated Attic Sensor Data.") + logging.getLogger("sensor").debug(" Updated attic sensor data.") time.sleep(how_often_to_check_temp) # Thread for updating the inside T/H sensor @@ -88,7 +88,7 @@ def run(self): now.In_Temp = sum(IN_Temp_Q['Q']) / float(len(IN_Temp_Q['Q'])) now.In_Humid = sum(IN_Humid_Q['Q']) / float(len(IN_Humid_Q['Q'])) - logging.getLogger("sensor").debug(" Updated Inside Sensor Data.") + logging.getLogger("sensor").debug(" Updated inside sensor data.") time.sleep(how_often_to_check_temp) # Thread for updating the wind sensor @@ -104,7 +104,7 @@ def run(self): now.Out_Wind_Avg = sum(Wind_Avg_Q['Q']) / float(len(Wind_Avg_Q['Q'])) now.Out_Wind_Max = max(Wind_Max_Q['Q']) - logging.getLogger("sensor").debug(" Updated Wind Data.") + logging.getLogger("sensor").debug(" Updated wind data.") time.sleep(how_often_to_check_wind) # Thread for updating the system stats @@ -115,7 +115,7 @@ def run(self): now.System_CPU = sensors.read_cpu_usage() now.System_RAM = sensors.read_ram_usage() - logging.getLogger("sensor").debug(" Updated SYSTEM Data.") + logging.getLogger("sensor").debug(" Updated SYSTEM data.") time.sleep(how_often_to_check_system) # This takes a dequeue, and a reading, and adds that reading to the dequeue. @@ -126,7 +126,7 @@ def add_reading_to_dequeue(dequeue, new_reading): (dequeue)['Fails'] = 0 elif dequeue['Fails'] < failed_readings_before_error: dequeue['Fails'] = dequeue['Fails'] + 1 - logging.getLogger("thread_sensors").warning(" Failed to update Sensor " + dequeue['Name'] + ".") + logging.getLogger("thread_sensors").warning(" Failed to update sensor " + dequeue['Name'] + ".") else: dequeue['Q'].append(0) - logging.getLogger("thread_sensors").error(" Sensor has Failed: " + dequeue['Name'] + "!!") \ No newline at end of file + logging.getLogger("thread_sensors").error(" Sensor has failed: " + dequeue['Name'] + "!!") \ No newline at end of file diff --git a/index.html b/index.html index 028519e..cd7b85b 100644 --- a/index.html +++ b/index.html @@ -3,7 +3,6 @@
- diff --git a/thread_handler.py b/thread_handler.py index 5b54d33..ddeb843 100644 --- a/thread_handler.py +++ b/thread_handler.py @@ -1,6 +1,5 @@ #!python -import time, sys, signal -import threading, logging +import time, sys, signal, logging from framework import update_sensors from framework import update_sensor_rain from framework import update_rain_compile @@ -27,7 +26,7 @@ # Signal handler to properly close all DB handles def signal_handler(signal, frame): - print('Closing...') + logging.getLogger("core").warning(" Shutting down...") for thread in threads: thread.stop() time.sleep(settings.how_long_to_wait_before_killing_threads) @@ -35,6 +34,7 @@ def signal_handler(signal, frame): signal.signal(signal.SIGINT, signal_handler) # Create the threads +logging.getLogger("core").info(" Launching the threads...") threads.append( update_sensors.thread_sensors() ) threads.append( update_sensor_rain.thread_sensor_rain() ) threads.append( update_rain_compile.thread_rain_compile() )