Open
Description
How to capture the stderr from server, I saw there is a params named: errlog
, its default value is sys.stderr
, that caused any stderr from server side will be print in the console/terminal
I do not like the behavior, at least I want capture the error log from server and print with prefix(maybe "error-received: {original-err}")
but I cannot figure out how to use errlog
param, I write a file-like object, something like this:
class ErrorPrefixTextIO(io.TextIOBase):
def __init__(self, original_stream=None):
self.original_stream = original_stream or sys.stderr
def write(self, message: str) -> int:
if message.strip():
self.original_stream.write(f"error- {message}")
self.original_stream.flush()
return len(message)
def flush(self) -> None:
self.original_stream.flush()
def fileno(self) -> int:
return self.original_stream.fileno()
def close(self) -> None:
if hasattr(self.original_stream, 'close'):
self.original_stream.close()
it's not work, seems the function write
is ignored at all
besides that, I also try to assign a file
object to errlog
, it could work, the file is write with error from server, but I cannot add any prefix to original err message. any help, thanks
Metadata
Metadata
Assignees
Labels
No labels