def data_to_stdout(data, bold=False): """ Writes text to the stdout (console) stream """ if 'quiet' not in conf or not conf.quiet: message = "" if isinstance(data, str): message = stdout_encode(data) else: message = data sys.stdout.write(set_color(message, bold)) try: sys.stdout.flush() except IOError: pass return
def emit(self, record): try: message = stdout_encode(self.format(record)) message = message.decode() stream = self.stream if not self.is_tty: if message and message[0] == "\r": message = message[1:] stream.write(message) else: self.output_colorized(message) stream.write(getattr(self, 'terminator', '\n')) self.flush() except (KeyboardInterrupt, SystemExit): raise except IOError: pass except: self.handleError(record)