Skip to content

Commit a72259c

Browse files
committed
avoid importing logging
use fake logger instead
1 parent a785348 commit a72259c

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ Dependencies
2424
This driver depends on:
2525

2626
* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
27-
* `Adafruit CircuitPython Logging <https://github.com/adafruit/Adafruit_CircuitPython_Logging>`_
2827

2928
Please ensure all dependencies are available on the CircuitPython filesystem.
3029
This is easily achieved by downloading

adafruit_minimqtt/adafruit_minimqtt.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import time
3333
from random import randint
3434

35-
import adafruit_logging as logging
3635
from micropython import const
3736

3837
from .matcher import MQTTMatcher
@@ -123,6 +122,19 @@ def wrap_socket(self, socket, server_hostname=None):
123122
return _FakeSSLSocket(socket, self._iface.TLS_MODE)
124123

125124

125+
class NullLogger:
126+
"""Fake logger class that does not do anything"""
127+
128+
# pylint: disable=unused-argument
129+
def nothing(self, msg: str, *args) -> None:
130+
"""no action"""
131+
pass
132+
133+
def __init__(self):
134+
for log_level in ["debug", "info", "warning", "error", "critical"]:
135+
setattr(NullLogger, log_level, self.nothing)
136+
137+
126138
class MQTT:
127139
"""MQTT Client for CircuitPython.
128140
@@ -1055,6 +1067,5 @@ def disable_logger(self):
10551067
self._init_logger()
10561068

10571069
def _init_logger(self):
1058-
"""Initializes logger to use NullHandler, i.e. no logging will be done."""
1059-
self.logger = logging.getLogger("")
1060-
self.logger.addHandler(logging.NullHandler())
1070+
"""Initializes logger to NullLogger, i.e. no logging will be done."""
1071+
self.logger = NullLogger()

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@
33
# SPDX-License-Identifier: Unlicense
44

55
Adafruit-Blinka
6-
adafruit-circuitpython-logging

0 commit comments

Comments
 (0)