'Display a message to the user
Note: msg *must* be a unicode string to prevent UnicodeError tracebacks.'

def display(self, msg, color=None, stderr=False, screen_only=False, log_only=False):

    nocolor = msg
    if color:
        msg = stringc(msg, color)
    if (not log_only):
        if (not msg.endswith(u'\n')):
            msg2 = (msg + u'\n')
        else:
            msg2 = msg
        msg2 = to_bytes(msg2, encoding=self._output_encoding(stderr=stderr))
        if (sys.version_info >= (3,)):
            msg2 = to_text(msg2, self._output_encoding(stderr=stderr), errors='replace')
        if (not stderr):
            fileobj = sys.stdout
        else:
            fileobj = sys.stderr
        fileobj.write(msg2)
        try:
            fileobj.flush()
        except IOError as e:
            if (e.errno != errno.EPIPE):
                raise
    if (logger and (not screen_only)):
        msg2 = nocolor.lstrip(u'\n')
        msg2 = to_bytes(msg2)
        if (sys.version_info >= (3,)):
            msg2 = to_text(msg2, self._output_encoding(stderr=stderr))
        if (color == C.COLOR_ERROR):
            logger.error(msg2)
        else:
            logger.info(msg2)
