Show More
@@ -115,8 +115,10 b' class LevelFormatter(logging.Formatter):' | |||
|
115 | 115 | record.highlevel = self.highlevel_format % record.__dict__ |
|
116 | 116 | else: |
|
117 | 117 | record.highlevel = "" |
|
118 | ||
|
119 | return super(LevelFormatter, self).format(record) | |
|
118 | if sys.version_info[:2] > (2,6): | |
|
119 | return super(LevelFormatter, self).format(record) | |
|
120 | else: | |
|
121 | return logging.Formatter.format(self, record) | |
|
120 | 122 | |
|
121 | 123 | |
|
122 | 124 | class Application(SingletonConfigurable): |
@@ -18,8 +18,11 b' Authors:' | |||
|
18 | 18 | #----------------------------------------------------------------------------- |
|
19 | 19 | |
|
20 | 20 | import logging |
|
21 | from io import StringIO | |
|
21 | 22 | from unittest import TestCase |
|
22 | 23 | |
|
24 | import nose.tools as nt | |
|
25 | ||
|
23 | 26 | from IPython.config.configurable import Configurable |
|
24 | 27 | from IPython.config.loader import Config |
|
25 | 28 | |
@@ -80,6 +83,16 b' class MyApp(Application):' | |||
|
80 | 83 | |
|
81 | 84 | class TestApplication(TestCase): |
|
82 | 85 | |
|
86 | def test_log(self): | |
|
87 | stream = StringIO() | |
|
88 | app = MyApp(log_level=logging.INFO) | |
|
89 | handler = logging.StreamHandler(stream) | |
|
90 | # trigger reconstruction of the log formatter | |
|
91 | app.log.handlers = [handler] | |
|
92 | app.log_format = "%(message)s" | |
|
93 | app.log.info("hello") | |
|
94 | nt.assert_in("hello", stream.getvalue()) | |
|
95 | ||
|
83 | 96 | def test_basic(self): |
|
84 | 97 | app = MyApp() |
|
85 | 98 | self.assertEqual(app.name, u'myapp') |
General Comments 0
You need to be logged in to leave comments.
Login now