Clients: UX improvements (#615)

This commit is contained in:
black-sliver
2022-06-07 00:15:08 +02:00
committed by GitHub
parent 25bea47872
commit fbf993566d
3 changed files with 60 additions and 13 deletions

13
kvui.py
View File

@@ -464,8 +464,19 @@ class LogtoUI(logging.Handler):
super(LogtoUI, self).__init__(logging.INFO)
self.on_log = on_log
@staticmethod
def format_compact(record: logging.LogRecord) -> str:
if isinstance(record.msg, Exception):
return str(record.msg)
return (f'{record.exc_info[1]}\n' if record.exc_info else '') + str(record.msg).split("\n")[0]
def handle(self, record: logging.LogRecord) -> None:
self.on_log(self.format(record))
if getattr(record, 'skip_gui', False):
pass # skip output
elif getattr(record, 'compact_gui', False):
self.on_log(self.format_compact(record))
else:
self.on_log(self.format(record))
class UILog(RecycleView):