Skip to content

Clean up cli application setup

Closes #2082 (closed)

This PR clean up logging setup used by the cli in order to not break the ptpython layout when a new log is emitted.

Changes

  • Try to move logging handler into the cli module (it have to be managed by the BLISS cli app, not by the BLISS lib)
  • Use prompt-toolkit API to embed logs in the application terminal
  • Reduce even more logging setup from the BLISS lib

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