Skip to content
Snippets Groups Projects
Verified Commit 96bddaee authored by Philipp Hörist's avatar Philipp Hörist
Browse files

new: Store logging records in memory

parent d1c80c84
No related branches found
No related tags found
No related merge requests found
......@@ -77,6 +77,7 @@ bob_cache: dict[str, bytes] = {}
app = None # type: GajimApplication
window = None # type: MainWindow
commands = None # type: ChatCommands
logging_records: list[logging.LogRecord] = []
ged = ged_module.GlobalEventsDispatcher() # Global Events Dispatcher
plugin_manager = cast(types.PluginManagerT, None) # Plugins Manager
......
......@@ -106,6 +106,16 @@ def colorize(text: str, color: str) -> str:
return color + text + Colors.NONE
class CustomStreamHandler(logging.StreamHandler): # pyright: ignore
def __init__(self) -> None:
super().__init__() # pyright: ignore
def emit(self, record: logging.LogRecord) -> None:
if record.levelno >= logging.WARNING:
app.logging_records.append(record)
super().emit(record)
class FancyFormatter(logging.Formatter):
'''
An eye-candy formatter with Colors
......@@ -152,7 +162,7 @@ def init() -> None:
if os.name != 'nt':
use_color = sys.stderr.isatty()
consoleloghandler = logging.StreamHandler()
consoleloghandler = CustomStreamHandler()
consoleloghandler.setFormatter(
FancyFormatter(
'%(asctime)s %(levelname)s %(name)-35s %(message)s',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment