Skip to content

Commit 7920180

Browse files
committed
enable error_only logging
1 parent 00cc546 commit 7920180

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "meshcore"
7-
version = "1.9.16"
7+
version = "1.9.17"
88
authors = [
99
{ name="Florent de Lamotte", email="florent@frizoncorrea.fr" },
1010
{ name="Alex Wolden", email="awolden@gmail.com" },

src/meshcore/meshcore.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MeshCore:
1717
"""
1818
Interface to a MeshCore device
1919
"""
20-
def __init__(self, cx, debug=False, default_timeout=None, auto_reconnect=False, max_reconnect_attempts=3):
20+
def __init__(self, cx, debug=False, only_error=False, default_timeout=None, auto_reconnect=False, max_reconnect_attempts=3):
2121
# Wrap connection with ConnectionManager
2222
self.dispatcher = EventDispatcher()
2323
self.connection_manager = ConnectionManager(
@@ -31,6 +31,8 @@ def __init__(self, cx, debug=False, default_timeout=None, auto_reconnect=False,
3131
# Set up logger
3232
if debug:
3333
logger.setLevel(logging.DEBUG)
34+
elif only_error:
35+
logger.setLevel(logging.ERROR)
3436
else:
3537
logger.setLevel(logging.INFO)
3638

@@ -59,29 +61,29 @@ def __init__(self, cx, debug=False, default_timeout=None, auto_reconnect=False,
5961
cx.set_disconnect_callback(self.connection_manager.handle_disconnect)
6062

6163
@classmethod
62-
async def create_tcp(cls, host: str, port: int, debug: bool = False, default_timeout=None,
64+
async def create_tcp(cls, host: str, port: int, debug: bool = False, only_error:bool = False, default_timeout=None,
6365
auto_reconnect: bool = False, max_reconnect_attempts: int = 3) -> 'MeshCore':
6466
"""Create and connect a MeshCore instance using TCP connection"""
6567
connection = TCPConnection(host, port)
6668

67-
mc = cls(connection, debug=debug, default_timeout=default_timeout,
69+
mc = cls(connection, debug=debug, only_error=only_error, default_timeout=default_timeout,
6870
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
6971
await mc.connect()
7072
return mc
7173

7274
@classmethod
73-
async def create_serial(cls, port: str, baudrate: int = 115200, debug: bool = False, default_timeout=None,
75+
async def create_serial(cls, port: str, baudrate: int = 115200, debug: bool = False, only_error:bool=False, default_timeout=None,
7476
auto_reconnect: bool = False, max_reconnect_attempts: int = 3, cx_dly:float = 0.1) -> 'MeshCore':
7577
"""Create and connect a MeshCore instance using serial connection"""
7678
connection = SerialConnection(port, baudrate, cx_dly=cx_dly)
7779

78-
mc = cls(connection, debug=debug, default_timeout=default_timeout,
80+
mc = cls(connection, debug=debug, only_error=only_error, default_timeout=default_timeout,
7981
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
8082
await mc.connect()
8183
return mc
8284

8385
@classmethod
84-
async def create_ble(cls, address: Optional[str] = None, debug: bool = False, default_timeout=None,
86+
async def create_ble(cls, address: Optional[str] = None, debug: bool = False, only_error:bool=False, default_timeout=None,
8587
auto_reconnect: bool = False, max_reconnect_attempts: int = 3) -> 'MeshCore':
8688
"""Create and connect a MeshCore instance using BLE connection
8789
@@ -90,7 +92,7 @@ async def create_ble(cls, address: Optional[str] = None, debug: bool = False, de
9092

9193
connection = BLEConnection(address)
9294

93-
mc = cls(connection, debug=debug, default_timeout=default_timeout,
95+
mc = cls(connection, debug=debug, only_error=only_error, default_timeout=default_timeout,
9496
auto_reconnect=auto_reconnect, max_reconnect_attempts=max_reconnect_attempts)
9597
await mc.connect()
9698
return mc

0 commit comments

Comments
 (0)