Skip to content

Commit

Permalink
Improve handle_exception_log (#1212)
Browse files Browse the repository at this point in the history
* Add exception logger

* Improve handle_exception_log
  • Loading branch information
SukramJ authored Sep 28, 2023
1 parent 0b80022 commit 5efc7e3
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 55 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Version 2023.9.6 (2023-09-26)

- Use freezegun for climate test
- Update ReGa-Script fetch_all_device_data.fn
- Update ReGa-Script fetch_all_device_data.fn by @Baxxy13
- Parameterize call to fetch_all_device_data.fn
- Simplify json rpc post code
- Improve for ConnectionProblemIssuer json rpc
- Improve handle_exception_log

# Version 2023.9.5 (2023-09-23)

Expand Down
12 changes: 6 additions & 6 deletions hahomematic/central/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1408,31 +1408,31 @@ def has_issue(self, issuer: ConnectionProblemIssuer, iid: str) -> bool:
def handle_exception_log(
self,
issuer: ConnectionProblemIssuer,
method: str,
iid: str,
exception: Exception,
logger: logging.Logger = _LOGGER,
level: int = logging.ERROR,
extra_msg: str = "",
iid: str | None = None,
multiple_logs: bool = True,
) -> None:
"""Handle Exception and derivates logging."""
exception_name = (
exception.name if hasattr(exception, "name") else exception.__class__.__name__
)
if self.has_issue(issuer=issuer, iid=iid or method):
if self.has_issue(issuer=issuer, iid=iid) and multiple_logs is False:
logger.debug(
"%s failed: %s [%s] %s",
method,
iid,
exception_name,
reduce_args(args=exception.args),
extra_msg,
)
else:
self.add_issue(issuer=issuer, iid=iid or method)
self.add_issue(issuer=issuer, iid=iid)
logger.log(
level,
"%s failed: %s [%s] %s",
method,
iid,
exception_name,
reduce_args(args=exception.args),
extra_msg,
Expand Down
Loading

0 comments on commit 5efc7e3

Please sign in to comment.