fix logpath for real
This commit is contained in:
parent
aed1a85b20
commit
954593258c
4
myTS3.py
4
myTS3.py
|
@ -12,6 +12,7 @@ __status__ = "Development"
|
|||
import sys
|
||||
import time
|
||||
import json
|
||||
import os.path
|
||||
|
||||
# Custom
|
||||
import ts3
|
||||
|
@ -480,7 +481,8 @@ class TSbot:
|
|||
|
||||
def main():
|
||||
# Start logger
|
||||
log = util.setupLogger()
|
||||
logpath = os.path.dirname(os.path.abspath(__file__)) + r"\log"
|
||||
log = util.setupLogger(logpath)
|
||||
|
||||
# Log unhandled exception
|
||||
sys.excepthook = util.unhandledException
|
||||
|
|
|
@ -57,17 +57,16 @@ def getconf(fname):
|
|||
exit(1)
|
||||
|
||||
|
||||
def setupLogger(lvl="DEBUG"):
|
||||
def setupLogger(logpath, lvl="DEBUG"):
|
||||
"""
|
||||
Create a rotating log in a log folder
|
||||
"""
|
||||
|
||||
global log # Needed to log exceptions in src\util
|
||||
log = logging.getLogger()
|
||||
logpath = os.path.dirname(os.path.abspath(__file__)) + 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)
|
||||
if not os.path.exists(logpath):
|
||||
os.makedirs(logpath)
|
||||
handler = RotatingFileHandler(logpath + r"\myTS3.log", 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)
|
||||
|
|
Loading…
Reference in New Issue