Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stream sink should not be wrapped by colorama on Windows if not stdout / stderr #249

Closed
Delgan opened this issue Apr 18, 2020 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@Delgan
Copy link
Owner

Delgan commented Apr 18, 2020

Considering a class with isatty() returning True, Loguru's should_wrap() function will return True on Windows, resulting in AttributeError: 'CustomSink' object has no attribute 'flush' when colorama will write to the sink.

class CustomSink:

    def isatty(self):
        return True

    def write(self, message):
        pass

logger.add(CustomSink(), colorize=True) 
logger.info("Boom")

The stream should only be wrapped if equals to sys.__stdout__ or sys.__stderr__. If for some reason another stream needs to be wrapped, user should wrap it himself (in practice, this is probably never needed).

@Delgan Delgan added the bug Something isn't working label Apr 18, 2020
@Delgan Delgan closed this as completed Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant