Skip to content

Draft: Create ptpython compliant logging handler

Closes #2082 (closed)

This MR clean up few things and then provide ptpython logging handler to embed the logs in the application terminal instead of logging it inside the bar stderr.

This allows to not break the ptpython layout.

Without this MR:

DEMO_SESSION [1]: import threading 
             ...: import time 
             ...: import logging 
             ...: class Foo(threading.Thread): 
             ...:     def run(self): 
             ...:         for i in range(10): 
             ...:             logging.error("abc") 
             ...:             time.sleep(1) 
             ...: foo = Foo() 
             ...: foo.start()            
ERROR 2020-09-23 08:52:42,889 root: abc
DEMO_SESSION [2]: ERROR 2020-09-23 08:52:43,890 root: abc
ERROR 2020-09-23 08:52:44,907 root: abc
ERROR 2020-09-23 08:52:45,909 root: abc
ERROR 2020-09-23 08:52:46,912 root: abc
ERROR 2020-09-23 08:52:47,913 root: abc
ERROR 2020-09-23 08:52:48,914 root: abc
ERROR 2020-09-23 08:52:49,916 root: abc] Scans [F6] Paste mode [F7] Typing helper (on) [F8] Logbook                                       [F2] Menu - CPython 3.7.9 
ERROR 2020-09-23 08:52:50,918 root: abc
ERROR 2020-09-23 08:52:51,920 root: abc

With this MR:

DEMO_SESSION [1]: import threading 
             ...: import time 
             ...: import logging 
             ...: class Foo(threading.Thread): 
             ...:     def run(self): 
             ...:         for i in range(10): 
             ...:             logging.error("abc") 
             ...:             time.sleep(1) 
             ...: foo = Foo() 
             ...: foo.start()            
ERROR 2020-09-23 08:51:52,584 root: abc
ERROR 2020-09-23 08:51:53,586 root: abc
ERROR 2020-09-23 08:51:54,587 root: abc
ERROR 2020-09-23 08:51:55,606 root: abc
ERROR 2020-09-23 08:51:56,608 root: abc
ERROR 2020-09-23 08:51:57,609 root: abc
ERROR 2020-09-23 08:51:58,610 root: abc
ERROR 2020-09-23 08:51:59,612 root: abc
ERROR 2020-09-23 08:52:00,614 root: abc
ERROR 2020-09-23 08:52:01,616 root: abc
DEMO_SESSION [2]:  

 [F4] Emacs  1938/1938 [F3] History [F5] Scans [F6] Paste mode [F7] Typing helper (on) [F8] Logbook                                       [F2] Menu - CPython 3.7.9 
Edited by Valentin Valls

Merge request reports