Selaa lähdekoodia

dedupe config overrides (#3600)

benedikt-bartscher 10 kuukautta sitten
vanhempi
säilyke
8304886cac
2 muutettua tiedostoa jossa 12 lisäystä ja 2 poistoa
  1. 2 1
      reflex/config.py
  2. 10 1
      reflex/utils/console.py

+ 2 - 1
reflex/config.py

@@ -277,7 +277,8 @@ class Config(Base):
             if env_var is not None:
             if env_var is not None:
                 if key.upper() != "DB_URL":
                 if key.upper() != "DB_URL":
                     console.info(
                     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.
                 # Convert the env var to the expected type.

+ 10 - 1
reflex/utils/console.py

@@ -17,6 +17,9 @@ _LOG_LEVEL = LogLevel.INFO
 # Deprecated features who's warning has been printed.
 # Deprecated features who's warning has been printed.
 _EMITTED_DEPRECATION_WARNINGS = set()
 _EMITTED_DEPRECATION_WARNINGS = set()
 
 
+# Info messages which have been printed.
+_EMITTED_INFO = set()
+
 
 
 def set_log_level(log_level: LogLevel):
 def set_log_level(log_level: LogLevel):
     """Set the log level.
     """Set the log level.
@@ -62,14 +65,20 @@ def debug(msg: str, **kwargs):
             print(msg_, **kwargs)
             print(msg_, **kwargs)
 
 
 
 
-def info(msg: str, **kwargs):
+def info(msg: str, dedupe: bool = False, **kwargs):
     """Print an info message.
     """Print an info message.
 
 
     Args:
     Args:
         msg: The info message.
         msg: The info message.
+        dedupe: If True, suppress multiple console logs of info message.
         kwargs: Keyword arguments to pass to the print function.
         kwargs: Keyword arguments to pass to the print function.
     """
     """
     if _LOG_LEVEL <= LogLevel.INFO:
     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)
         print(f"[cyan]Info: {msg}[/cyan]", **kwargs)