MCPcopy Index your code
hub / github.com/python/cpython / Manager

Class Manager

Lib/logging/__init__.py:1341–1460  ·  view source on GitHub ↗

There is [under normal circumstances] just one Manager instance, which holds the hierarchy of loggers.

Source from the content-addressed store, hash-verified

1339 return _loggerClass
1340
1341class Manager(object):
1342 """
1343 There is [under normal circumstances] just one Manager instance, which
1344 holds the hierarchy of loggers.
1345 """
1346 def __init__(self, rootnode):
1347 """
1348 Initialize the manager with the root node of the logger hierarchy.
1349 """
1350 self.root = rootnode
1351 self.disable = 0
1352 self.emittedNoHandlerWarning = False
1353 self.loggerDict = {}
1354 self.loggerClass = None
1355 self.logRecordFactory = None
1356
1357 @property
1358 def disable(self):
1359 return self._disable
1360
1361 @disable.setter
1362 def disable(self, value):
1363 self._disable = _checkLevel(value)
1364
1365 def getLogger(self, name):
1366 """
1367 Get a logger with the specified name (channel name), creating it
1368 if it doesn't yet exist. This name is a dot-separated hierarchical
1369 name, such as "a", "a.b", "a.b.c" or similar.
1370
1371 If a PlaceHolder existed for the specified name [i.e. the logger
1372 didn't exist but a child of it did], replace it with the created
1373 logger and fix up the parent/child references which pointed to the
1374 placeholder to now point to the logger.
1375 """
1376 rv = None
1377 if not isinstance(name, str):
1378 raise TypeError('A logger name must be a string')
1379 with _lock:
1380 if name in self.loggerDict:
1381 rv = self.loggerDict[name]
1382 if isinstance(rv, PlaceHolder):
1383 ph = rv
1384 rv = (self.loggerClass or _loggerClass)(name)
1385 rv.manager = self
1386 self.loggerDict[name] = rv
1387 self._fixupChildren(ph, rv)
1388 self._fixupParents(rv)
1389 else:
1390 rv = (self.loggerClass or _loggerClass)(name)
1391 rv.manager = self
1392 self.loggerDict[name] = rv
1393 self._fixupParents(rv)
1394 return rv
1395
1396 def setLoggerClass(self, klass):
1397 """
1398 Set the class to be used when instantiating a logger with this Manager.

Callers 1

__init__.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…