From 4c3110c27d1b75dca02b69577e236ddc1a920b82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20H=C3=B6rist?= <philipp@hoerist.com> Date: Sat, 16 Feb 2019 10:36:27 +0100 Subject: [PATCH] Redirect some print statments to stderr Otherwise they errors will not show up if the console output is redirected to a file --- gajim/common/i18n.py | 8 ++++---- gajim/common/logging_helpers.py | 5 +++-- gajim/gtk/exception.py | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gajim/common/i18n.py b/gajim/common/i18n.py index ac427ec194..3d7d64d94e 100644 --- a/gajim/common/i18n.py +++ b/gajim/common/i18n.py @@ -163,7 +163,7 @@ def ngettext(s_sing, s_plural, n, replace_sing=None, replace_plural=None): try: locale.setlocale(locale.LC_ALL, '') except locale.Error as error: - print(error) + print(error, file=sys.stderr) try: LANG = get_default_lang() @@ -172,7 +172,7 @@ try: # find the translation os.environ['LANG'] = LANG except Exception as error: - print('Failed to determine default language') + print('Failed to determine default language', file=sys.stderr) import traceback traceback.print_exc() @@ -188,6 +188,6 @@ for dir_ in iter_locale_dirs(): else: break else: - print('No translations found') - print('Dirs searched: %s' % get_locale_dirs()) + print('No translations found', file=sys.stderr) + print('Dirs searched: %s' % get_locale_dirs(), file=sys.stderr) _ = _translation.gettext diff --git a/gajim/common/logging_helpers.py b/gajim/common/logging_helpers.py index fb5bd33898..1adb9d1431 100644 --- a/gajim/common/logging_helpers.py +++ b/gajim/common/logging_helpers.py @@ -28,7 +28,7 @@ def parseLogLevel(arg): return int(arg) if arg.isupper() and hasattr(logging, arg): return getattr(logging, arg) - print(_('%s is not a valid loglevel') % repr(arg)) + print(_('%s is not a valid loglevel') % repr(arg), file=sys.stderr) return 0 def parseLogTarget(arg): @@ -69,7 +69,8 @@ def parseAndSetLogLevels(arg): target = parseLogTarget(target.strip()) if target: logging.getLogger(target).setLevel(level) - print("Logger %s level set to %d" % (target, level)) + print("Logger %s level set to %d" % (target, level), + file=sys.stderr) class colors: diff --git a/gajim/gtk/exception.py b/gajim/gtk/exception.py index 7ac9f381f1..dfb287e780 100644 --- a/gajim/gtk/exception.py +++ b/gajim/gtk/exception.py @@ -80,7 +80,7 @@ class ExceptionDialog(): traceback.print_exception(type_, value, tb, None, trace) self.text = self.get_issue_text(trace.getvalue()) buffer_.set_text(self.text) - print(self.text) + print(self.text, file=sys.stderr) self._ui.exception_view.set_editable(False) self._ui.exception_dialog.show() -- GitLab