Browse Source

set loglevel to info with hosting cli (#4043)

* set loglevel to info with hosting cli

* reduce reused logic
Khaleel Al-Adhami 7 months ago
parent
commit
6a9f83cc2d
2 changed files with 13 additions and 11 deletions
  1. 8 0
      reflex/constants/base.py
  2. 5 11
      reflex/reflex.py

+ 8 - 0
reflex/constants/base.py

@@ -191,6 +191,14 @@ class LogLevel(str, Enum):
         levels = list(LogLevel)
         levels = list(LogLevel)
         return levels.index(self) <= levels.index(other)
         return levels.index(self) <= levels.index(other)
 
 
+    def subprocess_level(self):
+        """Return the log level for the subprocess.
+
+        Returns:
+            The log level for the subprocess
+        """
+        return self if self != LogLevel.DEFAULT else LogLevel.INFO
+
 
 
 # Server socket configuration variables
 # Server socket configuration variables
 POLLING_MAX_HTTP_BUFFER_SIZE = 1000 * 1000
 POLLING_MAX_HTTP_BUFFER_SIZE = 1000 * 1000

+ 5 - 11
reflex/reflex.py

@@ -15,7 +15,6 @@ from reflex_cli.utils import dependency
 
 
 from reflex import constants
 from reflex import constants
 from reflex.config import get_config
 from reflex.config import get_config
-from reflex.constants.base import LogLevel
 from reflex.custom_components.custom_components import custom_components_cli
 from reflex.custom_components.custom_components import custom_components_cli
 from reflex.state import reset_disk_state_manager
 from reflex.state import reset_disk_state_manager
 from reflex.utils import console, redir, telemetry
 from reflex.utils import console, redir, telemetry
@@ -247,11 +246,6 @@ def _run(
         setup_frontend(Path.cwd())
         setup_frontend(Path.cwd())
         commands.append((frontend_cmd, Path.cwd(), frontend_port, backend))
         commands.append((frontend_cmd, Path.cwd(), frontend_port, backend))
 
 
-    # If no loglevel is specified, set the subprocesses loglevel to WARNING.
-    subprocesses_loglevel = (
-        loglevel if loglevel != LogLevel.DEFAULT else LogLevel.WARNING
-    )
-
     # In prod mode, run the backend on a separate thread.
     # In prod mode, run the backend on a separate thread.
     if backend and env == constants.Env.PROD:
     if backend and env == constants.Env.PROD:
         commands.append(
         commands.append(
@@ -259,7 +253,7 @@ def _run(
                 backend_cmd,
                 backend_cmd,
                 backend_host,
                 backend_host,
                 backend_port,
                 backend_port,
-                subprocesses_loglevel,
+                loglevel.subprocess_level(),
                 frontend,
                 frontend,
             )
             )
         )
         )
@@ -269,7 +263,7 @@ def _run(
         # In dev mode, run the backend on the main thread.
         # In dev mode, run the backend on the main thread.
         if backend and env == constants.Env.DEV:
         if backend and env == constants.Env.DEV:
             backend_cmd(
             backend_cmd(
-                backend_host, int(backend_port), subprocesses_loglevel, frontend
+                backend_host, int(backend_port), loglevel.subprocess_level(), frontend
             )
             )
             # The windows uvicorn bug workaround
             # The windows uvicorn bug workaround
             # https://github.com/reflex-dev/reflex/issues/2335
             # https://github.com/reflex-dev/reflex/issues/2335
@@ -342,7 +336,7 @@ def export(
         backend=backend,
         backend=backend,
         zip_dest_dir=zip_dest_dir,
         zip_dest_dir=zip_dest_dir,
         upload_db_file=upload_db_file,
         upload_db_file=upload_db_file,
-        loglevel=loglevel,
+        loglevel=loglevel.subprocess_level(),
     )
     )
 
 
 
 
@@ -577,7 +571,7 @@ def deploy(
             frontend=frontend,
             frontend=frontend,
             backend=backend,
             backend=backend,
             zipping=zipping,
             zipping=zipping,
-            loglevel=loglevel,
+            loglevel=loglevel.subprocess_level(),
             upload_db_file=upload_db_file,
             upload_db_file=upload_db_file,
         ),
         ),
         key=key,
         key=key,
@@ -591,7 +585,7 @@ def deploy(
         interactive=interactive,
         interactive=interactive,
         with_metrics=with_metrics,
         with_metrics=with_metrics,
         with_tracing=with_tracing,
         with_tracing=with_tracing,
-        loglevel=loglevel.value,
+        loglevel=loglevel.subprocess_level(),
     )
     )