Skip to content

Commit

Permalink
added logging to config
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-manuel committed Oct 9, 2023
1 parent dd61ed0 commit 8d8e793
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
## v1.0.x

* Added: Bluetooth: Show signal strength of BMS in log by @mr-manuel
* Added: Configure logging level in `config.ini` by @mr-manuel
* Added: Create unique identifier, if not provided from BMS by @mr-manuel
* Added: Current average of the last 5 minutes by @mr-manuel
* Added: Daly BMS - Auto reset SoC when changing to float (can be turned off in the config file) by @transistorgit
Expand Down
7 changes: 7 additions & 0 deletions etc/dbus-serialbattery/config.default.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
[DEFAULT]

; --------- Set logging level ---------
; ERROR: Only errors are logged
; WARNING: Errors and warnings are logged
; INFO: Errors, warnings and info messages are logged
; DEBUG: Errors, warnings, info and debug messages are logged
LOGGING = INFO

; --------- Battery Current limits ---------
MAX_BATTERY_CHARGE_CURRENT = 50.0
MAX_BATTERY_DISCHARGE_CURRENT = 60.0
Expand Down
13 changes: 11 additions & 2 deletions etc/dbus-serialbattery/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# Logging
logging.basicConfig()
logger = logging.getLogger("SerialBattery")
logger.setLevel(logging.INFO)

PATH_CONFIG_DEFAULT = "config.default.ini"
PATH_CONFIG_USER = "config.ini"
Expand All @@ -38,10 +37,20 @@ def _get_list_from_config(


# Constants
DRIVER_VERSION = "1.0.20230927dev"
DRIVER_VERSION = "1.0.20231009dev"
zero_char = chr(48)
degree_sign = "\N{DEGREE SIGN}"

# get logging level from config file
if config["DEFAULT"]["LOGGING"] == "ERROR":
logging.basicConfig(level=logging.ERROR)
elif config["DEFAULT"]["LOGGING"] == "WARNING":
logging.basicConfig(level=logging.WARNING)
elif config["DEFAULT"]["LOGGING"] == "DEBUG":
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig(level=logging.INFO)

# save config values to constants

# --------- Battery Current limits ---------
Expand Down

0 comments on commit 8d8e793

Please sign in to comment.