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

1"""Grab the global logger instance.""" 

2 

3# Copyright (c) IPython Development Team. 

4# Distributed under the terms of the Modified BSD License. 

5 

6import logging 

7 

8_logger = None 

9 

10 

11def get_logger(): 

12 """Grab the global logger instance. 

13 

14 If a global Application is instantiated, grab its logger. 

15 Otherwise, grab the root logger. 

16 """ 

17 global _logger 

18 

19 if _logger is None: 

20 from .config import Application 

21 

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