Skip to content

Commit b362036

Browse files
committed
maint: refactor to f-strings for non-debug logging
1 parent a32b244 commit b362036

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

jupyterhub_idle_culler/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ async def handle_server(user, server_name, server, max_age, inactive_limit):
186186
log_name = f"{user['name']}/{server_name}"
187187
if server.get("pending"):
188188
app_log.warning(
189-
"Not culling server %s with pending %s", log_name, server["pending"]
189+
f"Not culling server {log_name} with pending {server['pending']}"
190190
)
191191
return False
192192

@@ -199,7 +199,7 @@ async def handle_server(user, server_name, server, max_age, inactive_limit):
199199

200200
if not server.get("ready", bool(server["url"])):
201201
app_log.warning(
202-
"Not culling not-ready not-pending server %s: %s", log_name, server
202+
f"Not culling not-ready not-pending server {log_name}: {server}"
203203
)
204204
return False
205205

@@ -239,7 +239,7 @@ async def handle_server(user, server_name, server, max_age, inactive_limit):
239239
)
240240
if should_cull:
241241
app_log.info(
242-
"Culling server %s (inactive for %s)", log_name, format_td(inactive)
242+
f"Culling server {log_name} (inactive for {format_td(inactive)})"
243243
)
244244

245245
if max_age and not should_cull:
@@ -293,7 +293,7 @@ async def handle_server(user, server_name, server, max_age, inactive_limit):
293293
)
294294
resp = await fetch(req)
295295
if resp.code == 202:
296-
app_log.warning("Server %s is slow to stop", log_name)
296+
app_log.warning(f"Server {log_name} is slow to stop")
297297
# return False to prevent culling user with pending shutdowns
298298
return False
299299
return True
@@ -368,7 +368,7 @@ async def handle_user(user):
368368
) and (cull_admin_users or not user_is_admin)
369369

370370
if should_cull:
371-
app_log.info("Culling user %s (inactive for %s)", user["name"], inactive)
371+
app_log.info(f"Culling user {user['name']} " f"(inactive for {inactive})")
372372

373373
if max_age and not should_cull:
374374
# only check created if max_age is specified
@@ -427,15 +427,16 @@ async def handle_user(user):
427427
n_users += 1
428428
futures.append((user["name"], handle_user(user)))
429429

430-
app_log.debug(
431-
"Got %d users%s", n_users, (" with ready servers" if state_filter else "")
432-
)
430+
if state_filter:
431+
app_log.debug(f"Got {n_users} users with ready servers")
432+
else:
433+
app_log.debug(f"Got {n_users} users")
433434

434435
for name, f in futures:
435436
try:
436437
result = await f
437438
except Exception:
438-
app_log.exception("Error processing %s", name)
439+
app_log.exception(f"Error processing {name}")
439440
else:
440441
if result:
441442
app_log.debug("Finished culling %s", name)
@@ -570,9 +571,8 @@ def main():
570571
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
571572
except ImportError as e:
572573
app_log.warning(
573-
"Could not load pycurl: %s\n"
574-
"pycurl is recommended if you have a large number of users.",
575-
e,
574+
f"Could not load pycurl: {e}\n"
575+
"pycurl is recommended if you have a large number of users."
576576
)
577577

578578
loop = IOLoop.current()

0 commit comments

Comments
 (0)