Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/traitlets/log.py: 30%
10 statements
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-01 06:54 +0000
« prev ^ index » next coverage.py v7.2.7, created at 2023-07-01 06:54 +0000
1"""Grab the global logger instance."""
3# Copyright (c) IPython Development Team.
4# Distributed under the terms of the Modified BSD License.
6import logging
8_logger = None
11def get_logger():
12 """Grab the global logger instance.
14 If a global Application is instantiated, grab its logger.
15 Otherwise, grab the root logger.
16 """
17 global _logger
19 if _logger is None:
20 from .config import Application
22 if Application.initialized():
23 _logger = Application.instance().log
24 else:
25 _logger = logging.getLogger("traitlets")
26 # Add a NullHandler to silence warnings about not being
27 # initialized, per best practice for libraries.
28 _logger.addHandler(logging.NullHandler())
29 return _logger