Set Log level by env (#3798)

### What problem does this PR solve?

Set Log level by env

### Type of change

- [x] Refactoring
This commit is contained in:
Zhichang Yu
2024-12-02 17:24:39 +08:00
committed by GitHub
parent c4b6df350a
commit c5f13629af
7 changed files with 82 additions and 62 deletions

View File

@ -19,19 +19,14 @@
import logging
import sys
import os
from api.utils.log_utils import initRootLogger
CONSUMER_NO = "0" if len(sys.argv) < 2 else sys.argv[1]
CONSUMER_NAME = "task_executor_" + CONSUMER_NO
initRootLogger(CONSUMER_NAME)
for module in ["pdfminer"]:
module_logger = logging.getLogger(module)
module_logger.setLevel(logging.WARNING)
for module in ["peewee"]:
module_logger = logging.getLogger(module)
module_logger.handlers.clear()
module_logger.propagate = True
LOG_LEVELS = os.environ.get("LOG_LEVELS", "")
initRootLogger(CONSUMER_NAME, LOG_LEVELS)
from datetime import datetime
import json