'Write the given ``string`` to the logfile and terminal.'

def write(self, string):

    if (not self.quiet):
        try:
            if self.stderr:
                sys.__stderr__.write(string)
            else:
                sys.__stdout__.write(string)
        except:
            pass
    with codecs.open(self.logpath, u'ab', encoding=u'utf8', errors=u'xmlcharrefreplace') as logfile:
        try:
            logfile.write(string)
        except UnicodeDecodeError:
            logfile.write(unicode(string, u'utf8', errors=u'replace'))
