8000 Introduce LOG_LEVEL_OVERRIDES config var by simonrw · Pull Request #10808 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Introduce LOG_LEVEL_OVERRIDES config var #10808

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

Merged
merged 7 commits into from
May 29, 2025
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions localstack-core/localstack/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,9 @@ def in_docker():
# path to the lambda debug mode configuration file.
LAMBDA_DEBUG_MODE_CONFIG_PATH = os.environ.get("LAMBDA_DEBUG_MODE_CONFIG_PATH")

# EXPERIMENTAL: allow setting custom log levels for individual loggers
LOG_LEVEL_OVERRIDES = os.environ.get("LOG_LEVEL_OVERRIDES", "")

# whether to enable debugpy
DEVELOP = is_env_true("DEVELOP")

Expand Down
12 changes: 12 additions & 0 deletions localstack-core/localstack/logging/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from localstack import config, constants

from ..utils.strings import key_value_pairs_to_dict
from .format import AddFormattedAttributes, DefaultFormatter

# The log levels for modules are evaluated incrementally for logging granularity,
Expand Down Expand Up @@ -81,6 +82,17 @@ def setup_logging_from_config():
for name, level in trace_internal_log_levels.items():
logging.getLogger(name).setLevel(level)

raw_logging_override = config.LOG_LEVEL_OVERRIDES
if raw_logging_override:
logging_overrides = key_value_pairs_to_dict(raw_logging_override)
for logger, level_name in logging_overrides.items():
level = getattr(logging, level_name, None)
if not level:
raise ValueError(
f"Failed to configure logging overrides ({raw_logging_override}): '{level_name}' is not a valid log level"
)
logging.getLogger(logger).setLevel(level)


def create_default_handler(log_level: int):
log_handler = logging.StreamHandler(stream=sys.stderr)
Expand Down
Loading
0