backend.when_log   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 4

3 Functions

Rating   Name   Duplication   Size   Complexity  
A main() 0 2 1
A when_log() 0 7 2
A dolog() 0 2 1
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