Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logger configuration by not caching the logger #140

Merged
merged 1 commit into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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