summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhandingkang <[email protected]>2024-04-11 15:34:38 +0800
committerhandingkang <[email protected]>2024-04-11 15:34:38 +0800
commit5f8a190f889f1aab771f8662373ddc810ddfeb7f (patch)
treea3f692716081cdd0b35094473ad9240dc19160af
parenteb4ce6f691cdd188d5ca9c39e5f005fe8b99a96b (diff)
新增日志记录功能
-rw-r--r--server/apps/util.py15
-rw-r--r--server/requirements.txt3
2 files changed, 17 insertions, 1 deletions
diff --git a/server/apps/util.py b/server/apps/util.py
index fa5caae..025d072 100644
--- a/server/apps/util.py
+++ b/server/apps/util.py
@@ -3,8 +3,22 @@ import pymysql
from faker import Faker
from faker.providers import company
from faker.providers import date_time
+from loguru import logger
from pymysql.cursors import DictCursor
+
+def debug(message, *args, **kwargs):
+ logger.debug(message, *args, **kwargs)
+
+
+def info(message, *args, **kwargs):
+ logger.info(message, *args, **kwargs)
+
+
+def error(message, *args, **kwargs):
+ logger.error(message, *args, **kwargs)
+
+
from settings import *
fake = Faker("zh_CN")
@@ -32,6 +46,7 @@ class DataHandler:
# 数据库链接及数据库初始化
def __init__(self):
+
# mysql连接,采用字典游标,返回一系列字典值
self.conn = pymysql.connect(cursorclass=DictCursor, host=MYSQL_HOST, user='root',
password=MYSQL_PAWD, port=MYSQL_PORT)
diff --git a/server/requirements.txt b/server/requirements.txt
index 0da63cc..56babab 100644
--- a/server/requirements.txt
+++ b/server/requirements.txt
@@ -7,4 +7,5 @@ six~=1.16.0
pandas~=2.1.4
faker~=18.9.0
dnspython~=2.6.1
-pymysql~=1.1.0 \ No newline at end of file
+pymysql~=1.1.0
+loguru~=0.5.3 \ No newline at end of file