Added separate get_logs_dir function for logs dir
Instead of piggy-backing on the data dir
This commit is contained in:
@@ -213,6 +213,7 @@ class Info(BaseModel):
|
|||||||
debug_mode: bool = Field(example=False)
|
debug_mode: bool = Field(example=False)
|
||||||
automatic_backups: bool = Field(example=True)
|
automatic_backups: bool = Field(example=True)
|
||||||
data_dir: str = Field(example="/home/app/.local/share/spoolman")
|
data_dir: str = Field(example="/home/app/.local/share/spoolman")
|
||||||
|
logs_dir: str = Field(example="/home/app/.local/share/spoolman")
|
||||||
backups_dir: str = Field(example="/home/app/.local/share/spoolman/backups")
|
backups_dir: str = Field(example="/home/app/.local/share/spoolman/backups")
|
||||||
db_type: str = Field(example="sqlite")
|
db_type: str = Field(example="sqlite")
|
||||||
git_commit: Optional[str] = Field(example="a1b2c3d")
|
git_commit: Optional[str] = Field(example="a1b2c3d")
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ async def info() -> models.Info:
|
|||||||
debug_mode=env.is_debug_mode(),
|
debug_mode=env.is_debug_mode(),
|
||||||
automatic_backups=env.is_automatic_backup_enabled(),
|
automatic_backups=env.is_automatic_backup_enabled(),
|
||||||
data_dir=str(env.get_data_dir().resolve()),
|
data_dir=str(env.get_data_dir().resolve()),
|
||||||
|
logs_dir=str(env.get_logs_dir().resolve()),
|
||||||
backups_dir=str(env.get_backups_dir().resolve()),
|
backups_dir=str(env.get_backups_dir().resolve()),
|
||||||
db_type=str(env.get_database_type() or "sqlite"),
|
db_type=str(env.get_database_type() or "sqlite"),
|
||||||
git_commit=env.get_commit_hash(),
|
git_commit=env.get_commit_hash(),
|
||||||
|
|||||||
@@ -231,6 +231,15 @@ def get_data_dir() -> Path:
|
|||||||
return data_dir
|
return data_dir
|
||||||
|
|
||||||
|
|
||||||
|
def get_logs_dir() -> Path:
|
||||||
|
"""Get the logs directory.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Path: The logs directory.
|
||||||
|
"""
|
||||||
|
return get_data_dir()
|
||||||
|
|
||||||
|
|
||||||
def get_backups_dir() -> Path:
|
def get_backups_dir() -> Path:
|
||||||
"""Get the backups directory.
|
"""Get the backups directory.
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ if env.is_debug_mode():
|
|||||||
def add_file_logging() -> None:
|
def add_file_logging() -> None:
|
||||||
"""Add file logging to the root logger."""
|
"""Add file logging to the root logger."""
|
||||||
# Define a file logger with log rotation
|
# Define a file logger with log rotation
|
||||||
log_file = env.get_data_dir().joinpath("spoolman.log")
|
log_file = env.get_logs_dir().joinpath("spoolman.log")
|
||||||
file_handler = TimedRotatingFileHandler(log_file, when="midnight", backupCount=5)
|
file_handler = TimedRotatingFileHandler(log_file, when="midnight", backupCount=5)
|
||||||
file_handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(message)s", "%Y-%m-%d %H:%M:%S"))
|
file_handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(message)s", "%Y-%m-%d %H:%M:%S"))
|
||||||
root_logger.addHandler(file_handler)
|
root_logger.addHandler(file_handler)
|
||||||
|
|||||||
Reference in New Issue
Block a user