mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-03-20 03:57:30 +08:00
fix(log): add support for CONFIG_DIR through environment variables
This commit is contained in:
10
app/log.py
10
app/log.py
@@ -2,7 +2,7 @@ import inspect
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
from pathlib import Path
|
||||
from typing import Dict, Any
|
||||
from typing import Dict, Any, Optional
|
||||
|
||||
import click
|
||||
from pydantic import BaseSettings
|
||||
@@ -14,6 +14,8 @@ class LogSettings(BaseSettings):
|
||||
"""
|
||||
日志设置
|
||||
"""
|
||||
# 配置文件目录
|
||||
CONFIG_DIR: Optional[str] = None
|
||||
# 是否为调试模式
|
||||
DEBUG: bool = False
|
||||
# 日志级别(DEBUG、INFO、WARNING、ERROR等)
|
||||
@@ -27,12 +29,16 @@ class LogSettings(BaseSettings):
|
||||
# 文件日志格式
|
||||
LOG_FILE_FORMAT: str = "【%(levelname)s】%(asctime)s - %(message)s"
|
||||
|
||||
@property
|
||||
def CONFIG_PATH(self):
|
||||
return SystemUtils.get_config_path(self.CONFIG_DIR)
|
||||
|
||||
@property
|
||||
def LOG_PATH(self):
|
||||
"""
|
||||
获取日志存储路径
|
||||
"""
|
||||
return SystemUtils.get_config_path() / "logs"
|
||||
return self.CONFIG_PATH / "logs"
|
||||
|
||||
@property
|
||||
def LOG_MAX_FILE_SIZE_BYTES(self):
|
||||
|
||||
Reference in New Issue
Block a user