Rework logging (#3358)

Unified all log files into one.

### What problem does this PR solve?

Unified all log files into one.

### Type of change

- [x] Refactoring
This commit is contained in:
Zhichang Yu
2024-11-12 17:35:13 +08:00
committed by GitHub
parent 567a7563e7
commit a2a5631da4
75 changed files with 481 additions and 853 deletions

View File

@@ -17,10 +17,10 @@
import json
import os
import time
import logging
import re
from api.utils.file_utils import get_project_base_directory
from api.utils.log_utils import logger
class Dealer:
@@ -32,15 +32,15 @@ class Dealer:
path = os.path.join(get_project_base_directory(), "rag/res", "synonym.json")
try:
self.dictionary = json.load(open(path, 'r'))
except Exception as e:
logging.warn("Missing synonym.json")
except Exception:
logger.warn("Missing synonym.json")
self.dictionary = {}
if not redis:
logging.warning(
logger.warning(
"Realtime synonym is disabled, since no redis connection.")
if not len(self.dictionary.keys()):
logging.warning(f"Fail to load synonym")
logger.warning("Fail to load synonym")
self.redis = redis
self.load()
@@ -64,7 +64,7 @@ class Dealer:
d = json.loads(d)
self.dictionary = d
except Exception as e:
logging.error("Fail to load synonym!" + str(e))
logger.error("Fail to load synonym!" + str(e))
def lookup(self, tk):
self.lookup_num += 1