MCPcopy Create free account
hub / github.com/ipython/traitlets / get_logger

Function get_logger

traitlets/log.py:13–31  ·  view source on GitHub ↗

Grab the global logger instance. If a global Application is instantiated, grab its logger. Otherwise, grab the root logger.

()

Source from the content-addressed store, hash-verified

11
12
13def get_logger() -> logging.Logger | logging.LoggerAdapter[Any]:
14 """Grab the global logger instance.
15
16 If a global Application is instantiated, grab its logger.
17 Otherwise, grab the root logger.
18 """
19 global _logger # noqa: PLW0603
20
21 if _logger is None:
22 from .config import Application
23
24 if Application.initialized():
25 _logger = Application.instance().log
26 else:
27 _logger = logging.getLogger("traitlets")
28 # Add a NullHandler to silence warnings about not being
29 # initialized, per best practice for libraries.
30 _logger.addHandler(logging.NullHandler())
31 return _logger

Callers 3

test_parent_loggerMethod · 0.90
_log_defaultMethod · 0.90

Calls 2

initializedMethod · 0.80
instanceMethod · 0.80

Tested by 2

test_parent_loggerMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…