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