fixed logfile in settings to allow for adding or removing a logfile

This commit is contained in:
UpstreamData
2022-06-22 13:28:37 -06:00
parent f18d37a19e
commit 5261b00aad
3 changed files with 20 additions and 7 deletions

View File

@@ -1,14 +1,21 @@
import logging
from settings import DEBUG
from settings import DEBUG, LOGFILE
def init_logger():
logging.basicConfig(
# filename="logfile.txt",
# filemode="a",
format="%(pathname)s:%(lineno)d in %(funcName)s\n[%(levelname)s][%(asctime)s](%(name)s) - %(message)s",
datefmt="%x %X",
)
if LOGFILE:
logging.basicConfig(
filename="logfile.txt",
filemode="a",
format="%(pathname)s:%(lineno)d in %(funcName)s\n[%(levelname)s][%(asctime)s](%(name)s) - %(message)s",
datefmt="%x %X",
)
else:
logging.basicConfig(
format="%(pathname)s:%(lineno)d in %(funcName)s\n[%(levelname)s][%(asctime)s](%(name)s) - %(message)s",
datefmt="%x %X",
)
_logger = logging.getLogger()
if DEBUG:

View File

@@ -13,6 +13,7 @@ MINER_FACTORY_GET_VERSION_RETRIES: int = 3
WHATSMINER_PWD = "admin"
DEBUG = False
LOGFILE = False
settings_keys = {}
@@ -47,3 +48,6 @@ if "whatsminer_pwd" in settings_keys:
if "debug" in settings_keys:
DEBUG: int = settings["debug"]
if "logfile" in settings_keys:
LOGFILE: bool = settings["logfile"]

View File

@@ -13,6 +13,8 @@ reboot_threads = 300
whatsminer_pwd = "admin"
logfile = true
### DEBUG MODE ###
# change this to debug = true
# to enable debug mode.