fix: respect LOGLEVEL env var for all log output sources

Agent-Logs-Url: https://github.com/rommapp/romm/sessions/0b5ef21c-89e1-4f08-b402-03f3276aab08

Co-authored-by: gantoine <3247106+gantoine@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-04-11 02:13:20 +00:00
committed by GitHub
parent cc2dffc6cc
commit d6036cb5ef
4 changed files with 58 additions and 4 deletions

View File

@@ -3,7 +3,7 @@ from pprint import pformat
from colorama import Fore, Style, init
from config import FORCE_COLOR, NO_COLOR
from config import FORCE_COLOR, LOGLEVEL, NO_COLOR
RED = Fore.RED
LIGHTRED = Fore.LIGHTRED_EX
@@ -33,16 +33,16 @@ LOGGING_CONFIG = {
},
"root": {
"handlers": ["default"],
"level": "INFO",
"level": LOGLEVEL,
},
"loggers": {
"uvicorn": {
"level": "INFO",
"level": LOGLEVEL,
"handlers": ["default"],
"propagate": False,
},
"uvicorn.error": {
"level": "INFO",
"level": LOGLEVEL,
"handlers": ["default"],
"propagate": False,
},

View File

@@ -39,6 +39,16 @@ done
export ROMM_BASE_PATH=${ROMM_BASE_PATH:-/romm}
export ROMM_PORT=${ROMM_PORT:-8080}
# Disable nginx access logs when log level is WARNING, ERROR, or CRITICAL
case "${LOGLEVEL:-INFO}" in
WARNING|ERROR|CRITICAL|warning|error|critical)
export NGINX_ACCESS_LOG="access_log off;"
;;
*)
export NGINX_ACCESS_LOG=""
;;
esac
# Set IPV6_LISTEN based on IPV4_ONLY
if [[ ${IPV4_ONLY} == "true" ]]; then
export IPV6_LISTEN="#listen [::]:${ROMM_PORT};"

View File

@@ -93,6 +93,48 @@ start_bin_gunicorn() {
# cleanup potentially leftover socket
rm /tmp/gunicorn.sock -f
# Generate gunicorn logging config with the configured log level
cat >/etc/gunicorn/logging.conf <<EOF
[loggers]
keys=root,gunicorn,error
[handlers]
keys=console_gunicorn
[formatters]
keys=gunicorn_format
# Root logger — KEEP but minimal
[logger_root]
level=WARNING
handlers=
# Gunicorn internal logger
[logger_gunicorn]
level=${LOGLEVEL}
handlers=console_gunicorn
qualname=gunicorn
propagate=0
# Gunicorn error logger (optional)
[logger_error]
level=${LOGLEVEL}
handlers=console_gunicorn
qualname=gunicorn.error
propagate=0
# Handler for Gunicorn logs
[handler_console_gunicorn]
class=StreamHandler
formatter=gunicorn_format
args=(sys.stdout,)
# Formatter for Gunicorn logs
[formatter_gunicorn_format]
format=INFO: [RomM][gunicorn][%%(asctime)s] %%(message)s
datefmt=%Y-%m-%d %H:%M:%S
EOF
# commands to start our main application and store its PID to check for crashes
info_log "Starting backend"

View File

@@ -26,6 +26,8 @@ server {
${IPV6_LISTEN}
server_name localhost;
${NGINX_ACCESS_LOG}
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;