log.py 687 Bytes
Newer Older
julric's avatar
julric committed
1
import output
julric's avatar
julric committed
2
import time
julric's avatar
julric committed
3 4

class Log(output.Output):
5
       requiredData = ["text_file"]
julric's avatar
julric committed
6 7
       optionalData = []
       def __init__(self,data):
julric's avatar
julric committed
8
               self.text_file=data["text_file"]
9

julric's avatar
julric committed
10
       def outputData(self,dataPoints):
11
               f = open(self.text_file, 'a')
julric's avatar
julric committed
12 13 14
               logline = 'time,'
               logline += str(int(time.time()))
               logline += ';'
julric's avatar
julric committed
15
               for i in dataPoints:
julric's avatar
julric committed
16 17 18 19
                       logline += i["name"] + "," + str(i["value"]) + ';'
               logline = logline[:-1]
               logline += "\n"

20
#               print(logline)
julric's avatar
julric committed
21 22 23
               f.write(logline)
               f.close()

julric's avatar
julric committed
24
               return True