Skip to content

Commit 6f8ad5d

Browse files
simonschmidtcarltongibson
authored andcommitted
Use format string plus arguments in logging call.
This makes it easier for tools to group similar messages even when the exact values change
1 parent b10cef2 commit 6f8ad5d

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

channels_redis/core.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,10 @@ async def group_send(self, group, message):
688688
)
689689
if channels_over_capacity > 0:
690690
logger.info(
691-
f"{channels_over_capacity} of {len(channel_names)} channels over capacity in group {group}"
691+
"%s of %s channels over capacity in group %s",
692+
channels_over_capacity,
693+
len(channel_names),
694+
group,
692695
)
693696

694697
def _map_channel_to_connection(self, channel_names, message):

tests/test_core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ async def test_group_send_capacity(channel_layer, caplog):
357357
# Make sure number of channels over capacity are logged
358358
for record in caplog.records:
359359
assert record.levelname == "INFO"
360-
assert record.msg == "1 of 1 channels over capacity in group test-group"
360+
assert (
361+
record.getMessage() == "1 of 1 channels over capacity in group test-group"
362+
)
361363

362364

363365
@pytest.mark.asyncio
@@ -397,7 +399,9 @@ async def test_group_send_capacity_multiple_channels(channel_layer, caplog):
397399
# Make sure number of channels over capacity are logged
398400
for record in caplog.records:
399401
assert record.levelname == "INFO"
400-
assert record.msg == "1 of 2 channels over capacity in group test-group"
402+
assert (
403+
record.getMessage() == "1 of 2 channels over capacity in group test-group"
404+
)
401405

402406

403407
@pytest.mark.asyncio

0 commit comments

Comments
 (0)