Get logger in main
This commit is contained in:
parent
c5491d90ad
commit
aa343594d2
1 changed files with 5 additions and 7 deletions
|
@ -17,17 +17,13 @@ import logging
|
||||||
import lorautil
|
import lorautil
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
#Call back functions
|
|
||||||
|
|
||||||
# gives connection message
|
|
||||||
def on_connect(client,userdata,rc):
|
def on_connect(client,userdata,rc):
|
||||||
print("Connected with result code:"+str(rc))
|
log.debug("Connected with result code:"+str(rc))
|
||||||
# subscribe for all devices of user
|
# subscribe for all devices of user
|
||||||
client.subscribe('+/devices/+/up')
|
client.subscribe('+/devices/+/up')
|
||||||
|
|
||||||
# gives message from device
|
|
||||||
def on_message(client,userdata,msg):
|
def on_message(client,userdata,msg):
|
||||||
myjson = msg.payload.decode('utf-8')
|
myjson = msg.payload.decode('utf-8')
|
||||||
mydict = json.loads(myjson)
|
mydict = json.loads(myjson)
|
||||||
|
@ -53,7 +49,9 @@ def on_disconnect(client, userdata, rc):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logging.root.setLevel(logging.DEBUG)
|
logging.root.setLevel(logging.DEBUG)
|
||||||
log.setLevel(logging.DEBUG)
|
|
||||||
|
# log.setLevel(logging.DEBUG)
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
mqttc= mqtt.Client()
|
mqttc= mqtt.Client()
|
||||||
mqttc.on_connect=on_connect
|
mqttc.on_connect=on_connect
|
||||||
|
|
Loading…
Reference in a new issue