Skip to content
Open
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
4 changes: 2 additions & 2 deletions ina219.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ def __init__(self, shunt_ohms, i2c, max_expected_amps=None,
log_level -- set to logging.DEBUG to see detailed calibration
calculations (optional).
"""
logging.basicConfig(level=log_level)
Copy link
Owner

@chrisb2 chrisb2 Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should follow the pattern in the RPi version of this library and check if the logger is already setup, see RPi ina219.py, which was made in this PR?

self._log = logging.getLogger("ina219")
self._log.setLevel(log_level)
self._i2c = i2c
self._address = address
self._shunt_ohms = shunt_ohms
Expand Down Expand Up @@ -406,7 +406,7 @@ def __read_register(self, register, negative_value_supported=False):

def __log_register_operation(self, msg, register, value):
# performance optimisation
if logging._level == logging.DEBUG:
if self._log.level == logging.DEBUG:
binary = '{0:#018b}'.format(value)
self._log.debug("%s register 0x%02x: 0x%04x %s",
msg, register, value, binary)
Expand Down