mirror of
https://github.com/katanemo/plano.git
synced 2026-05-04 21:32:43 +02:00
add log_level env var (#728)
This commit is contained in:
parent
4a6cea3545
commit
e056ddbcd3
3 changed files with 31 additions and 5 deletions
|
|
@ -16,6 +16,7 @@ from planoai.utils import (
|
||||||
get_llm_provider_access_keys,
|
get_llm_provider_access_keys,
|
||||||
has_ingress_listener,
|
has_ingress_listener,
|
||||||
load_env_file_to_dict,
|
load_env_file_to_dict,
|
||||||
|
set_log_level,
|
||||||
stream_access_logs,
|
stream_access_logs,
|
||||||
find_config_file,
|
find_config_file,
|
||||||
find_repo_root,
|
find_repo_root,
|
||||||
|
|
@ -67,6 +68,8 @@ def get_version():
|
||||||
@click.option("--version", is_flag=True, help="Show the plano cli version and exit.")
|
@click.option("--version", is_flag=True, help="Show the plano cli version and exit.")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def main(ctx, version):
|
def main(ctx, version):
|
||||||
|
# Set log level from LOG_LEVEL env var only
|
||||||
|
set_log_level(os.environ.get("LOG_LEVEL", "info"))
|
||||||
if version:
|
if version:
|
||||||
click.echo(f"plano cli version: {get_version()}")
|
click.echo(f"plano cli version: {get_version()}")
|
||||||
ctx.exit()
|
ctx.exit()
|
||||||
|
|
@ -192,6 +195,10 @@ def up(file, path, foreground):
|
||||||
else:
|
else:
|
||||||
env_stage[access_key] = env_file_dict[access_key]
|
env_stage[access_key] = env_file_dict[access_key]
|
||||||
|
|
||||||
|
# Pass log level to the Docker container — supervisord uses LOG_LEVEL
|
||||||
|
# to set RUST_LOG (brightstaff) and envoy component log levels
|
||||||
|
env_stage["LOG_LEVEL"] = os.environ.get("LOG_LEVEL", "info")
|
||||||
|
|
||||||
env.update(env_stage)
|
env.update(env_stage)
|
||||||
start_arch(arch_config_file, env, foreground=foreground)
|
start_arch(arch_config_file, env, foreground=foreground)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,15 +7,34 @@ import logging
|
||||||
from planoai.consts import PLANO_DOCKER_NAME
|
from planoai.consts import PLANO_DOCKER_NAME
|
||||||
|
|
||||||
|
|
||||||
|
# Standard env var for log level across all Plano components
|
||||||
|
LOG_LEVEL_ENV = "LOG_LEVEL"
|
||||||
|
|
||||||
|
_env_log_level = os.environ.get(LOG_LEVEL_ENV, "info").upper()
|
||||||
|
_log_level = getattr(logging, _env_log_level, logging.INFO)
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.INFO,
|
level=_log_level,
|
||||||
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def set_log_level(level: str):
|
||||||
|
"""Set the log level for all loggers. Accepts: debug, info, warn, error."""
|
||||||
|
global _log_level
|
||||||
|
numeric_level = getattr(logging, level.upper(), None)
|
||||||
|
if numeric_level is None:
|
||||||
|
raise ValueError(f"Invalid log level: {level}")
|
||||||
|
_log_level = numeric_level
|
||||||
|
logging.getLogger().setLevel(_log_level)
|
||||||
|
# Update all existing planoai loggers
|
||||||
|
for name in logging.Logger.manager.loggerDict:
|
||||||
|
logging.getLogger(name).setLevel(_log_level)
|
||||||
|
|
||||||
|
|
||||||
def getLogger(name="cli"):
|
def getLogger(name="cli"):
|
||||||
logger = logging.getLogger(name)
|
logger = logging.getLogger(name)
|
||||||
logger.setLevel(logging.INFO)
|
logger.setLevel(_log_level)
|
||||||
return logger
|
return logger
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ nodaemon=true
|
||||||
[program:brightstaff]
|
[program:brightstaff]
|
||||||
command=sh -c "\
|
command=sh -c "\
|
||||||
envsubst < /app/arch_config_rendered.yaml > /app/arch_config_rendered.env_sub.yaml && \
|
envsubst < /app/arch_config_rendered.yaml > /app/arch_config_rendered.env_sub.yaml && \
|
||||||
RUST_LOG=info \
|
RUST_LOG=${LOG_LEVEL:-info} \
|
||||||
ARCH_CONFIG_PATH_RENDERED=/app/arch_config_rendered.env_sub.yaml \
|
ARCH_CONFIG_PATH_RENDERED=/app/arch_config_rendered.env_sub.yaml \
|
||||||
/app/brightstaff 2>&1 | \
|
/app/brightstaff 2>&1 | \
|
||||||
tee /var/log/brightstaff.log | \
|
tee /var/log/brightstaff.log | \
|
||||||
|
|
@ -18,8 +18,8 @@ stderr_logfile_maxbytes=0
|
||||||
command=/bin/sh -c "\
|
command=/bin/sh -c "\
|
||||||
uv run python -m planoai.config_generator && \
|
uv run python -m planoai.config_generator && \
|
||||||
envsubst < /etc/envoy/envoy.yaml > /etc/envoy.env_sub.yaml && \
|
envsubst < /etc/envoy/envoy.yaml > /etc/envoy.env_sub.yaml && \
|
||||||
envoy -c /etc/envoy.env_sub.yaml \
|
envoy -c /etc/envoy.env_sub.yaml \
|
||||||
--component-log-level wasm:info \
|
--component-log-level wasm:${LOG_LEVEL:-info} \
|
||||||
--log-format '[%%Y-%%m-%%d %%T.%%e][%%l] %%v' 2>&1 | \
|
--log-format '[%%Y-%%m-%%d %%T.%%e][%%l] %%v' 2>&1 | \
|
||||||
tee /var/log/envoy.log | \
|
tee /var/log/envoy.log | \
|
||||||
while IFS= read -r line; do echo '[plano_logs]' \"$line\"; done"
|
while IFS= read -r line; do echo '[plano_logs]' \"$line\"; done"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue