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

Class SystemLog

Lib/_apple_support.py:13–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11
12
13class SystemLog(io.TextIOWrapper):
14 def __init__(self, log_write, level, **kwargs):
15 kwargs.setdefault("encoding", "UTF-8")
16 kwargs.setdefault("line_buffering", True)
17 super().__init__(LogStream(log_write, level), **kwargs)
18
19 def __repr__(self):
20 return f"<SystemLog (level {self.buffer.level})>"
21
22 def write(self, s):
23 if not isinstance(s, str):
24 raise TypeError(
25 f"write() argument must be str, not {type(s).__name__}")
26
27 # In case `s` is a str subclass that writes itself to stdout or stderr
28 # when we call its methods, convert it to an actual str.
29 s = str.__str__(s)
30
31 # We want to emit one log message per line, so split
32 # the string before sending it to the superclass.
33 for line in s.splitlines(keepends=True):
34 super().write(line)
35
36 return len(s)
37
38
39class LogStream(io.RawIOBase):

Callers 2

setUpMethod · 0.90
init_streamsFunction · 0.85

Calls

no outgoing calls

Tested by 1

setUpMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…