MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _install_handlers

Function _install_handlers

tools/python-3.11.9-amd64/Lib/logging/config.py:135–171  ·  view source on GitHub ↗

Install and return handlers

(cp, formatters)

Source from the content-addressed store, hash-verified

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

Callers 1

fileConfigFunction · 0.85

Calls 9

_strip_spacesFunction · 0.85
varsFunction · 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