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

Function _install_handlers

Lib/logging/config.py:140–176  ·  view source on GitHub ↗

Install and return handlers

(cp, formatters)

Source from the content-addressed store, hash-verified

138
139
140def _install_handlers(cp, formatters):
141 """Install and return handlers"""
142 hlist = cp["handlers"]["keys"]
143 if not len(hlist):
144 return {}
145 hlist = hlist.split(",")
146 hlist = _strip_spaces(hlist)
147 handlers = {}
148 fixups = [] #for inter-handler references
149 for hand in hlist:
150 section = cp["handler_%s" % hand]
151 klass = section["class"]
152 fmt = section.get("formatter", "")
153 try:
154 klass = eval(klass, vars(logging))
155 except (AttributeError, NameError):
156 klass = _resolve(klass)
157 args = section.get("args", '()')
158 args = eval(args, vars(logging))
159 kwargs = section.get("kwargs", '{}')
160 kwargs = eval(kwargs, vars(logging))
161 h = klass(*args, **kwargs)
162 h.name = hand
163 if "level" in section:
164 level = section["level"]
165 h.setLevel(level)
166 if len(fmt):
167 h.setFormatter(formatters[fmt])
168 if issubclass(klass, logging.handlers.MemoryHandler):
169 target = section.get("target", "")
170 if len(target): #the target handler may not be loaded yet, so keep for later...
171 fixups.append((h, target))
172 handlers[hand] = h
173 #now all handlers are loaded, fixup inter-handler references...
174 for h, t in fixups:
175 h.setTarget(handlers[t])
176 return handlers
177
178def _handle_existing_loggers(existing, child_loggers, disable_existing):
179 """

Callers 1

fileConfigFunction · 0.85

Calls 8

_strip_spacesFunction · 0.85
_resolveFunction · 0.85
setFormatterMethod · 0.80
setTargetMethod · 0.80
splitMethod · 0.45
getMethod · 0.45
setLevelMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…