diff --git a/myTS3.py b/myTS3.py index d1b2b9f..94e9f56 100644 --- a/myTS3.py +++ b/myTS3.py @@ -131,8 +131,11 @@ class TSbot: if 'client_nickname' in event[0]: displayname = event[0]['client_nickname'] - else: + elif 'clid' in event[0]: displayname = event[0]['clid'] + else: + self.pipeOut(event[0]) + displayname = "Unresolved" self.pipeOut(f"Client [{displayname}] connected.") diff --git a/src/template.toml b/src/template.toml index be36ef8..ce5f04e 100644 --- a/src/template.toml +++ b/src/template.toml @@ -1,5 +1,5 @@ [Connection] -host = "example.com" +host = "127.0.0.1" port = 10011 sid = 1 diff --git a/src/util.py b/src/util.py index 362e1c6..9ba4842 100644 --- a/src/util.py +++ b/src/util.py @@ -14,7 +14,7 @@ import sys import shutil import os.path import logging -from datetime import date +from logging.handlers import RotatingFileHandler # Custom import toml @@ -59,13 +59,16 @@ def getconf(fname): def setupLogger(lvl="DEBUG"): """ - + Create a rotating log in a log folder """ + global log # Needed to log exceptions in src\util log = logging.getLogger() - now = date.today().strftime("%Y-%m-%d") - handler = logging.FileHandler(f"myTS3_{now}.log", encoding="utf-8") - logformat = logging.Formatter("%(asctime)s %(levelname)7s %(message)s", "%d-%m-%Y %H:%M:%S") + logpath = r".\log\myTS3.log" + if not os.path.exists(os.path.dirname(logpath)): + os.makedirs(os.path.dirname(logpath)) + handler = RotatingFileHandler(logpath, encoding='utf-8', maxBytes=5*1024*1024, backupCount=10) + logformat = logging.Formatter("%(asctime)s %(levelname)7s %(message)s", "%Y-%m-%d %H:%M:%S") handler.setFormatter(logformat) log.addHandler(handler) log.setLevel(lvl)