]> git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/commitdiff
Add config dump in debug mode
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 12 Aug 2016 11:53:14 +0000 (13:53 +0200)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Fri, 12 Aug 2016 11:53:48 +0000 (13:53 +0200)
Fixes https://git.immae.eu/mantisbt/view.php?id=19

music_sampler/app.py
music_sampler/helpers.py

index ce842358240d0e6cbb56206513ab539ba7b94bc7..74f0acb679cd4bbd76267b656e6e8865cfcb0a07 100644 (file)
@@ -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()
 
 
index 943e5a197465143dc2f47e193bfbcc0f3bdf94e2..9403875cbfe49a82b91ab5772b42f1452eb78b81 100644 (file)
@@ -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)
+