backend.when_log.dolog()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 1
dl 0
loc 2
rs 10
c 0
b 0
f 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