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

Method _log

Tools/c-analyzer/distutils/log.py:19–37  ·  view source on GitHub ↗
(self, level, msg, args)

Source from the content-addressed store, hash-verified

17 self.threshold = threshold
18
19 def _log(self, level, msg, args):
20 if level not in (DEBUG, INFO, WARN, ERROR, FATAL):
21 raise ValueError('%s wrong log level' % str(level))
22
23 if level >= self.threshold:
24 if args:
25 msg = msg % args
26 if level in (WARN, ERROR, FATAL):
27 stream = sys.stderr
28 else:
29 stream = sys.stdout
30 try:
31 stream.write('%s\n' % msg)
32 except UnicodeEncodeError:
33 # emulate backslashreplace error handler
34 encoding = stream.encoding
35 msg = msg.encode(encoding, "backslashreplace").decode(encoding)
36 stream.write('%s\n' % msg)
37 stream.flush()
38
39 def log(self, level, msg, *args):
40 self._log(level, msg, args)

Callers 6

logMethod · 0.95
debugMethod · 0.95
infoMethod · 0.95
warnMethod · 0.95
errorMethod · 0.95
fatalMethod · 0.95

Calls 5

strFunction · 0.85
writeMethod · 0.45
decodeMethod · 0.45
encodeMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected