Merge pull request #29 from presenton/logging_fixes
fix(fastapi):save api logs
This commit is contained in:
commit
ca8a9fc277
1 changed files with 6 additions and 0 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import os
|
||||
from typing import Any
|
||||
import logging
|
||||
from logging import Logger
|
||||
|
||||
|
||||
|
|
@ -7,6 +9,10 @@ class LoggingService:
|
|||
def __init__(self, stream_name: str):
|
||||
self._logger = Logger(stream_name)
|
||||
|
||||
log_file_path = os.path.join(os.getenv("APP_DATA_DIRECTORY"), "logs", "api.log")
|
||||
os.makedirs(os.path.dirname(log_file_path), exist_ok=True)
|
||||
self._logger.addHandler(logging.FileHandler(log_file_path))
|
||||
|
||||
@property
|
||||
def logger(self) -> Logger:
|
||||
return self._logger
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue