Show More
@@ -261,3 +261,18 b' class SingletonConfigurable(Configurable):' | |||||
261 | """Has an instance been created?""" |
|
261 | """Has an instance been created?""" | |
262 | return hasattr(cls, "_instance") and cls._instance is not None |
|
262 | return hasattr(cls, "_instance") and cls._instance is not None | |
263 |
|
263 | |||
|
264 | ||||
|
265 | class LoggingConfigurable(Configurable): | |||
|
266 | """A parent class for Configurables that log. | |||
|
267 | ||||
|
268 | Subclasses have a log trait, and the default behavior | |||
|
269 | is to get the logger from the currently running Application | |||
|
270 | via Application.instance().log. | |||
|
271 | """ | |||
|
272 | ||||
|
273 | log = Instance('logging.Logger') | |||
|
274 | def _log_default(self): | |||
|
275 | from IPython.config.application import Application | |||
|
276 | return Application.instance().log | |||
|
277 | ||||
|
278 | No newline at end of file |
@@ -50,7 +50,7 b' except ImportError:' | |||||
50 | from zmq.eventloop import ioloop |
|
50 | from zmq.eventloop import ioloop | |
51 |
|
51 | |||
52 | from IPython.config.application import Application |
|
52 | from IPython.config.application import Application | |
53 | from IPython.config.configurable import Configurable |
|
53 | from IPython.config.configurable import LoggingConfigurable | |
54 | from IPython.utils.text import EvalFormatter |
|
54 | from IPython.utils.text import EvalFormatter | |
55 | from IPython.utils.traitlets import Any, Int, List, Unicode, Dict, Instance |
|
55 | from IPython.utils.traitlets import Any, Int, List, Unicode, Dict, Instance | |
56 | from IPython.utils.path import get_ipython_module_path |
|
56 | from IPython.utils.path import get_ipython_module_path | |
@@ -96,7 +96,7 b' class UnknownStatus(LauncherError):' | |||||
96 | pass |
|
96 | pass | |
97 |
|
97 | |||
98 |
|
98 | |||
99 | class BaseLauncher(Configurable): |
|
99 | class BaseLauncher(LoggingConfigurable): | |
100 | """An asbtraction for starting, stopping and signaling a process.""" |
|
100 | """An asbtraction for starting, stopping and signaling a process.""" | |
101 |
|
101 | |||
102 | # In all of the launchers, the work_dir is where child processes will be |
|
102 | # In all of the launchers, the work_dir is where child processes will be | |
@@ -108,9 +108,6 b' class BaseLauncher(Configurable):' | |||||
108 | # the work_dir option. |
|
108 | # the work_dir option. | |
109 | work_dir = Unicode(u'.') |
|
109 | work_dir = Unicode(u'.') | |
110 | loop = Instance('zmq.eventloop.ioloop.IOLoop') |
|
110 | loop = Instance('zmq.eventloop.ioloop.IOLoop') | |
111 | log = Instance('logging.Logger') |
|
|||
112 | def _log_default(self): |
|
|||
113 | return Application.instance().log |
|
|||
114 |
|
111 | |||
115 | start_data = Any() |
|
112 | start_data = Any() | |
116 | stop_data = Any() |
|
113 | stop_data = Any() |
@@ -19,8 +19,7 b' import sys' | |||||
19 | import zmq |
|
19 | import zmq | |
20 | from zmq.eventloop import ioloop, zmqstream |
|
20 | from zmq.eventloop import ioloop, zmqstream | |
21 |
|
21 | |||
22 |
from IPython.config. |
|
22 | from IPython.config.configurable import LoggingConfigurable | |
23 | from IPython.config.configurable import Configurable |
|
|||
24 | from IPython.utils.traitlets import Int, Unicode, Instance, List |
|
23 | from IPython.utils.traitlets import Int, Unicode, Instance, List | |
25 |
|
24 | |||
26 | #----------------------------------------------------------------------------- |
|
25 | #----------------------------------------------------------------------------- | |
@@ -28,17 +27,13 b' from IPython.utils.traitlets import Int, Unicode, Instance, List' | |||||
28 | #----------------------------------------------------------------------------- |
|
27 | #----------------------------------------------------------------------------- | |
29 |
|
28 | |||
30 |
|
29 | |||
31 | class LogWatcher(Configurable): |
|
30 | class LogWatcher(LoggingConfigurable): | |
32 | """A simple class that receives messages on a SUB socket, as published |
|
31 | """A simple class that receives messages on a SUB socket, as published | |
33 | by subclasses of `zmq.log.handlers.PUBHandler`, and logs them itself. |
|
32 | by subclasses of `zmq.log.handlers.PUBHandler`, and logs them itself. | |
34 |
|
33 | |||
35 | This can subscribe to multiple topics, but defaults to all topics. |
|
34 | This can subscribe to multiple topics, but defaults to all topics. | |
36 | """ |
|
35 | """ | |
37 |
|
36 | |||
38 | log = Instance('logging.Logger') |
|
|||
39 | def _log_default(self): |
|
|||
40 | return Application.instance().log |
|
|||
41 |
|
||||
42 | # configurables |
|
37 | # configurables | |
43 | topics = List([''], config=True, |
|
38 | topics = List([''], config=True, | |
44 | help="The ZMQ topics to subscribe to. Default is to subscribe to all messages") |
|
39 | help="The ZMQ topics to subscribe to. Default is to subscribe to all messages") |
@@ -44,8 +44,7 b' We support a subset of mongodb operators:' | |||||
44 |
|
44 | |||
45 | from datetime import datetime |
|
45 | from datetime import datetime | |
46 |
|
46 | |||
47 |
from IPython.config. |
|
47 | from IPython.config.configurable import LoggingConfigurable | |
48 | from IPython.config.configurable import Configurable |
|
|||
49 |
|
48 | |||
50 | from IPython.utils.traitlets import Dict, Unicode, Instance |
|
49 | from IPython.utils.traitlets import Dict, Unicode, Instance | |
51 |
|
50 | |||
@@ -80,13 +79,10 b' class CompositeFilter(object):' | |||||
80 | return False |
|
79 | return False | |
81 | return True |
|
80 | return True | |
82 |
|
81 | |||
83 | class BaseDB(Configurable): |
|
82 | class BaseDB(LoggingConfigurable): | |
84 | """Empty Parent class so traitlets work on DB.""" |
|
83 | """Empty Parent class so traitlets work on DB.""" | |
85 | # base configurable traits: |
|
84 | # base configurable traits: | |
86 | session = Unicode("") |
|
85 | session = Unicode("") | |
87 | log = Instance('logging.Logger') |
|
|||
88 | def _log_default(self): |
|
|||
89 | return Application.instance().log |
|
|||
90 |
|
86 | |||
91 | class DictDB(BaseDB): |
|
87 | class DictDB(BaseDB): | |
92 | """Basic in-memory dict-based object for saving Task Records. |
|
88 | """Basic in-memory dict-based object for saving Task Records. |
@@ -18,8 +18,7 b' import zmq' | |||||
18 | from zmq.devices import ThreadDevice |
|
18 | from zmq.devices import ThreadDevice | |
19 | from zmq.eventloop import ioloop, zmqstream |
|
19 | from zmq.eventloop import ioloop, zmqstream | |
20 |
|
20 | |||
21 |
from IPython.config. |
|
21 | from IPython.config.configurable import LoggingConfigurable | |
22 | from IPython.config.configurable import Configurable |
|
|||
23 | from IPython.utils.traitlets import Set, Instance, CFloat |
|
22 | from IPython.utils.traitlets import Set, Instance, CFloat | |
24 |
|
23 | |||
25 | class Heart(object): |
|
24 | class Heart(object): | |
@@ -48,7 +47,7 b' class Heart(object):' | |||||
48 | def start(self): |
|
47 | def start(self): | |
49 | return self.device.start() |
|
48 | return self.device.start() | |
50 |
|
49 | |||
51 | class HeartMonitor(Configurable): |
|
50 | class HeartMonitor(LoggingConfigurable): | |
52 | """A basic HeartMonitor class |
|
51 | """A basic HeartMonitor class | |
53 | pingstream: a PUB stream |
|
52 | pingstream: a PUB stream | |
54 | pongstream: an XREP stream |
|
53 | pongstream: an XREP stream | |
@@ -59,10 +58,6 b' class HeartMonitor(Configurable):' | |||||
59 | ' (in ms) [default: 100]', |
|
58 | ' (in ms) [default: 100]', | |
60 | ) |
|
59 | ) | |
61 |
|
60 | |||
62 | log = Instance('logging.Logger') |
|
|||
63 | def _log_default(self): |
|
|||
64 | return Application.instance().log |
|
|||
65 |
|
||||
66 | pingstream=Instance('zmq.eventloop.zmqstream.ZMQStream') |
|
61 | pingstream=Instance('zmq.eventloop.zmqstream.ZMQStream') | |
67 | pongstream=Instance('zmq.eventloop.zmqstream.ZMQStream') |
|
62 | pongstream=Instance('zmq.eventloop.zmqstream.ZMQStream') | |
68 | loop = Instance('zmq.eventloop.ioloop.IOLoop') |
|
63 | loop = Instance('zmq.eventloop.ioloop.IOLoop') |
General Comments 0
You need to be logged in to leave comments.
Login now