Skip to content

Commit

Permalink
Tweak logging output
Browse files Browse the repository at this point in the history
  • Loading branch information
ping committed Jul 8, 2023
1 parent 0b4d616 commit 28d9868
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions calibre-plugin/libby/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ def send_request(

for attempt in range(0, self.max_retries + 1):
try:
self.logger.info(
"REQUEST: {0!s} {1!s}".format(req.get_method(), endpoint)
self.logger.debug(
"REQUEST: {0!s} {1!s}".format(req.get_method(), endpoint_url)
)
self.logger.debug(
"REQ HEADERS: \n{0!s}".format(
Expand Down
4 changes: 2 additions & 2 deletions calibre-plugin/overdrive/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ def send_request(

for attempt in range(0, self.max_retries + 1):
try:
self.logger.info(
"REQUEST: {0!s} {1!s}".format(req.get_method(), endpoint)
self.logger.debug(
"REQUEST: {0!s} {1!s}".format(req.get_method(), endpoint_url)
)
self.logger.debug(
"REQ HEADERS: \n{0!s}".format(
Expand Down
11 changes: 8 additions & 3 deletions calibre-plugin/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ def run(self):
identity_token=libby_token, max_retries=1, timeout=30, logger=logger
)
synced_state = libby_client.sync()
logger.info("Libby request took %f seconds" % (timer() - start))
logger.info("Libby Sync request took %f seconds" % (timer() - start))

# Fetch libraries details from OD and patch it onto synced state
start = timer()
cards = synced_state.get("cards", [])
all_website_ids = [c["library"]["websiteId"] for c in cards]

logger.info("Fetching %d libraries" % len(all_website_ids))
od_client = OverDriveClient(max_retries=1, timeout=30, logger=logger)
max_per_page = 24
total_pages = math.ceil(len(all_website_ids) / max_per_page)
Expand All @@ -49,11 +51,14 @@ def run(self):
website_ids=website_ids, per_page=max_per_page
)
libraries.extend(results.get("items", []))
logger.info("OverDrive request took %f seconds" % (timer() - start))
logger.info(
"OverDrive Libraries requests took %f seconds" % (timer() - start)
)
synced_state["__libraries"] = libraries

subbed_magazines = []
if subscriptions:
logger.info("Checking %d magazines" % len(subscriptions))
# Fetch magazine details from OD
start = timer()
all_parent_magazine_ids = [
Expand Down Expand Up @@ -98,7 +103,7 @@ def run(self):
)
subbed_magazines.extend(titles)
logger.info(
"OverDrive Magazines request took %f seconds" % (timer() - start)
"OverDrive Magazines requests took %f seconds" % (timer() - start)
)
synced_state["__subscriptions"] = subbed_magazines
logger.info("Total Sync Time took %f seconds" % (timer() - total_start))
Expand Down

0 comments on commit 28d9868

Please sign in to comment.