Skip to content

Commit

Permalink
Merge pull request #140 from kjsanger/bugfix/logger-cache
Browse files Browse the repository at this point in the history
Fix logger configuration by not caching the logger
  • Loading branch information
kjsanger authored Oct 31, 2023
2 parents 28ac982 + 2ec5dd0 commit 6a4efec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
9 changes: 6 additions & 3 deletions src/partisan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
13 changes: 6 additions & 7 deletions src/partisan/irods.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ def checksum(
timeout=timeout,
tries=tries,
)

checksum = result[Baton.CHECKSUM]
return checksum

Expand Down Expand Up @@ -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))
Expand All @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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]
Expand All @@ -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:
Expand Down

0 comments on commit 6a4efec

Please sign in to comment.