diff --git a/fir_ser/api/views/supersign.py b/fir_ser/api/views/supersign.py index c561cd7..4609899 100644 --- a/fir_ser/api/views/supersign.py +++ b/fir_ser/api/views/supersign.py @@ -435,7 +435,7 @@ class DeviceUsedRankInfoView(APIView): if end_time and start_time: try: start_time = datetime.date.fromtimestamp(int(start_time) / 1000) - end_time = datetime.date.fromtimestamp(int(end_time) / 1000 + 24 * 60 * 60 - 1) + end_time = datetime.date.fromtimestamp(int(end_time) / 1000) + datetime.timedelta(days=1) app_used_sign_objs = app_used_sign_objs.filter(created_time__range=[start_time, end_time]) except Exception as e: logger.error(f"get time range failed {e}") diff --git a/fir_ser/fir_ser/settings.py b/fir_ser/fir_ser/settings.py index 83f86c9..aae44a9 100644 --- a/fir_ser/fir_ser/settings.py +++ b/fir_ser/fir_ser/settings.py @@ -305,7 +305,7 @@ LOGGING = { }, 'handlers': { 'console': { - 'level': 'INFO', + 'level': 'DEBUG', 'filters': ['require_debug_true'], # 只有在Django debug为True时才在屏幕打印日志 'class': 'logging.StreamHandler', 'formatter': 'simple' @@ -347,6 +347,15 @@ LOGGING = { 'formatter': 'standard', 'encoding': 'utf-8', }, + 'sql': { + 'level': 'DEBUG', + 'class': 'logging.handlers.RotatingFileHandler', # 保存到文件,自动切 + 'filename': os.path.join(BASE_LOG_DIR, "flyapp_sql.log"), # 日志文件 + 'maxBytes': 1024 * 1024 * 5, # 日志大小 50M + 'backupCount': 10, + 'formatter': 'standard', + 'encoding': 'utf-8', + }, }, 'loggers': { '': { # 默认的logger应用如下配置 @@ -359,6 +368,11 @@ LOGGING = { 'level': 'DEBUG', 'propagate': True, }, + 'django.db.backends': { + 'handlers': ['console', 'sql'], + 'propagate': True, + 'level': 'DEBUG', + }, }, }