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
|
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
|
import os
|
||||||
from logging.handlers import RotatingFileHandler
|
from logging.handlers import RotatingFileHandler
|
||||||
|
|
||||||
|
@ -27,7 +27,9 @@ def configure_logging(name:str, level=logging.INFO, color:bool = True):
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
logger.setLevel(level)
|
logger.setLevel(level)
|
||||||
# create file handler which logs even debug messages
|
# 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)
|
fh.setLevel(logging.DEBUG)
|
||||||
# create console handler with a higher log level
|
# create console handler with a higher log level
|
||||||
ch = logging.StreamHandler()
|
ch = logging.StreamHandler()
|
||||||
|
|
|
@ -34,7 +34,8 @@ class Treepuncher(
|
||||||
GameInventory,
|
GameInventory,
|
||||||
GameContainer,
|
GameContainer,
|
||||||
GameTablist,
|
GameTablist,
|
||||||
GameWorld
|
GameWorld,
|
||||||
|
# GameMovement
|
||||||
):
|
):
|
||||||
name: str
|
name: str
|
||||||
storage: StorageDriver
|
storage: StorageDriver
|
||||||
|
@ -49,7 +50,7 @@ class Treepuncher(
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
name: str,
|
name: str,
|
||||||
config_file: str = None,
|
config_file: str = "",
|
||||||
**kwargs
|
**kwargs
|
||||||
):
|
):
|
||||||
self.ctx = dict()
|
self.ctx = dict()
|
||||||
|
|
Loading…
Reference in a new issue