There is [under normal circumstances] just one Manager instance, which holds the hierarchy of loggers.
| 1301 | return _loggerClass |
| 1302 | |
| 1303 | class Manager(object): |
| 1304 | """ |
| 1305 | There is [under normal circumstances] just one Manager instance, which |
| 1306 | holds the hierarchy of loggers. |
| 1307 | """ |
| 1308 | def __init__(self, rootnode): |
| 1309 | """ |
| 1310 | Initialize the manager with the root node of the logger hierarchy. |
| 1311 | """ |
| 1312 | self.root = rootnode |
| 1313 | self.disable = 0 |
| 1314 | self.emittedNoHandlerWarning = False |
| 1315 | self.loggerDict = {} |
| 1316 | self.loggerClass = None |
| 1317 | self.logRecordFactory = None |
| 1318 | |
| 1319 | @property |
| 1320 | def disable(self): |
| 1321 | return self._disable |
| 1322 | |
| 1323 | @disable.setter |
| 1324 | def disable(self, value): |
| 1325 | self._disable = _checkLevel(value) |
| 1326 | |
| 1327 | def getLogger(self, name): |
| 1328 | """ |
| 1329 | Get a logger with the specified name (channel name), creating it |
| 1330 | if it doesn't yet exist. This name is a dot-separated hierarchical |
| 1331 | name, such as "a", "a.b", "a.b.c" or similar. |
| 1332 | |
| 1333 | If a PlaceHolder existed for the specified name [i.e. the logger |
| 1334 | didn't exist but a child of it did], replace it with the created |
| 1335 | logger and fix up the parent/child references which pointed to the |
| 1336 | placeholder to now point to the logger. |
| 1337 | """ |
| 1338 | rv = None |
| 1339 | if not isinstance(name, str): |
| 1340 | raise TypeError('A logger name must be a string') |
| 1341 | _acquireLock() |
| 1342 | try: |
| 1343 | if name in self.loggerDict: |
| 1344 | rv = self.loggerDict[name] |
| 1345 | if isinstance(rv, PlaceHolder): |
| 1346 | ph = rv |
| 1347 | rv = (self.loggerClass or _loggerClass)(name) |
| 1348 | rv.manager = self |
| 1349 | self.loggerDict[name] = rv |
| 1350 | self._fixupChildren(ph, rv) |
| 1351 | self._fixupParents(rv) |
| 1352 | else: |
| 1353 | rv = (self.loggerClass or _loggerClass)(name) |
| 1354 | rv.manager = self |
| 1355 | self.loggerDict[name] = rv |
| 1356 | self._fixupParents(rv) |
| 1357 | finally: |
| 1358 | _releaseLock() |
| 1359 | return rv |
| 1360 |