Permalink
Browse files

Convert to new Logger

  • Loading branch information...
1 parent f045d4c commit 682856433bf65ba355d12f13341b8f55de3b9ca7 @palango committed May 10, 2012
Showing with 161 additions and 1,028 deletions.
  1. +23 −4 pitivi/application.py
  2. +136 −1,021 pitivi/utils/loggable.py
  3. +2 −3 pitivi/utils/ui.py
View
@@ -31,6 +31,7 @@
import urllib
import ges
import gio
+import logging
from gettext import gettext as _
from optparse import OptionParser
@@ -50,7 +51,7 @@
from pitivi.utils.signal import Signallable
from pitivi.utils.system import getSystem
-from pitivi.utils.loggable import Loggable
+from pitivi.utils.loggable import Loggable, ColorizingStreamHandler
import pitivi.utils.loggable as log
#FIXME GES port disabled it
#from pitivi.undo.timeline import TimelineLogObserver
@@ -106,11 +107,29 @@ def __init__(self):
"""
Loggable.__init__(self)
+ root = logging.getLogger()
+ map = {"CRITICAL": logging.CRITICAL,
+ "ERROR": logging.ERROR,
+ "WARNING": logging.WARNING,
+ "INFO": logging.INFO,
+ "DEBUG": logging.DEBUG}
+
+ root.setLevel(map[os.environ.get("PITIVI_DEBUG")])
+
# init logging as early as possible so we can log startup code
- enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0')
- log.init('PITIVI_DEBUG', enable_color)
+ if os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0'):
+ handler = ColorizingStreamHandler()
+ formatter = logging.Formatter('[%(levelname)-8s %(asctime)s.%(msecs)d]!! %(message)s',
+ datefmt='%H:%M:%S')
+ else:
+ handler = logging.StreamHandler()
+ formatter = logging.Formatter('[%(levelname)-8s %(asctime)s.%(msecs)d] %(message)s',
+ datefmt='%H:%M:%S',)
+
+ handler.setFormatter(formatter)
+ root.addHandler(handler)
- self.info('starting up')
+ self.info('Starting PiTiVi %s' % pitivi_version)
# store ourself in the instance global
if instance.PiTiVi:
Oops, something went wrong.

1 comment on commit 6828564

I get this when starting pitivi normally:
root.setLevel(map[os.environ.get("PITIVI_DEBUG")])
KeyError: None

or KeyError: 4
if I start with PITIVI_DEBUG=4 bin/pitivi

or KeyError: :4
with PITIVI_DEBUG=
:4

Now the question is, loggable.py worked and certainly had a reason for its complexity (compatibility with gstreamer or something?). What are the issues you're trying to address here? If it's just a matter of readability, then my less-invasive 2d5be0e in my branch does that. Replacing this battle-tested code makes me slightly nervous, I'd like to know the reasons for the complexity of the previous implementation.

Please sign in to comment.