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

@ -1,10 +1,9 @@
import os
import time
from minio import Minio
from io import BytesIO
from rag import settings
from rag.settings import minio_logger
from rag.utils import singleton
from api.utils.log_utils import logger
@singleton
@ -17,7 +16,7 @@ class RAGFlowMinio(object):
try:
if self.conn:
self.__close__()
except Exception as e:
except Exception:
pass
try:
@ -26,9 +25,9 @@ class RAGFlowMinio(object):
secret_key=settings.MINIO["password"],
secure=False
)
except Exception as e:
minio_logger.error(
"Fail to connect %s " % settings.MINIO["host"] + str(e))
except Exception:
logger.exception(
"Fail to connect %s " % settings.MINIO["host"])
def __close__(self):
del self.conn
@ -55,24 +54,24 @@ class RAGFlowMinio(object):
len(binary)
)
return r
except Exception as e:
minio_logger.error(f"Fail put {bucket}/{fnm}: " + str(e))
except Exception:
logger.exception(f"Fail put {bucket}/{fnm}:")
self.__open__()
time.sleep(1)
def rm(self, bucket, fnm):
try:
self.conn.remove_object(bucket, fnm)
except Exception as e:
minio_logger.error(f"Fail rm {bucket}/{fnm}: " + str(e))
except Exception:
logger.exception(f"Fail put {bucket}/{fnm}:")
def get(self, bucket, fnm):
for _ in range(1):
try:
r = self.conn.get_object(bucket, fnm)
return r.read()
except Exception as e:
minio_logger.error(f"fail get {bucket}/{fnm}: " + str(e))
except Exception:
logger.exception(f"Fail put {bucket}/{fnm}:")
self.__open__()
time.sleep(1)
return
@ -81,8 +80,8 @@ class RAGFlowMinio(object):
try:
if self.conn.stat_object(bucket, fnm):return True
return False
except Exception as e:
minio_logger.error(f"Fail put {bucket}/{fnm}: " + str(e))
except Exception:
logger.exception(f"Fail put {bucket}/{fnm}:")
return False
@ -90,8 +89,8 @@ class RAGFlowMinio(object):
for _ in range(10):
try:
return self.conn.get_presigned_url("GET", bucket, fnm, expires)
except Exception as e:
minio_logger.error(f"fail get {bucket}/{fnm}: " + str(e))
except Exception:
logger.exception(f"Fail put {bucket}/{fnm}:")
self.__open__()
time.sleep(1)
return