Philipp Hörist pushed to branch master at gajim / gajim

Commits:
ddf60b01 by Philipp Hörist at 2017-02-25T17:21:03+01:00
Parse log arguments earlier

- - - - -


2 changed files:

- src/common/logging_helpers.py
- src/gajim.py


Changes:

=====================================
src/common/logging_helpers.py
=====================================
--- a/src/common/logging_helpers.py
+++ b/src/common/logging_helpers.py
@@ -19,6 +19,8 @@
 ##
 
 import logging
+import os
+import sys
 
 def parseLogLevel(arg):
     """
@@ -132,10 +134,14 @@ class FancyFormatter(logging.Formatter):
         return logging.Formatter.format(self, record)
 
 
-def init(use_color=False):
+def init():
     """
     Iinitialize the logging system
     """
+    use_color = False
+    if os.name != 'nt':
+        use_color = sys.stderr.isatty()
+
     consoleloghandler = logging.StreamHandler()
     consoleloghandler.setFormatter(
             FancyFormatter(
@@ -171,7 +177,7 @@ def set_quiet():
 
 # tests
 if __name__ == '__main__':
-    init(use_color=True)
+    init()
 
     set_loglevels('gajim.c=DEBUG,INFO')
 


=====================================
src/gajim.py
=====================================
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -60,9 +60,6 @@ except ImportError:
     print('PyOpenSSL not available, impossible to generate entropy', 
file=sys.stderr)
     PYOPENSSL_PRNG_PRESENT = False
 
-logging_helpers.init(sys.stderr.isatty())
-log = logging.getLogger('gajim.gajim')
-
 MIN_NBXMPP_VER = "0.5.3"
 
 
@@ -264,6 +261,9 @@ class GajimApplication(Gtk.Application):
             self.interface.roster.prepare_quit()
 
     def do_handle_local_options(self, options: GLib.VariantDict) -> int:
+
+        logging_helpers.init()
+
         if options.contains('profile'):
             # Incorporate profile name into application id
             # to have a single app instance for each profile.
@@ -279,18 +279,17 @@ class GajimApplication(Gtk.Application):
             from common.defs import version
             print(version)
             return 0
+        if options.contains('quiet'):
+            logging_helpers.set_quiet(True)
+        if options.contains('verbose'):
+            logging_helpers.set_verbose(True)
+        if options.contains('loglevel'):
+            loglevel = options.lookup_value('loglevel').get_string()
+            logging_helpers.set_loglevels(loglevel)
         return -1
 
     def do_command_line(self, command_line: Gio.ApplicationCommandLine) -> int:
         Gtk.Application.do_command_line(self, command_line)
-        options = command_line.get_options_dict()
-        if options.contains('quiet'):
-            logging_helpers.set_quiet()
-        if options.contains('verbose'):
-            logging_helpers.set_verbose()
-        if options.contains('loglevel'):
-            string = options.lookup_value('loglevel').get_string()
-            logging_helpers.set_loglevels(string)
         if not command_line.get_is_remote():
             self.activate()
         return 0



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/commit/ddf60b01b37e407de668c5240759897b2d9989c8
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to