MCPcopy Create free account
hub / github.com/enthought/comtypes / setup_logging

Function setup_logging

comtypes/logutil.py:45–83  ·  view source on GitHub ↗
(*pathnames)

Source from the content-addressed store, hash-verified

43
44@deprecated("Deprecated. See https://github.com/enthought/comtypes/issues/920.")
45def setup_logging(*pathnames):
46 import configparser
47
48 parser = configparser.ConfigParser()
49 parser.optionxform = str # use case sensitive option names!
50
51 parser.read(pathnames)
52
53 DEFAULTS = {
54 "handler": "StreamHandler()",
55 "format": "%(levelname)s:%(name)s:%(message)s",
56 "level": "WARNING",
57 }
58
59 def get(section, option):
60 try:
61 return parser.get(section, option, True)
62 except (configparser.NoOptionError, configparser.NoSectionError):
63 return DEFAULTS[option]
64
65 levelname = get("logging", "level")
66 format = get("logging", "format")
67 handlerclass = get("logging", "handler")
68
69 # convert level name to level value
70 level = getattr(logging, levelname)
71 # create the handler instance
72 handler = eval(handlerclass, vars(logging))
73 formatter = logging.Formatter(format)
74 handler.setFormatter(formatter)
75 logging.root.addHandler(handler)
76 logging.root.setLevel(level)
77
78 try:
79 for name, value in parser.items("logging.levels", True):
80 value = getattr(logging, value)
81 logging.getLogger(name).setLevel(value)
82 except configparser.NoSectionError:
83 pass

Callers

nothing calls this directly

Calls 2

getFunction · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…