def __init__(self, providers):
        self.providers = providers

        # If there's an application singleton, pass its configurables to the provider.  If
        # no application, still give provider a chance to handle configuration loading.
        config = None
        if Application.initialized():
            config = Application.instance().config

        for provider in providers:
            provider.load_config(config=config)
def app_or_module_logger(module_name):
    """
    If a global Application is instantiated, grab its logger.
    Otherwise, get a logger for the module name.
    """
    from traitlets.config import Application
    if Application.initialized():
        return Application.instance().log
    else:
        _logger = logging.getLogger(module_name)
        # Add a NullHandler to silence warnings about not being
        # initialized, per best practice for libraries.
        _logger.addHandler(logging.NullHandler())
        return _logger
Exemple #3
0
    def _default_log(self):
        if self.parent and self.parent is IPython.get_ipython():
            # log to stdout in an IPython session
            log = logging.getLogger(f"{__name__}.{self.cluster_id}")
            log.setLevel(self.log_level)

            handler = logging.StreamHandler(sys.stdout)
            log.handlers = [handler]
            return log
        elif self.parent and getattr(self.parent, 'log', None) is not None:
            return self.parent.log
        elif Application.initialized():
            return Application.instance().log
        else:
            # set up our own logger
            log = logging.getLogger(f"{__name__}.{self.cluster_id}")
            log.setLevel(self.log_level)
            return log
Exemple #4
0
 def log(self):
     """use the IPython log by default, falling back on tornado's logger"""
     if Application.initialized():
         return Application.instance().log
     else:
         return app_log
Exemple #5
0
def log():
    if Application.initialized():
        return Application.instance().log
    else:
        return app_log
Exemple #6
0
def log():
    if Application.initialized():
        return Application.instance().log
    else:
        return app_log
Exemple #7
0
 def log(self):
     """use the IPython log by default, falling back on tornado's logger"""
     if Application.initialized():
         return Application.instance().log
     else:
         return app_log