fix: typing, create log folder if missing
This commit is contained in:
parent
82cd2fbf1d
commit
989731574a
2 changed files with 7 additions and 4 deletions
|
@ -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()
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in a new issue