Skip to content

Commit

Permalink
allow to use nc.log in exception handlers
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
  • Loading branch information
bigcat88 committed Sep 5, 2024
1 parent 3cde102 commit 036d14c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file.

## [0.17.1 - 2024-09-06]

### Fixed

- NextcloudApp: `nc.log` now suppresses all exceptions to safe call it anywhere in your app.

## [0.17.0 - 2024-09-05]

### Added
Expand Down
2 changes: 1 addition & 1 deletion nc_py_api/_version.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Version of nc_py_api."""

__version__ = "0.17.0"
__version__ = "0.17.1"
8 changes: 6 additions & 2 deletions nc_py_api/nextcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,8 @@ def log(self, log_lvl: LogLvl, content: str) -> None:
return
if int(log_lvl) < self.capabilities["app_api"].get("loglevel", 0):
return
self._session.ocs("POST", f"{self._session.ae_url}/log", json={"level": int(log_lvl), "message": content})
with contextlib.suppress(Exception):
self._session.ocs("POST", f"{self._session.ae_url}/log", json={"level": int(log_lvl), "message": content})

def users_list(self) -> list[str]:
"""Returns list of users on the Nextcloud instance."""
Expand Down Expand Up @@ -484,7 +485,10 @@ async def log(self, log_lvl: LogLvl, content: str) -> None:
return
if int(log_lvl) < (await self.capabilities)["app_api"].get("loglevel", 0):
return
await self._session.ocs("POST", f"{self._session.ae_url}/log", json={"level": int(log_lvl), "message": content})
with contextlib.suppress(Exception):
await self._session.ocs(
"POST", f"{self._session.ae_url}/log", json={"level": int(log_lvl), "message": content}
)

async def users_list(self) -> list[str]:
"""Returns list of users on the Nextcloud instance."""
Expand Down

0 comments on commit 036d14c

Please sign in to comment.