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

dedupe config overrides #3600

Merged
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: 2 additions & 1 deletion reflex/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ def update_from_env(self) -> dict[str, Any]:
if env_var is not None:
if key.upper() != "DB_URL":
console.info(
f"Overriding config value {key} with env var {key.upper()}={env_var}"
f"Overriding config value {key} with env var {key.upper()}={env_var}",
dedupe=True,
)

# Convert the env var to the expected type.
Expand Down
11 changes: 10 additions & 1 deletion reflex/utils/console.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# Deprecated features who's warning has been printed.
_EMITTED_DEPRECATION_WARNINGS = set()

# Info messages which have been printed.
_EMITTED_INFO = set()


def set_log_level(log_level: LogLevel):
"""Set the log level.
Expand Down Expand Up @@ -62,14 +65,20 @@ def debug(msg: str, **kwargs):
print(msg_, **kwargs)


def info(msg: str, **kwargs):
def info(msg: str, dedupe: bool = False, **kwargs):
"""Print an info message.
Args:
msg: The info message.
dedupe: If True, suppress multiple console logs of info message.
kwargs: Keyword arguments to pass to the print function.
"""
if _LOG_LEVEL <= LogLevel.INFO:
if dedupe:
if msg in _EMITTED_INFO:
return
else:
_EMITTED_INFO.add(msg)
print(f"[cyan]Info: {msg}[/cyan]", **kwargs)


Expand Down
Loading