Merged PR 2899: Create .anaxi folder automatically if it does not exist
This PR ensures that the logger sets up automatically in case the folder does not exists. It just checks if the directory exists, and if it does not exist, it just creates the .anaxi folder. Checked in local by dropping the folder and works well.
This commit is contained in:
commit
12299602e4
1 changed files with 4 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from anaxi.constants import PATHS
|
||||
|
||||
|
|
@ -14,6 +15,9 @@ def get_anaxi_logger(name: str) -> None:
|
|||
console_handler.setFormatter(anaxi_formatter)
|
||||
logger.addHandler(console_handler)
|
||||
|
||||
if not os.path.exists(os.path.dirname(PATHS.logging_file)):
|
||||
os.makedirs(os.path.dirname(PATHS.logging_file))
|
||||
|
||||
file_handler = logging.FileHandler(filename=PATHS.logging_file)
|
||||
file_handler.setFormatter(anaxi_formatter)
|
||||
logger.addHandler(file_handler)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue