Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

stdio_client init with errlog #645

Copy link
Copy link
Open
@vincent-pli

Description

@vincent-pli
Issue body actions

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.