diff web/log.py @ 33:024f5571df8c

- Debug log file for server - Fix some variable sizes, turn off local echo for avr code - symlink config for wrt server
author Matt Johnston <matt@ucc.asn.au>
date Fri, 15 Jun 2012 23:34:24 +0800
parents e18d7e89c17d
children 8da0fdadc8d7
line wrap: on
line diff
--- a/web/log.py	Thu Jun 14 00:00:57 2012 +0800
+++ b/web/log.py	Fri Jun 15 23:34:24 2012 +0800
@@ -73,10 +73,22 @@
 
     rrdfile = sensor_rrd_path(sensor_id)
     rrdtool.update(rrdfile, *values)
+
+    # be paranois
     f = file(rrdfile)
     os.fsync(f.fileno())
 
+def record_debug(lines):
+    f = open('%s/debug.log', config.DATA_PATH, 'a+')
+    f.write('===== %s =====' % time.strftime('%a, %d %b %Y %H:%M:%S')
+    f.writelines(('%s\n' % s for s in lines))
+    f.flush()
+    return f
+
 def parse(lines):
+   
+    debugf = record_debug(lines):
+
     entries = dict(l.split('=', 1) for l in lines)
     if len(entries) != len(lines):
         raise Exception("Keys are not unique")
@@ -110,3 +122,6 @@
 
     for sensor_id, measurements in zip(sensors, meas):
         sensor_update(sensor_id, measurements, first_real_time, time_step)
+
+    debugf.write("Updated %d sensors\n" % len(sensors)
+    debugf.flush()