fix logging mkdir

This commit is contained in:
shenjack 2023-05-14 23:49:24 +08:00
parent 0fae2ce610
commit a0f55895d1

View File

@ -85,10 +85,10 @@ class Game(Options):
def init_logger(self) -> None: def init_logger(self) -> None:
log_path = self.logging_config['handlers']['file']['filename'] log_path = self.logging_config['handlers']['file']['filename']
log_path = Path(f"logs/{log_path.format(time.strftime('%Y-%m-%d %H-%M-%S' , time.gmtime(DR_runtime.start_time_ns / 1000_000_000)))}") log_path = f"logs/{log_path.format(time.strftime('%Y-%m-%d %H-%M-%S' , time.gmtime(DR_runtime.start_time_ns / 1000_000_000)))}"
mkdir = False mkdir = False
if not Path("logs/").exists(): if not Path('logs/').is_dir():
log_path.mkdir(parents=True) Path('logs/').mkdir()
mkdir = True mkdir = True
self.logging_config['handlers']['file']['filename'] = str(log_path.absolute()) self.logging_config['handlers']['file']['filename'] = str(log_path.absolute())
logging.config.dictConfig(self.logging_config) logging.config.dictConfig(self.logging_config)