From 989731574afba66d24b6a0c9190fe4957dc8dcd5 Mon Sep 17 00:00:00 2001 From: alemi Date: Thu, 2 Nov 2023 05:32:21 +0100 Subject: [PATCH] fix: typing, create log folder if missing --- src/treepuncher/helpers.py | 6 ++++-- src/treepuncher/treepuncher.py | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/treepuncher/helpers.py b/src/treepuncher/helpers.py index 663dc8d..0e37387 100644 --- a/src/treepuncher/helpers.py +++ b/src/treepuncher/helpers.py @@ -4,7 +4,7 @@ from typing import Dict from termcolor import colored -def configure_logging(name:str, level=logging.INFO, color:bool = True): +def configure_logging(name:str, level=logging.INFO, color:bool = True, path:str = "log"): import os from logging.handlers import RotatingFileHandler @@ -27,7 +27,9 @@ def configure_logging(name:str, level=logging.INFO, color:bool = True): logger = logging.getLogger() logger.setLevel(level) # create file handler which logs even debug messages - fh = RotatingFileHandler(f'log/{name}.log', maxBytes=1048576, backupCount=5) # 1MB files + if not os.path.isdir(path): + os.mkdir(path) + fh = RotatingFileHandler(f'{path}/{name}.log', maxBytes=1048576, backupCount=5) # 1MB files fh.setLevel(logging.DEBUG) # create console handler with a higher log level ch = logging.StreamHandler() diff --git a/src/treepuncher/treepuncher.py b/src/treepuncher/treepuncher.py index ef64f7e..a607bcb 100644 --- a/src/treepuncher/treepuncher.py +++ b/src/treepuncher/treepuncher.py @@ -34,7 +34,8 @@ class Treepuncher( GameInventory, GameContainer, GameTablist, - GameWorld + GameWorld, + # GameMovement ): name: str storage: StorageDriver @@ -49,7 +50,7 @@ class Treepuncher( def __init__( self, name: str, - config_file: str = None, + config_file: str = "", **kwargs ): self.ctx = dict()