class LoggerWriter:

    def __init__(self, logger, level):
        self.logger = logger
self.level = level

def write(self, message):
    if message != '\n':
        self.logger.log(self.level, message)
how to redirect stdout and stderr to logger in py