better rich.traceback initialization

pull/14/head
sezanzeb 4 years ago
parent 9c7bac222e
commit 02ae3429a8

@ -36,14 +36,6 @@ from keymapper.gtk.window import Window
from keymapper.daemon import Daemon
try:
from rich.traceback import install
install(show_locals=True)
except Exception:
# since this is optional, just skip all exceptions
pass
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument(

@ -37,14 +37,6 @@ from keymapper.daemon import Daemon, BUS_NAME
from keymapper.dev.permissions import can_read_devices
try:
from rich.traceback import install
install(show_locals=True)
except Exception:
# since this is optional, just skip all exceptions
pass
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument(

@ -118,9 +118,21 @@ def log_info():
def update_verbosity(debug):
"""Set the logging verbosity according to the settings object."""
"""Set the logging verbosity according to the settings object.
Also enable rich tracebacks in debug mode.
"""
if debug:
logger.setLevel(SPAM)
try:
from rich.traceback import install
install(show_locals=True)
logger.debug('Using rich.traceback')
except Exception as error:
# since this is optional, just skip all exceptions
if not isinstance(error, ImportError):
logger.debug(f'Cannot use rich.traceback: {error}')
else:
logger.setLevel(logging.INFO)

Loading…
Cancel
Save