symbola = find_font("Symbola")
if ubuntu_regular is None:
- error_print("Font Ubuntu regular could not be found, please install it.")
- sys.exit()
+ error_print("Font Ubuntu regular could not be found, "
+ "please install it.", exit=True)
if symbola is None:
- error_print("Font Symbola could not be found, please install it.")
- sys.exit()
+ error_print("Font Symbola could not be found, please install it.",
+ exit=True)
if ubuntu_bold is None:
warn_print("Font Ubuntu Bold could not be found.")
20 * math.log10(max(volume, 0.1) / max(old_volume, 0.1)),
max(volume, 0)]
-def debug_print(message, with_trace=False):
+def debug_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.debug('MusicSampler: ' + message, exc_info=with_trace)
-def error_print(message, with_trace=False):
- Logger.error('MusicSampler: ' + message, exc_info=with_trace)
+def error_print(message, exit=False, with_trace=None):
+ if with_trace is None:
+ with_trace = (Logger.getEffectiveLevel() < logging.WARN)
+ with_trace &= (sys.exc_info()[0] is not None)
+
+ # FIXME: handle it correctly when in a thread
+ if exit:
+ Logger.critical('MusicSampler: ' + message, exc_info=with_trace)
+ sys.exit(1)
+ else:
+ Logger.error('MusicSampler: ' + message, exc_info=with_trace)
+
+def warn_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)
-def warn_print(message, with_trace=False):
Logger.warn('MusicSampler: ' + message, exc_info=with_trace)