I have several remote MQTT devices which send logging information to my plugin. The plugin then writes these to separate log files for each device. Here's what I'm using for instantiating the loggers (looks basic):
- Code: Select all
logger = logging.getLogger(u'mqtt_' + deviceName)
logger.setLevel(int(indigo.activePlugin.pluginPrefs["loggingLevel"]))
filename = u'%s.log' % (logger.name)
filePath = os.path.join(os.path.expanduser('~'), u'Library', u'Logs', filename)
handler = logging.handlers.TimedRotatingFileHandler(filePath, when=u'midnight', backupCount=7)
formatter = logging.Formatter(u'%(asctime)s \n%(message)s')
handler.setFormatter(formatter)
logger.addHandler(handler)
This is the code that does the actual logging:
- Code: Select all
indigo.server.log(u"Writing to %s log" % (deviceName))
logger.log(logLevel, u"\n" + msg.payload)
indigo.server.log(u"Done Writing")
But, if my logLevel is 40 (Errors only), I get this in the indigo log:
--- BEGIN LOG SNIPPET
MQTT Writing to T1 log
MQTT Error
t.callback cnt=105
rcv_settings.update=15720
heap=18600
MQTT Done Writing
--- END LOG SNIPPET
There's other unexplained behaviors too. If I set my logging level to 10 then none of this is in indigo error red.
Any suggestions?