kvui: limit UI side logs to by default 1000 messages
This commit is contained in:
parent
cc61f16e57
commit
f7a0542898
|
@ -30,6 +30,8 @@
|
||||||
font_size: dp(20)
|
font_size: dp(20)
|
||||||
markup: True
|
markup: True
|
||||||
<UILog>:
|
<UILog>:
|
||||||
|
messages: 1000 # amount of messages stored in client logs.
|
||||||
|
cols: 1
|
||||||
viewclass: 'SelectableLabel'
|
viewclass: 'SelectableLabel'
|
||||||
scroll_y: 0
|
scroll_y: 0
|
||||||
scroll_type: ["content", "bars"]
|
scroll_type: ["content", "bars"]
|
||||||
|
|
8
kvui.py
8
kvui.py
|
@ -508,7 +508,7 @@ class LogtoUI(logging.Handler):
|
||||||
|
|
||||||
|
|
||||||
class UILog(RecycleView):
|
class UILog(RecycleView):
|
||||||
cols = 1
|
messages: typing.ClassVar[int] # comes from kv file
|
||||||
|
|
||||||
def __init__(self, *loggers_to_handle, **kwargs):
|
def __init__(self, *loggers_to_handle, **kwargs):
|
||||||
super(UILog, self).__init__(**kwargs)
|
super(UILog, self).__init__(**kwargs)
|
||||||
|
@ -518,9 +518,15 @@ class UILog(RecycleView):
|
||||||
|
|
||||||
def on_log(self, record: str) -> None:
|
def on_log(self, record: str) -> None:
|
||||||
self.data.append({"text": escape_markup(record)})
|
self.data.append({"text": escape_markup(record)})
|
||||||
|
self.clean_old()
|
||||||
|
|
||||||
def on_message_markup(self, text):
|
def on_message_markup(self, text):
|
||||||
self.data.append({"text": text})
|
self.data.append({"text": text})
|
||||||
|
self.clean_old()
|
||||||
|
|
||||||
|
def clean_old(self):
|
||||||
|
if len(self.data) > self.messages:
|
||||||
|
self.data.pop(0)
|
||||||
|
|
||||||
def fix_heights(self):
|
def fix_heights(self):
|
||||||
"""Workaround fix for divergent texture and layout heights"""
|
"""Workaround fix for divergent texture and layout heights"""
|
||||||
|
|
Loading…
Reference in New Issue