From 5e0dc4b280187b2dd063b010a7c8c678f6398403 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 12 Aug 2016 13:53:14 +0200 Subject: [PATCH] Add config dump in debug mode Fixes https://git.immae.eu/mantisbt/view.php?id=19 --- music_sampler/app.py | 3 ++- music_sampler/helpers.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/music_sampler/app.py b/music_sampler/app.py index ce84235..74f0acb 100644 --- a/music_sampler/app.py +++ b/music_sampler/app.py @@ -1,4 +1,4 @@ -from .helpers import parse_args, register_fonts, path +from .helpers import parse_args, dump_config, register_fonts, path parse_args() @@ -12,6 +12,7 @@ from kivy.properties import ListProperty, StringProperty from kivy.core.window import Window from kivy.lang import Builder +dump_config() register_fonts() diff --git a/music_sampler/helpers.py b/music_sampler/helpers.py index 943e5a1..9403875 100644 --- a/music_sampler/helpers.py +++ b/music_sampler/helpers.py @@ -214,6 +214,15 @@ def parse_args(): if not Config.music_path.endswith("/"): Config.music_path = Config.music_path + "/" +def dump_config(): + max_size = max(max(map(len, Configs_order)), len('config')) + info_print("{:<{}} : {}".format( + "config", max_size, Config.yml_file)) + for item in Config.__dict__: + if item in Configs_order: + info_print("{:<{}} : {}".format( + item, max_size, getattr(Config, item))) + def build_config(args): stream = open(Config.yml_file, "r") try: @@ -297,3 +306,10 @@ def warn_print(message, with_trace=None): Logger.warn('MusicSampler: ' + message, exc_info=with_trace) +def info_print(message, with_trace=None): + if with_trace is None: + with_trace = (Logger.getEffectiveLevel() < logging.WARN) + with_trace &= (sys.exc_info()[0] is not None) + + Logger.info('MusicSampler: ' + message, exc_info=with_trace) + -- 2.41.0