diff --git a/IPython/config/application.py b/IPython/config/application.py index 7376cd8..d32a256 100644 --- a/IPython/config/application.py +++ b/IPython/config/application.py @@ -115,8 +115,10 @@ class LevelFormatter(logging.Formatter): record.highlevel = self.highlevel_format % record.__dict__ else: record.highlevel = "" - - return super(LevelFormatter, self).format(record) + if sys.version_info[:2] > (2,6): + return super(LevelFormatter, self).format(record) + else: + return logging.Formatter.format(self, record) class Application(SingletonConfigurable): diff --git a/IPython/config/tests/test_application.py b/IPython/config/tests/test_application.py index 97225d4..4269776 100644 --- a/IPython/config/tests/test_application.py +++ b/IPython/config/tests/test_application.py @@ -18,8 +18,11 @@ Authors: #----------------------------------------------------------------------------- import logging +from io import StringIO from unittest import TestCase +import nose.tools as nt + from IPython.config.configurable import Configurable from IPython.config.loader import Config @@ -80,6 +83,16 @@ class MyApp(Application): class TestApplication(TestCase): + def test_log(self): + stream = StringIO() + app = MyApp(log_level=logging.INFO) + handler = logging.StreamHandler(stream) + # trigger reconstruction of the log formatter + app.log.handlers = [handler] + app.log_format = "%(message)s" + app.log.info("hello") + nt.assert_in("hello", stream.getvalue()) + def test_basic(self): app = MyApp() self.assertEqual(app.name, u'myapp')