set loglevel to info with hosting cli (#4043)

* set loglevel to info with hosting cli

* reduce reused logic
This commit is contained in:
Khaleel Al-Adhami 2024-10-02 18:04:04 -07:00 committed by GitHub
parent c08720ed1a
commit 6a9f83cc2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 11 deletions

View File

@ -191,6 +191,14 @@ class LogLevel(str, Enum):
levels = list(LogLevel)
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
POLLING_MAX_HTTP_BUFFER_SIZE = 1000 * 1000

View File

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