Total Complexity | 4 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | '''logs message to terminal. in future may log to database''' |
||
2 | from helpers.queuehelper import QueueName |
||
3 | from backend.fcmapp import Component |
||
4 | |||
5 | COMPONENTLOG = Component('log') |
||
6 | |||
7 | def when_log(channel, method, properties, body): |
||
8 | '''event handler when log event is raised''' |
||
9 | try: |
||
10 | print("[{0}] Received log message".format(COMPONENTLOG.app.now())) |
||
11 | dolog(body.decode()) |
||
12 | except Exception as ex: |
||
13 | COMPONENTLOG.app.logexception(ex) |
||
14 | |||
15 | def dolog(msg): |
||
16 | print(msg) |
||
17 | |||
18 | def main(): |
||
19 | COMPONENTLOG.listeningqueue = COMPONENTLOG.app.listen_to_broadcast(QueueName.Q_LOG, when_log) |
||
20 | |||
21 | if __name__ == "__main__": |
||
22 | main() |
||
23 |