Use consistent log file names, introduced initLogger (#3403)

### What problem does this PR solve?

Use consistent log file names, introduced initLogger

### Type of change

- [ ] Bug Fix (non-breaking change which fixes an issue)
- [ ] New Feature (non-breaking change which adds functionality)
- [ ] Documentation Update
- [x] Refactoring
- [ ] Performance Improvement
- [ ] Other (please describe):
This commit is contained in:
Zhichang Yu
2024-11-14 17:13:48 +08:00
committed by GitHub
parent ab4384e011
commit 30f6421760
75 changed files with 396 additions and 402 deletions

View File

@ -15,6 +15,7 @@
#
import os
import sys
import logging
from importlib.util import module_from_spec, spec_from_file_location
from pathlib import Path
from flask import Blueprint, Flask
@ -32,7 +33,6 @@ from flask_login import LoginManager
from api.settings import SECRET_KEY
from api.settings import API_VERSION
from api.utils.api_utils import server_error_response
from api.utils.log_utils import logger
from itsdangerous.url_safe import URLSafeTimedSerializer as Serializer
__all__ = ["app"]
@ -154,7 +154,7 @@ def load_user(web_request):
else:
return None
except Exception:
logger.exception("load_user got exception")
logging.exception("load_user got exception")
return None
else:
return None

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import json
from functools import partial
from flask import request, Response
@ -23,7 +24,6 @@ from api.utils import get_uuid
from api.utils.api_utils import get_json_result, server_error_response, validate_request, get_data_error_result
from agent.canvas import Canvas
from peewee import MySQLDatabase, PostgresqlDatabase
from api.utils.log_utils import logger
@manager.route('/templates', methods=['GET'])
@ -115,7 +115,7 @@ def run():
pass
canvas.add_user_input(req["message"])
answer = canvas.run(stream=stream)
logger.info(canvas)
logging.debug(canvas)
except Exception as e:
return server_error_response(e)

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import json
from flask import request
@ -25,7 +26,6 @@ from api.db.db_models import TenantLLM
from api.utils.api_utils import get_json_result
from rag.llm import EmbeddingModel, ChatModel, RerankModel, CvModel, TTSModel
import requests
from api.utils.log_utils import logger
@manager.route('/factories', methods=['GET'])
@ -90,7 +90,7 @@ def set_api_key():
if len(arr) == 0 or tc == 0:
raise Exception("Fail")
rerank_passed = True
logger.info(f'passed model rerank {llm.llm_name}')
logging.debug(f'passed model rerank {llm.llm_name}')
except Exception as e:
msg += f"\nFail to access model({llm.llm_name}) using this api key." + str(
e)

View File

@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import logging
import json
import re
from datetime import datetime
@ -54,7 +55,6 @@ from api.settings import (
from api.db.services.user_service import UserService, TenantService, UserTenantService
from api.db.services.file_service import FileService
from api.utils.api_utils import get_json_result, construct_response
from api.utils.log_utils import logger
@manager.route("/login", methods=["POST", "GET"])
@ -177,7 +177,7 @@ def github_callback():
try:
avatar = download_img(user_info["avatar_url"])
except Exception as e:
logger.exception(e)
logging.exception(e)
avatar = ""
users = user_register(
user_id,
@ -202,7 +202,7 @@ def github_callback():
return redirect("/?auth=%s" % user.get_id())
except Exception as e:
rollback_user_registration(user_id)
logger.exception(e)
logging.exception(e)
return redirect("/?error=%s" % str(e))
# User has already registered, try to log in
@ -279,7 +279,7 @@ def feishu_callback():
try:
avatar = download_img(user_info["avatar_url"])
except Exception as e:
logger.exception(e)
logging.exception(e)
avatar = ""
users = user_register(
user_id,
@ -304,7 +304,7 @@ def feishu_callback():
return redirect("/?auth=%s" % user.get_id())
except Exception as e:
rollback_user_registration(user_id)
logger.exception(e)
logging.exception(e)
return redirect("/?error=%s" % str(e))
# User has already registered, try to log in
@ -436,7 +436,7 @@ def setting_user():
UserService.update_by_id(current_user.id, update_dict)
return get_json_result(data=True)
except Exception as e:
logger.exception(e)
logging.exception(e)
return get_json_result(
data=False, message="Update failure!", code=RetCode.EXCEPTION_ERROR
)
@ -621,7 +621,7 @@ def user_add():
)
except Exception as e:
rollback_user_registration(user_id)
logger.exception(e)
logging.exception(e)
return get_json_result(
data=False,
message=f"User registration failure, error: {str(e)}",