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

log: use environment to control the log level #405

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 channels_redis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import functools
import itertools
import logging
import os
import time
import uuid

Expand All @@ -21,6 +22,7 @@
)

logger = logging.getLogger(__name__)
OVER_CAPACITY_LEVEL = int(os.environ.get("CHANNELS_REDIS_CAPACITY_LOG_LEVEL", 10))


class ChannelLock:
Expand Down Expand Up @@ -574,7 +576,8 @@ async def group_send(self, group, message):
group_send_lua, len(channel_redis_keys), *channel_redis_keys, *args
)
if channels_over_capacity > 0:
logger.info(
logger.log(
OVER_CAPACITY_LEVEL,
"%s of %s channels over capacity in group %s",
channels_over_capacity,
len(channel_names),
Expand All @@ -596,9 +599,9 @@ def _map_channel_keys_to_connection(self, channel_names, message):
# Connection dict keyed by index to list of redis keys mapped on that index
connection_to_channel_keys = collections.defaultdict(list)
# Message dict maps redis key to the message that needs to be send on that key
channel_key_to_message = dict()
channel_key_to_message = {}
# Channel key mapped to its capacity
channel_key_to_capacity = dict()
channel_key_to_capacity = {}

# For each channel
for channel in channel_names:
Expand Down