Conditions | 1 |
Total Lines | 23 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | from multiprocessing import Process |
||
7 | def main(): |
||
8 | """main""" |
||
9 | # create logger |
||
10 | logger = logging.getLogger('myems-mqtt-publisher') |
||
11 | # specifies the lowest-severity log message a logger will handle, |
||
12 | # where debug is the lowest built-in severity level and critical is the highest built-in severity. |
||
13 | # For example, if the severity level is INFO, the logger will handle only INFO, WARNING, ERROR, and CRITICAL |
||
14 | # messages and will ignore DEBUG messages. |
||
15 | logger.setLevel(logging.ERROR) |
||
16 | # create file handler which logs messages |
||
17 | fh = RotatingFileHandler('myems-mqtt-publisher.log', maxBytes=1024*1024, backupCount=1) |
||
18 | # create formatter and add it to the handlers |
||
19 | formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') |
||
20 | fh.setFormatter(formatter) |
||
21 | # add the handlers to logger |
||
22 | logger.addHandler(fh) |
||
23 | |||
24 | # create acquisition processes |
||
25 | Process(target=acquisition.process, args=(logger, 'ANALOG_VALUE')).start() |
||
26 | |||
27 | Process(target=acquisition.process, args=(logger, 'DIGITAL_VALUE')).start() |
||
28 | |||
29 | Process(target=acquisition.process, args=(logger, 'ENERGY_VALUE')).start() |
||
30 | |||
34 |