Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Paho Client Log Messages into Log at Same Level #369

Merged
merged 3 commits into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Corrects a bug which prevented Keypadlincs of the Switch variety from
reporting their state via the MQTT state topic. ([PR 368][P368])

### Additions

- Adds logging of Paho MQTT client. ([PR 369][P339])

## [0.8.1]

### Fixes
Expand Down Expand Up @@ -645,3 +649,4 @@ will add new features.
[P359]: https://github.com/TD22057/insteon-mqtt/pull/359
[P363]: https://github.com/TD22057/insteon-mqtt/pull/363
[P368]: https://github.com/TD22057/insteon-mqtt/pull/368
[P369]: https://github.com/TD22057/insteon-mqtt/pull/369
3 changes: 2 additions & 1 deletion config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
#
#==========================================================================
logging:
# 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR
# 5=VERBOSE, 10=DEBUG, 20=INFO, 30=WARNING, 40=ERROR
# VERBOSE only adds logging of MQTT ping requests to DEBUG
level: 10

# Print messages to the screen.
Expand Down
15 changes: 11 additions & 4 deletions insteon_mqtt/network/Mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,17 @@ def _on_log(self, client, data, level, buf):
level (int): Logging level.
buf (str): The message to log.
"""
# Send a very low level logging message so we can turn on level 5
# logging at the top level to see what is happening in the MQTT
# client.
LOG.log(5, buf)
# Pass on the majority of paho client logging messages at the same
# level.
# However, the ping messages are a bit verbose and cause 2 log entries
# every thirty seconds. To see these messages set the debug to level
# 5
verbose = ["Sending PINGREQ", "Sending PINGRESP", "Received PINGREQ",
"Received PINGRESP"]
if buf not in verbose:
LOG.log(paho.LOGGING_LEVEL[level], buf)
else:
LOG.log(5, buf)

#-----------------------------------------------------------------------
def __str__(self):
Expand Down