update code, switch to loguru
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
from .log import Log
|
||||
from .icon import Icon
|
||||
from .debug import debugMessage
|
||||
from .stringtodate import stringToDate
|
||||
from .documentation import launch_documentation
|
||||
@@ -1,18 +0,0 @@
|
||||
from src import config
|
||||
from icecream import ic
|
||||
from src.utils import Log
|
||||
log = Log("debugMessage")
|
||||
|
||||
def debugMessage(*args, **kwargs):
|
||||
startmessage = "Logging debug message"
|
||||
# join args and kwargs to a string
|
||||
message = " ".join(args)
|
||||
for key, value in kwargs.items():
|
||||
message += f" {key}: {value}"
|
||||
if config.debug:
|
||||
if config.log_debug:
|
||||
log.info(f"{startmessage}: {message}")
|
||||
if config.ic_logging == True:
|
||||
ic(message)
|
||||
else: print(message)
|
||||
return message
|
||||
@@ -1,7 +1,8 @@
|
||||
from pyramid.config import Configurator
|
||||
from wsgiref.simple_server import make_server
|
||||
from src import docport
|
||||
from src import docport, log
|
||||
import os
|
||||
import sys
|
||||
def website():
|
||||
config = Configurator()
|
||||
|
||||
@@ -14,8 +15,17 @@ def website():
|
||||
def launch_documentation():
|
||||
app = website()
|
||||
server = make_server('localhost', 6543, app)
|
||||
print("Serving MkDocs documentation on http://0.0.0.0:{}".format(docport))
|
||||
server.serve_forever()
|
||||
log.info("Serving MkDocs documentation on http://0.0.0.0:{}".format(docport))
|
||||
with open(os.devnull, "w") as devnull:
|
||||
old_stdout = sys.stdout
|
||||
old_stderr = sys.stderr
|
||||
sys.stdout = devnull
|
||||
sys.stderr = devnull
|
||||
try:
|
||||
server.serve_forever()
|
||||
finally:
|
||||
sys.stdout = old_stdout
|
||||
sys.stderr = old_stderr
|
||||
|
||||
if __name__ == '__main__':
|
||||
pass
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import logging
|
||||
|
||||
|
||||
class Log:
|
||||
def __init__(self, name):
|
||||
self.logger = logging.getLogger(name)
|
||||
self.logger.setLevel(logging.DEBUG)
|
||||
self.formatter = logging.Formatter(
|
||||
"%(asctime)s - %(name)s - %(levelname)s - %(message)s"
|
||||
)
|
||||
self.file_handler = logging.FileHandler("log.log")
|
||||
self.file_handler.setLevel(logging.DEBUG)
|
||||
self.file_handler.setFormatter(self.formatter)
|
||||
self.logger.addHandler(self.file_handler)
|
||||
|
||||
def info(self, message):
|
||||
self.logger.info(message)
|
||||
|
||||
def debug(self, message):
|
||||
self.logger.debug(message)
|
||||
|
||||
def error(self, message):
|
||||
self.logger.error(message)
|
||||
|
||||
def warning(self, message):
|
||||
self.logger.warning(message)
|
||||
@@ -1,6 +1,6 @@
|
||||
# import qdate
|
||||
from PyQt6 import QtCore
|
||||
from .debug import debugMessage
|
||||
from src import log
|
||||
def stringToDate(date: str) -> QtCore.QDate:
|
||||
"""Takes an input string and returns a QDate object.
|
||||
|
||||
@@ -10,7 +10,7 @@ def stringToDate(date: str) -> QtCore.QDate:
|
||||
Returns:
|
||||
QtCore.QDate: the QDate object in string format DD.MM.yyyy
|
||||
"""
|
||||
debugMessage(date=date)
|
||||
log.debug(f"stringToDate: {date}")
|
||||
if not date:
|
||||
return ""
|
||||
if isinstance(date, QtCore.QDate):
|
||||
@@ -21,22 +21,3 @@ def stringToDate(date: str) -> QtCore.QDate:
|
||||
month = datedata[1]
|
||||
year = datedata[0]
|
||||
return QtCore.QDate(int(year), int(month), int(day))
|
||||
|
||||
# else:
|
||||
# datedata = date.split(" ")[1:]
|
||||
# month = datedata[0]
|
||||
# day = datedata[1]
|
||||
# year = datedata[2]
|
||||
# month = month.replace("Jan", "01")
|
||||
# month = month.replace("Feb", "02")
|
||||
# month = month.replace("Mar", "03")
|
||||
# month = month.replace("Apr", "04")
|
||||
# month = month.replace("May", "05")
|
||||
# month = month.replace("Jun", "06")
|
||||
# month = month.replace("Jul", "07")
|
||||
# month = month.replace("Aug", "08")
|
||||
# month = month.replace("Sep", "09")
|
||||
# month = month.replace("Oct", "10")
|
||||
# month = month.replace("Nov", "11")
|
||||
# month = month.replace("Dec", "12")
|
||||
# return QtCore.QDate(int(year), int(month), int(day)).toString("dd.MM.yyyy")
|
||||
|
||||
Reference in New Issue
Block a user