CommonClient: explicitly set logging handlers, and explicitly set them to unicode.
This commit is contained in:
parent
beb15aa99a
commit
fa56541b3a
|
@ -22,7 +22,6 @@ gui_enabled = Utils.is_frozen() or "--nogui" not in sys.argv
|
||||||
log_folder = Utils.local_path("logs")
|
log_folder = Utils.local_path("logs")
|
||||||
os.makedirs(log_folder, exist_ok=True)
|
os.makedirs(log_folder, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
class ClientCommandProcessor(CommandProcessor):
|
class ClientCommandProcessor(CommandProcessor):
|
||||||
def __init__(self, ctx: CommonContext):
|
def __init__(self, ctx: CommonContext):
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
|
@ -518,12 +517,18 @@ async def console_loop(ctx: CommonContext):
|
||||||
|
|
||||||
|
|
||||||
def init_logging(name: str):
|
def init_logging(name: str):
|
||||||
if gui_enabled:
|
root_logger = logging.getLogger()
|
||||||
logging.basicConfig(format='[%(name)s]: %(message)s', level=logging.INFO,
|
root_logger.setLevel(logging.INFO)
|
||||||
filename=os.path.join(log_folder, f"{name}.txt"), filemode="w", force=True)
|
file_handler = logging.FileHandler(
|
||||||
else:
|
os.path.join(log_folder, f"{name}.txt"),
|
||||||
logging.basicConfig(format='[%(name)s]: %(message)s', level=logging.INFO, force=True)
|
"w",
|
||||||
logging.getLogger().addHandler(logging.FileHandler(os.path.join(log_folder, f"{name}.txt"), "w"))
|
encoding="utf-8-sig")
|
||||||
|
file_handler.setFormatter(logging.Formatter("[%(name)s]: %(message)s"))
|
||||||
|
root_logger.addHandler(file_handler)
|
||||||
|
if sys.stdout:
|
||||||
|
root_logger.addHandler(
|
||||||
|
logging.StreamHandler(sys.stdout)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
1
kvui.py
1
kvui.py
|
@ -7,6 +7,7 @@ import sys
|
||||||
os.environ["KIVY_NO_CONSOLELOG"] = "1"
|
os.environ["KIVY_NO_CONSOLELOG"] = "1"
|
||||||
os.environ["KIVY_NO_FILELOG"] = "1"
|
os.environ["KIVY_NO_FILELOG"] = "1"
|
||||||
os.environ["KIVY_NO_ARGS"] = "1"
|
os.environ["KIVY_NO_ARGS"] = "1"
|
||||||
|
os.environ["KIVY_LOG_ENABLE"] = "0"
|
||||||
|
|
||||||
from kivy.app import App
|
from kivy.app import App
|
||||||
from kivy.core.window import Window
|
from kivy.core.window import Window
|
||||||
|
|
Loading…
Reference in New Issue