Changes from Windows

This commit is contained in:
Kat Inskip 2023-09-23 13:37:20 -07:00
parent a3ff57bc21
commit b2cf9c4870
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
2 changed files with 12 additions and 12 deletions

View file

@ -2,7 +2,7 @@ import logging
import termcolor import termcolor
""" """
Print a key-value pair with a key and value coloured differently. Print a key-value pair with a key and value.
:param key: The key to print :param key: The key to print
:param value: The value to print :param value: The value to print
@ -11,4 +11,4 @@ Print a key-value pair with a key and value coloured differently.
""" """
def kv_print(key: str, value: str, level: str = "INFO") -> None: def kv_print(key: str, value: str, level: str = "INFO") -> None:
logger = getattr(logging, level.lower()) logger = getattr(logging, level.lower())
logger(termcolor.colored(key, "cyan") + ": " + termcolor.colored(value, "white")) logger(f"{key}: {value}")

20
gui.py
View file

@ -35,9 +35,9 @@ def create_menu_item(menu, label, func):
return item return item
class Konawall(wx.adv.TaskBarIcon): class Konawall(wx.adv.TaskBarIcon):
def __init__(self, file_logger, console_logger): def __init__(self, file_logger):
self.file_logger = file_logger self.file_logger = file_logger
self.console_logger = console_logger #self.console_logger = console_logger
self.loaded = False self.loaded = False
wx.adv.TaskBarIcon.__init__(self) wx.adv.TaskBarIcon.__init__(self)
# Pre-setup initialization # Pre-setup initialization
@ -119,11 +119,11 @@ class Konawall(wx.adv.TaskBarIcon):
else: else:
file_log_level = logging.INFO file_log_level = logging.INFO
self.file_logger.setLevel(file_log_level) self.file_logger.setLevel(file_log_level)
if "console" in self.logging: #if "console" in self.logging:
console_log_level = getattr(logging, self.logging["console"]) # console_log_level = getattr(logging, self.logging["console"])
else: #else:
console_log_level = logging.INFO # console_log_level = logging.INFO
self.console_logger.setLevel(console_log_level) #self.console_logger.setLevel(console_log_level)
# Finished loading # Finished loading
self.loaded = True self.loaded = True
@ -160,15 +160,15 @@ class Konawall(wx.adv.TaskBarIcon):
if __name__ == "__main__": if __name__ == "__main__":
file_logger = logging.FileHandler("app.log", mode="a") file_logger = logging.FileHandler("app.log", mode="a")
console_logger = logging.StreamHandler() #console_logger = logging.StreamHandler()
logging.basicConfig( logging.basicConfig(
level=logging.DEBUG, level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(message)s", format="%(asctime)s - %(levelname)s - %(message)s",
handlers=[ handlers=[
console_logger, #console_logger,
file_logger, file_logger,
] ]
) )
app = wx.App(False) app = wx.App(False)
Konawall(file_logger, console_logger) Konawall(file_logger)
app.MainLoop() app.MainLoop()