From 2ec5dd0088df8f0adde4a15810da2781d0349403 Mon Sep 17 00:00:00 2001 From: Keith James Date: Tue, 31 Oct 2023 14:53:32 +0000 Subject: [PATCH] Fix logger configuration by not caching the logger Actually raise to info level log messages that were meant to be changed in release 2.9.1 --- src/partisan/__init__.py | 9 ++++++--- src/partisan/irods.py | 13 ++++++------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/partisan/__init__.py b/src/partisan/__init__.py index cc01754..9980cee 100644 --- a/src/partisan/__init__.py +++ b/src/partisan/__init__.py @@ -63,7 +63,10 @@ # string) from the final processor (`JSONRenderer`) will be passed to # the method of the same name as that you've called on the bound logger. logger_factory=structlog.stdlib.LoggerFactory(), - # Effectively freeze configuration after creating the first bound - # logger. - cache_logger_on_first_use=True, + # Do not freeze configuration after creating the first bound logger. This lets + # the application using this library more easily configure partisans loggers. + # + # With this set to True, I was unable to change the configuration of the + # module-scope loggers when calling the partisan library. + cache_logger_on_first_use=False, ) diff --git a/src/partisan/irods.py b/src/partisan/irods.py index 411d88f..e61ac52 100644 --- a/src/partisan/irods.py +++ b/src/partisan/irods.py @@ -268,7 +268,6 @@ def checksum( timeout=timeout, tries=tries, ) - checksum = result[Baton.CHECKSUM] return checksum @@ -1548,7 +1547,7 @@ def supersede_metadata( history_date = datetime.utcnow() current = self.metadata() - log.info("Superseding AVUs", path=self, current=current, new=avus) + log.debug("Superseding AVUs", path=self, old=current, new=avus) rem_attrs = set(map(lambda avu: avu.attribute, avus)) to_remove = set(filter(lambda a: a.attribute in rem_attrs, current)) @@ -1558,7 +1557,7 @@ def supersede_metadata( to_remove.difference_update(avus) to_remove = sorted(to_remove) if to_remove: - log.info("Removing AVUs", path=self, avus=to_remove) + log.debug("Removing AVUs", path=self, avus=to_remove) item = self._to_dict() item[Baton.AVUS] = to_remove with client(self.pool) as c: @@ -1572,7 +1571,7 @@ def supersede_metadata( to_add += hist if to_add: - log.info("Adding AVUs", path=self, avus=to_add) + log.debug("Adding AVUs", path=self, avus=to_add) item = self._to_dict() item[Baton.AVUS] = to_add with client(self.pool) as c: @@ -1668,11 +1667,11 @@ class for methods handling recursive operations. Returns: Tuple[int, int] """ current = self.acl() - log.info("Superseding ACL", path=self, current=current, new=acs) + log.debug("Superseding ACL", path=self, old=current, new=acs) to_remove = sorted(set(current).difference(acs)) if to_remove: - log.info("Removing from ACL", path=self, ac=to_remove) + log.debug("Removing from ACL", path=self, ac=to_remove) # In iRODS we "remove" permissions by setting them to NULL to_null = [AC(ac.user, Permission.NULL, zone=ac.zone) for ac in to_remove] @@ -1684,7 +1683,7 @@ class for methods handling recursive operations. to_add = sorted(set(acs).difference(current)) if to_add: - log.info("Adding to ACL", path=self, ac=to_add) + log.debug("Adding to ACL", path=self, ac=to_add) item = self._to_dict() item[Baton.ACCESS] = to_add with client(self.pool) as c: