Skip to content

Commit 08b017b

Browse files
Add license pool logging (#166)
1 parent c93d629 commit 08b017b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

api/odl.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,7 @@ def _request_loan_status(
309309

310310
def checkin(self, patron: Patron, pin: str, licensepool: LicensePool) -> None:
311311
"""Return a loan early."""
312+
self.log.info(f"Checking in a loan in license pool {licensepool}")
312313
_db = Session.object_session(patron)
313314

314315
loan = (
@@ -387,6 +388,7 @@ def checkout(
387388
delivery_mechanism: LicensePoolDeliveryMechanism,
388389
) -> LoanInfo:
389390
"""Create a new loan."""
391+
self.log.info(f"Checking out a loan in license pool {licensepool}")
390392
_db = Session.object_session(patron)
391393

392394
loan = (
@@ -612,13 +614,14 @@ def _unlimited_access_fulfill(
612614
raise FormatNotAvailable()
613615
content_link = resource.representation.public_url
614616
content_type = resource.representation.media_type
615-
return RedirectFulfillment(
616-
content_link, content_type
617-
) # Tää pitää kattoo, ei ole circulation.py:ssä
617+
return RedirectFulfillment(content_link, content_type)
618618

619619
def _license_fulfill(
620620
self, loan: Loan, delivery_mechanism: LicensePoolDeliveryMechanism
621621
) -> Fulfillment:
622+
self.log.info(
623+
f"Fulfilling loan of license {loan.license.identifier} in license pool {loan.license_pool}"
624+
)
622625
# We are unable to fulfill a loan that doesn't have its external identifier set,
623626
# since we use this to get to the checkout link. It shouldn't be possible to get
624627
# into this state.
@@ -722,6 +725,7 @@ def place_hold(
722725
notification_email_address: str | None,
723726
) -> HoldInfo:
724727
"""Create a new hold."""
728+
self.log.info(f"Placing hold in license pool {licensepool}")
725729
return self._place_hold(patron, licensepool)
726730

727731
def _place_hold(self, patron: Patron, licensepool: LicensePool) -> HoldInfo:
@@ -759,6 +763,7 @@ def _place_hold(self, patron: Patron, licensepool: LicensePool) -> HoldInfo:
759763

760764
def release_hold(self, patron: Patron, pin: str, licensepool: LicensePool) -> None:
761765
"""Cancel a hold."""
766+
self.log.info(f"Releasing hold in license pool {licensepool}")
762767
_db = Session.object_session(patron)
763768

764769
hold = get_one(

core/model/licensing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def checkin(self):
211211
logging.warning(f"Checking in expired license # {self.identifier}.")
212212

213213
def __repr__(self):
214-
return f"License id: {self.identifier}, checkouts left: {self.checkouts_left}, available: {self.checkouts_available} active: {self.is_inactive} to borrow: {self.is_available_for_borrowing}"
214+
return f"License id: {self.identifier}, checkouts left: {self.checkouts_left}, available: {self.checkouts_available}, is inactive: {self.is_inactive}, can be borrowed: {self.is_available_for_borrowing}"
215215

216216

217217
class LicensePool(Base):

0 commit comments

Comments
 (0)