cmroche / OctoPrint-HomeAssistant

Home Assistant plugin for OctoPrint, enabling MQTT discovery of you device and sensors
110 stars 18 forks source link

Plugin does not respect logging level? #24

Closed fredrikbaberg closed 4 years ago

fredrikbaberg commented 4 years ago

When I install and enable the HomeAssistant plugin, my output log becomes full of DEBUG statements, see below. Normally it is possible to change log level in OctoPrint settings, but this plugin does not seem to respect that.

I'm just guessing now, since I have not been able to test it, but I think a setup of the logger is missing. See e.g. https://github.com/jneilliii/OctoPrint-TPLinkSmartplug/blob/ca8bcc6ab3cddac7f5010ef41e94c9659985c442/octoprint_tplinksmartplug/__init__.py#L84

2020-07-04 15:48:17,197 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,199 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,199 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,201 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,202 - octoprint.plugins.homeassistant - DEBUG - Generating topic for progressTopic, slicing
2020-07-04 15:48:17,203 - octoprint.plugins.homeassistant - DEBUG - Generated topic: progress/slicing
2020-07-04 15:48:17,204 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,206 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,207 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,209 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,217 - octoprint.plugins.homeassistant - DEBUG - Generating topic for temperatureTopic, tool0
2020-07-04 15:48:17,219 - octoprint.plugins.homeassistant - DEBUG - Generated topic: temperature/tool0
2020-07-04 15:48:17,220 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,221 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,222 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,223 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,224 - octoprint.plugins.homeassistant - DEBUG - Generating topic for temperatureTopic, tool0
2020-07-04 15:48:17,225 - octoprint.plugins.homeassistant - DEBUG - Generated topic: temperature/tool0
2020-07-04 15:48:17,226 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,227 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,228 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,230 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,231 - octoprint.plugins.homeassistant - DEBUG - Generating topic for temperatureTopic, bed
2020-07-04 15:48:17,232 - octoprint.plugins.homeassistant - DEBUG - Generated topic: temperature/bed
2020-07-04 15:48:17,233 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,234 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,235 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,236 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,237 - octoprint.plugins.homeassistant - DEBUG - Generating topic for temperatureTopic, bed
2020-07-04 15:48:17,238 - octoprint.plugins.homeassistant - DEBUG - Generated topic: temperature/bed
2020-07-04 15:48:17,240 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,241 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,241 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,243 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,244 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, stop
2020-07-04 15:48:17,246 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hassControl/stop
2020-07-04 15:48:17,247 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, stop
2020-07-04 15:48:17,248 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hassControl/stop
2020-07-04 15:48:17,248 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, stop
2020-07-04 15:48:17,249 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hassControl/stop
2020-07-04 15:48:17,250 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,251 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,252 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,253 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,254 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, cancel
2020-07-04 15:48:17,255 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hassControl/cancel
2020-07-04 15:48:17,256 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, cancel
2020-07-04 15:48:17,258 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hassControl/cancel
2020-07-04 15:48:17,259 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, cancel
2020-07-04 15:48:17,261 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hassControl/cancel
2020-07-04 15:48:17,262 - octoprint.plugins.homeassistant - DEBUG - Generating topic for hassTopic, is_printing
2020-07-04 15:48:17,263 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hass/is_printing
2020-07-04 15:48:17,264 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,265 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,266 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,266 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,268 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, pause
2020-07-04 15:48:17,270 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hassControl/pause
2020-07-04 15:48:17,271 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, pause
2020-07-04 15:48:17,272 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hassControl/pause
2020-07-04 15:48:17,272 - octoprint.plugins.homeassistant - DEBUG - Generating topic for hassTopic, is_paused
2020-07-04 15:48:17,273 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hass/is_paused
2020-07-04 15:48:17,274 - octoprint.plugins.homeassistant - DEBUG - Generating topic for hassTopic, is_printing
2020-07-04 15:48:17,275 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hass/is_printing
2020-07-04 15:48:17,275 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,277 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,278 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,280 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,282 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, shutdown
2020-07-04 15:48:17,283 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hassControl/shutdown
2020-07-04 15:48:17,284 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, shutdown
2020-07-04 15:48:17,285 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hassControl/shutdown
2020-07-04 15:48:17,286 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, shutdown
2020-07-04 15:48:17,287 - octoprint.plugins.homeassistant - DEBUG - Generated topic: hassControl/shutdown
2020-07-04 15:48:17,289 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,290 - octoprint.plugins.homeassistant - DEBUG - Generated topic: mqtt
2020-07-04 15:48:17,292 - octoprint.plugins.homeassistant - DEBUG - Generating topic for baseTopic, 
2020-07-04 15:48:17,293 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/
2020-07-04 15:48:17,295 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, jog
2020-07-04 15:48:17,297 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hassControl/jog
2020-07-04 15:48:17,297 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, home
2020-07-04 15:48:17,299 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hassControl/home
2020-07-04 15:48:17,300 - octoprint.plugins.homeassistant - DEBUG - Generating topic for controlTopic, commands
2020-07-04 15:48:17,301 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hassControl/commands
2020-07-04 15:48:17,301 - octoprint.plugins.homeassistant - DEBUG - Generating topic for lwTopic, 
2020-07-04 15:48:17,301 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/mqtt
2020-07-04 15:48:17,302 - octoprint.plugins.homeassistant - DEBUG - Generating topic for hassTopic, is_printing
2020-07-04 15:48:17,305 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hass/is_printing
2020-07-04 15:48:17,307 - octoprint.plugins.homeassistant - DEBUG - Generating topic for hassTopic, is_paused
2020-07-04 15:48:17,309 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hass/is_paused
2020-07-04 15:48:17,312 - octoprint.plugins.homeassistant - DEBUG - Generating topic for hassTopic, printing
2020-07-04 15:48:17,313 - octoprint.plugins.homeassistant - DEBUG - Generated topic: octoPrint/hass/printing
cmroche commented 4 years ago

Hey @fredrikbaberg thanks for bringing this up.

Actually I realized that I have not been using logging in a very pythonic way very recently. I'll make a fix for this and push a release later today.

fredrikbaberg commented 4 years ago

That was a very quick response! I attempted to add the line I referenced, replacing the name, but it did not work for me. Perhaps something else is needed, or I installed it the wrong way.

cmroche commented 4 years ago

There was a call on on_startup that I used to explicitly set the logging level when debugging.

As a further note, what I learned last week was that you should not need to set the behaviour of the logger directly, and probably not use a string name. In packages it's common to simply use logger = logging.getLogger(__name__) and the responsibility of the parent modules to collect and set the respective logging levels. Manually adding the name of the package shouldn't be necessary either.