Skip to content

Commit 6d8b72a

Browse files
committed
avoid importing logging
use fake logger instead
1 parent 033a5a1 commit 6d8b72a

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
@@ -127,6 +126,19 @@ def wrap_socket(self, socket, server_hostname=None):
127126
return _FakeSSLSocket(socket, self._iface.TLS_MODE)
128127

129128

129+
class NullLogger:
130+
"""Fake logger class that does not do anything"""
131+
132+
# pylint: disable=unused-argument
133+
def nothing(self, msg: str, *args) -> None:
134+
"""no action"""
135+
pass
136+
137+
def __init__(self):
138+
for log_level in ["debug", "info", "warning", "error", "critical"]:
139+
setattr(NullLogger, log_level, self.nothing)
140+
141+
130142
class MQTT:
131143
"""MQTT Client for CircuitPython.
132144
@@ -1178,6 +1190,5 @@ def disable_logger(self):
11781190
self._init_logger()
11791191

11801192
def _init_logger(self):
1181-
"""Initializes logger to use NullHandler, i.e. no logging will be done."""
1182-
self.logger = logging.getLogger("")
1183-
self.logger.addHandler(logging.NullHandler())
1193+
"""Initializes logger to NullLogger, i.e. no logging will be done."""
1194+
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)