forked from open-webui/open-webui
fix: Invoke the function before it is defined
This commit is contained in:
parent
0399a69b73
commit
c49cc3fa86
1 changed files with 45 additions and 41 deletions
|
@ -18,6 +18,51 @@ from secrets import token_bytes
|
||||||
from constants import ERROR_MESSAGES
|
from constants import ERROR_MESSAGES
|
||||||
|
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# LOGGING
|
||||||
|
####################################
|
||||||
|
|
||||||
|
log_levels = ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]
|
||||||
|
|
||||||
|
GLOBAL_LOG_LEVEL = os.environ.get("GLOBAL_LOG_LEVEL", "").upper()
|
||||||
|
if GLOBAL_LOG_LEVEL in log_levels:
|
||||||
|
logging.basicConfig(stream=sys.stdout, level=GLOBAL_LOG_LEVEL, force=True)
|
||||||
|
else:
|
||||||
|
GLOBAL_LOG_LEVEL = "INFO"
|
||||||
|
|
||||||
|
log = logging.getLogger(__name__)
|
||||||
|
log.info(f"GLOBAL_LOG_LEVEL: {GLOBAL_LOG_LEVEL}")
|
||||||
|
|
||||||
|
log_sources = [
|
||||||
|
"AUDIO",
|
||||||
|
"COMFYUI",
|
||||||
|
"CONFIG",
|
||||||
|
"DB",
|
||||||
|
"IMAGES",
|
||||||
|
"LITELLM",
|
||||||
|
"MAIN",
|
||||||
|
"MODELS",
|
||||||
|
"OLLAMA",
|
||||||
|
"OPENAI",
|
||||||
|
"RAG",
|
||||||
|
"WEBHOOK",
|
||||||
|
]
|
||||||
|
|
||||||
|
SRC_LOG_LEVELS = {}
|
||||||
|
|
||||||
|
for source in log_sources:
|
||||||
|
log_env_var = source + "_LOG_LEVEL"
|
||||||
|
SRC_LOG_LEVELS[source] = os.environ.get(log_env_var, "").upper()
|
||||||
|
if SRC_LOG_LEVELS[source] not in log_levels:
|
||||||
|
SRC_LOG_LEVELS[source] = GLOBAL_LOG_LEVEL
|
||||||
|
log.info(f"{log_env_var}: {SRC_LOG_LEVELS[source]}")
|
||||||
|
|
||||||
|
log.setLevel(SRC_LOG_LEVELS["CONFIG"])
|
||||||
|
|
||||||
|
####################################
|
||||||
|
# Load .env file
|
||||||
|
####################################
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from dotenv import load_dotenv, find_dotenv
|
from dotenv import load_dotenv, find_dotenv
|
||||||
|
|
||||||
|
@ -122,47 +167,6 @@ STATIC_DIR = str(Path(os.getenv("STATIC_DIR", "./static")).resolve())
|
||||||
|
|
||||||
shutil.copyfile(f"{FRONTEND_BUILD_DIR}/favicon.png", f"{STATIC_DIR}/favicon.png")
|
shutil.copyfile(f"{FRONTEND_BUILD_DIR}/favicon.png", f"{STATIC_DIR}/favicon.png")
|
||||||
|
|
||||||
####################################
|
|
||||||
# LOGGING
|
|
||||||
####################################
|
|
||||||
log_levels = ["CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG"]
|
|
||||||
|
|
||||||
GLOBAL_LOG_LEVEL = os.environ.get("GLOBAL_LOG_LEVEL", "").upper()
|
|
||||||
if GLOBAL_LOG_LEVEL in log_levels:
|
|
||||||
logging.basicConfig(stream=sys.stdout, level=GLOBAL_LOG_LEVEL, force=True)
|
|
||||||
else:
|
|
||||||
GLOBAL_LOG_LEVEL = "INFO"
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
log.info(f"GLOBAL_LOG_LEVEL: {GLOBAL_LOG_LEVEL}")
|
|
||||||
|
|
||||||
log_sources = [
|
|
||||||
"AUDIO",
|
|
||||||
"COMFYUI",
|
|
||||||
"CONFIG",
|
|
||||||
"DB",
|
|
||||||
"IMAGES",
|
|
||||||
"LITELLM",
|
|
||||||
"MAIN",
|
|
||||||
"MODELS",
|
|
||||||
"OLLAMA",
|
|
||||||
"OPENAI",
|
|
||||||
"RAG",
|
|
||||||
"WEBHOOK",
|
|
||||||
]
|
|
||||||
|
|
||||||
SRC_LOG_LEVELS = {}
|
|
||||||
|
|
||||||
for source in log_sources:
|
|
||||||
log_env_var = source + "_LOG_LEVEL"
|
|
||||||
SRC_LOG_LEVELS[source] = os.environ.get(log_env_var, "").upper()
|
|
||||||
if SRC_LOG_LEVELS[source] not in log_levels:
|
|
||||||
SRC_LOG_LEVELS[source] = GLOBAL_LOG_LEVEL
|
|
||||||
log.info(f"{log_env_var}: {SRC_LOG_LEVELS[source]}")
|
|
||||||
|
|
||||||
log.setLevel(SRC_LOG_LEVELS["CONFIG"])
|
|
||||||
|
|
||||||
|
|
||||||
####################################
|
####################################
|
||||||
# CUSTOM_NAME
|
# CUSTOM_NAME
|
||||||
####################################
|
####################################
|
||||||
|
|
Loading…
Reference in a new issue