Show More
@@ -0,0 +1,25 b'' | |||
|
1 | """Grab the global logger instance.""" | |
|
2 | ||
|
3 | # Copyright (c) IPython Development Team. | |
|
4 | # Distributed under the terms of the Modified BSD License. | |
|
5 | ||
|
6 | import logging | |
|
7 | ||
|
8 | _logger = None | |
|
9 | ||
|
10 | def get_logger(): | |
|
11 | """Grab the global logger instance. | |
|
12 | ||
|
13 | If a global IPython Application is instantiated, grab its logger. | |
|
14 | Otherwise, grab the root logger. | |
|
15 | """ | |
|
16 | global _logger | |
|
17 | ||
|
18 | if _logger is None: | |
|
19 | from IPython.config import Application | |
|
20 | if Application.initialized(): | |
|
21 | _logger = Application.instance().log | |
|
22 | else: | |
|
23 | logging.basicConfig() | |
|
24 | _logger = logging.getLogger() | |
|
25 | return _logger |
@@ -1,31 +1,11 b'' | |||
|
1 | 1 | # encoding: utf-8 |
|
2 | """ | |
|
3 | A base class for objects that are configurable. | |
|
2 | """A base class for objects that are configurable.""" | |
|
4 | 3 | |
|
5 | Inheritance diagram: | |
|
4 | # Copyright (c) IPython Development Team. | |
|
5 | # Distributed under the terms of the Modified BSD License. | |
|
6 | 6 | |
|
7 | .. inheritance-diagram:: IPython.config.configurable | |
|
8 | :parts: 3 | |
|
9 | ||
|
10 | Authors: | |
|
11 | ||
|
12 | * Brian Granger | |
|
13 | * Fernando Perez | |
|
14 | * Min RK | |
|
15 | """ | |
|
16 | 7 | from __future__ import print_function |
|
17 | 8 | |
|
18 | #----------------------------------------------------------------------------- | |
|
19 | # Copyright (C) 2008-2011 The IPython Development Team | |
|
20 | # | |
|
21 | # Distributed under the terms of the BSD License. The full license is in | |
|
22 | # the file COPYING, distributed as part of this software. | |
|
23 | #----------------------------------------------------------------------------- | |
|
24 | ||
|
25 | #----------------------------------------------------------------------------- | |
|
26 | # Imports | |
|
27 | #----------------------------------------------------------------------------- | |
|
28 | ||
|
29 | 9 | import logging |
|
30 | 10 | from copy import deepcopy |
|
31 | 11 | |
@@ -375,16 +355,12 b' class LoggingConfigurable(Configurable):' | |||
|
375 | 355 | """A parent class for Configurables that log. |
|
376 | 356 | |
|
377 | 357 | Subclasses have a log trait, and the default behavior |
|
378 | is to get the logger from the currently running Application | |
|
379 | via Application.instance().log. | |
|
358 | is to get the logger from the currently running Application. | |
|
380 | 359 | """ |
|
381 | 360 | |
|
382 | 361 | log = Instance('logging.Logger') |
|
383 | 362 | def _log_default(self): |
|
384 |
from IPython. |
|
|
385 | if Application.initialized(): | |
|
386 | return Application.instance().log | |
|
387 | else: | |
|
388 | return logging.getLogger() | |
|
363 | from IPython.utils import log | |
|
364 | return log.get_logger() | |
|
389 | 365 | |
|
390 | 366 |
@@ -1,27 +1,8 b'' | |||
|
1 | """A simple configuration system. | |
|
1 | # encoding: utf-8 | |
|
2 | """A simple configuration system.""" | |
|
2 | 3 | |
|
3 | Inheritance diagram: | |
|
4 | ||
|
5 | .. inheritance-diagram:: IPython.config.loader | |
|
6 | :parts: 3 | |
|
7 | ||
|
8 | Authors | |
|
9 | ------- | |
|
10 | * Brian Granger | |
|
11 | * Fernando Perez | |
|
12 | * Min RK | |
|
13 | """ | |
|
14 | ||
|
15 | #----------------------------------------------------------------------------- | |
|
16 | # Copyright (C) 2008-2011 The IPython Development Team | |
|
17 | # | |
|
18 | # Distributed under the terms of the BSD License. The full license is in | |
|
19 | # the file COPYING, distributed as part of this software. | |
|
20 | #----------------------------------------------------------------------------- | |
|
21 | ||
|
22 | #----------------------------------------------------------------------------- | |
|
23 | # Imports | |
|
24 | #----------------------------------------------------------------------------- | |
|
4 | # Copyright (c) IPython Development Team. | |
|
5 | # Distributed under the terms of the Modified BSD License. | |
|
25 | 6 | |
|
26 | 7 | import argparse |
|
27 | 8 | import copy |
@@ -308,11 +289,8 b' class ConfigLoader(object):' | |||
|
308 | 289 | """ |
|
309 | 290 | |
|
310 | 291 | def _log_default(self): |
|
311 |
from IPython. |
|
|
312 | if Application.initialized(): | |
|
313 | return Application.instance().log | |
|
314 | else: | |
|
315 | return logging.getLogger() | |
|
292 | from IPython.utils.log import get_logger | |
|
293 | return get_logger() | |
|
316 | 294 | |
|
317 | 295 | def __init__(self, log=None): |
|
318 | 296 | """A base class for config loaders. |
@@ -1,21 +1,7 b'' | |||
|
1 | """Base Tornado handlers for the notebook. | |
|
2 | ||
|
3 | Authors: | |
|
4 | ||
|
5 | * Brian Granger | |
|
6 | """ | |
|
7 | ||
|
8 | #----------------------------------------------------------------------------- | |
|
9 | # Copyright (C) 2011 The IPython Development Team | |
|
10 | # | |
|
11 | # Distributed under the terms of the BSD License. The full license is in | |
|
12 | # the file COPYING, distributed as part of this software. | |
|
13 | #----------------------------------------------------------------------------- | |
|
14 | ||
|
15 | #----------------------------------------------------------------------------- | |
|
16 | # Imports | |
|
17 | #----------------------------------------------------------------------------- | |
|
1 | """Base Tornado handlers for the notebook.""" | |
|
18 | 2 | |
|
3 | # Copyright (c) IPython Development Team. | |
|
4 | # Distributed under the terms of the Modified BSD License. | |
|
19 | 5 | |
|
20 | 6 | import functools |
|
21 | 7 | import json |
@@ -1,21 +1,4 b'' | |||
|
1 | """The official API for working with notebooks in the current format version. | |
|
2 | ||
|
3 | Authors: | |
|
4 | ||
|
5 | * Brian Granger | |
|
6 | * Jonathan Frederic | |
|
7 | """ | |
|
8 | ||
|
9 | #----------------------------------------------------------------------------- | |
|
10 | # Copyright (C) 2008-2011 The IPython Development Team | |
|
11 | # | |
|
12 | # Distributed under the terms of the BSD License. The full license is in | |
|
13 | # the file COPYING, distributed as part of this software. | |
|
14 | #----------------------------------------------------------------------------- | |
|
15 | ||
|
16 | #----------------------------------------------------------------------------- | |
|
17 | # Imports | |
|
18 | #----------------------------------------------------------------------------- | |
|
1 | """The official API for working with notebooks in the current format version.""" | |
|
19 | 2 | |
|
20 | 3 | from __future__ import print_function |
|
21 | 4 | |
@@ -37,12 +20,8 b' from .reader import versions' | |||
|
37 | 20 | from .convert import convert |
|
38 | 21 | from .validator import validate |
|
39 | 22 | |
|
40 | import logging | |
|
41 | logger = logging.getLogger('NotebookApp') | |
|
23 | from IPython.utils.log import get_logger | |
|
42 | 24 | |
|
43 | #----------------------------------------------------------------------------- | |
|
44 | # Code | |
|
45 | #----------------------------------------------------------------------------- | |
|
46 | 25 | |
|
47 | 26 | current_nbformat = nbformat |
|
48 | 27 | current_nbformat_minor = nbformat_minor |
@@ -88,7 +67,7 b' def reads_json(nbjson, **kwargs):' | |||
|
88 | 67 | nb_current = convert(nb, current_nbformat) |
|
89 | 68 | errors = validate(nb_current) |
|
90 | 69 | if errors: |
|
91 | logger.error( | |
|
70 | get_logger().error( | |
|
92 | 71 | "Notebook JSON is invalid (%d errors detected during read)", |
|
93 | 72 | len(errors)) |
|
94 | 73 | return nb_current |
@@ -101,7 +80,7 b' def writes_json(nb, **kwargs):' | |||
|
101 | 80 | """ |
|
102 | 81 | errors = validate(nb) |
|
103 | 82 | if errors: |
|
104 | logger.error( | |
|
83 | get_logger().error( | |
|
105 | 84 | "Notebook JSON is invalid (%d errors detected during write)", |
|
106 | 85 | len(errors)) |
|
107 | 86 | nbjson = versions[current_nbformat].writes_json(nb, **kwargs) |
@@ -3,21 +3,10 b'' | |||
|
3 | 3 | The Pure ZMQ scheduler does not allow routing schemes other than LRU, |
|
4 | 4 | nor does it check msg_id DAG dependencies. For those, a slightly slower |
|
5 | 5 | Python Scheduler exists. |
|
6 | ||
|
7 | Authors: | |
|
8 | ||
|
9 | * Min RK | |
|
10 | 6 | """ |
|
11 | #----------------------------------------------------------------------------- | |
|
12 | # Copyright (C) 2010-2011 The IPython Development Team | |
|
13 | # | |
|
14 | # Distributed under the terms of the BSD License. The full license is in | |
|
15 | # the file COPYING, distributed as part of this software. | |
|
16 | #----------------------------------------------------------------------------- | |
|
17 | 7 | |
|
18 | #---------------------------------------------------------------------- | |
|
19 | # Imports | |
|
20 | #---------------------------------------------------------------------- | |
|
8 | # Copyright (c) IPython Development Team. | |
|
9 | # Distributed under the terms of the Modified BSD License. | |
|
21 | 10 | |
|
22 | 11 | import logging |
|
23 | 12 | import sys |
@@ -27,6 +27,7 b' except:' | |||
|
27 | 27 | import zmq |
|
28 | 28 | from zmq.log import handlers |
|
29 | 29 | |
|
30 | from IPython.utils.log import get_logger | |
|
30 | 31 | from IPython.external.decorator import decorator |
|
31 | 32 | |
|
32 | 33 | from IPython.config.application import Application |
@@ -296,7 +297,7 b' def select_random_ports(n):' | |||
|
296 | 297 | def signal_children(children): |
|
297 | 298 | """Relay interupt/term signals to children, for more solid process cleanup.""" |
|
298 | 299 | def terminate_children(sig, frame): |
|
299 | log = Application.instance().log | |
|
300 | log = get_logger() | |
|
300 | 301 | log.critical("Got signal %i, terminating children..."%sig) |
|
301 | 302 | for child in children: |
|
302 | 303 | child.terminate() |
@@ -20,6 +20,7 b' from .importstring import import_item' | |||
|
20 | 20 | from .py3compat import string_types, iteritems |
|
21 | 21 | |
|
22 | 22 | from IPython.config import Application |
|
23 | from IPython.utils.log import get_logger | |
|
23 | 24 | |
|
24 | 25 | if py3compat.PY3: |
|
25 | 26 | buffer = memoryview |
@@ -276,25 +277,11 b' def CannedBuffer(CannedBytes):' | |||
|
276 | 277 | # Functions |
|
277 | 278 | #------------------------------------------------------------------------------- |
|
278 | 279 | |
|
279 | def _logger(): | |
|
280 | """get the logger for the current Application | |
|
281 | ||
|
282 | the root logger will be used if no Application is running | |
|
283 | """ | |
|
284 | if Application.initialized(): | |
|
285 | logger = Application.instance().log | |
|
286 | else: | |
|
287 | logger = logging.getLogger() | |
|
288 | if not logger.handlers: | |
|
289 | logging.basicConfig() | |
|
290 | ||
|
291 | return logger | |
|
292 | ||
|
293 | 280 | def _import_mapping(mapping, original=None): |
|
294 | 281 | """import any string-keys in a type mapping |
|
295 | 282 | |
|
296 | 283 | """ |
|
297 | log = _logger() | |
|
284 | log = get_logger() | |
|
298 | 285 | log.debug("Importing canning map") |
|
299 | 286 | for key,value in list(mapping.items()): |
|
300 | 287 | if isinstance(key, string_types): |
General Comments 0
You need to be logged in to leave comments.
Login now