ignore output encoding errors

git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@1883 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
calvin 2004-10-27 18:13:20 +00:00
parent 8cf68dfad4
commit e6412dd549

View file

@ -77,13 +77,17 @@ class Logger (object):
self.fd = sys.stdout
self.close_fd = False
def write (self, s):
def write (self, s, **args):
"""write string to file output"""
if self.fd is None:
raise ValueError("write to non-file")
if not isinstance(s, unicode):
raise ValueError("write non-unicode string %r" % s)
self.fd.write(s.encode(self.output_encoding, "strict"))
self.fd.write(s.encode(self.output_encoding, "ignore"), **args)
def writeln (self, s=u"", **args):
self.write(s)
self.write(unicode(os.linesep), **args)
def has_field (self, name):
"""see if given field name will be logged"""