From 8043287a8f62ba022b147c037494a3dda641805b 2014-03-18 20:28:15 From: MinRK Date: 2014-03-18 20:28:15 Subject: [PATCH] don't instantiate Application just for default logger It's unlikely to happen in IPython itself, but can happen if config loaders are used elsewhere. --- diff --git a/IPython/config/configurable.py b/IPython/config/configurable.py index c9d3440..cd661d7 100644 --- a/IPython/config/configurable.py +++ b/IPython/config/configurable.py @@ -26,6 +26,7 @@ from __future__ import print_function # Imports #----------------------------------------------------------------------------- +import logging from copy import deepcopy from .loader import Config, LazyConfigValue @@ -381,6 +382,9 @@ class LoggingConfigurable(Configurable): log = Instance('logging.Logger') def _log_default(self): from IPython.config.application import Application - return Application.instance().log + if Application.initialized(): + return Application.instance().log + else: + return logging.getLogger() diff --git a/IPython/config/loader.py b/IPython/config/loader.py index fc22aab..1051cde 100644 --- a/IPython/config/loader.py +++ b/IPython/config/loader.py @@ -25,6 +25,7 @@ Authors import argparse import copy +import logging import os import re import sys @@ -308,7 +309,10 @@ class ConfigLoader(object): def _log_default(self): from IPython.config.application import Application - return Application.instance().log + if Application.initialized(): + return Application.instance().log + else: + return logging.getLogger() def __init__(self, log=None): """A base class for config loaders.