# Buggy code
def open_logfile_local(self, rpath):
    """Open logfile locally - should only be run on one connection"""
    assert rpath.conn is Globals.local_connection
    try:
        self.logfp = rpath.open("a")
    except (OSError, IOError) as e:
        raise LoggerError("Unable to open logfile %s: %s" % (rpath.path, e))
    self.log_file_local = 1
    self.logrp = rpath


# Traceback (UnicodeEncodeError)
2020-05-11 21:04:14.547611 +0000  <CLIENT-286>  Using rdiff-backup version 2.0.1rc0
2020-05-11 21:04:14.547685 +0000  <CLIENT-286>  	with cpython /usr/bin/python3 version 3.6.8
2020-05-11 21:04:14.550694 +0000  <CLIENT-286>  	on Linux-4.19.37-x86_64-with-centos-7.8.2003-Core, fs encoding ascii
2020-05-11 21:04:14.552330 +0000  <CLIENT-286>  Using mirror root directory /testcases
2020-05-11 21:04:14.552817 +0000  <CLIENT-286>  Unable to import win32security module. Windows ACLs
not supported by filesystem at /testcases/rdiff-backup-data
2020-05-11 21:04:14.553562 +0000  <CLIENT-286>  -----------------------------------------------------------------
Detected abilities for rdiff-backup repository (read only) file system:
Access control lists                         On
Extended attributes                          On
Windows access control lists                 Off
Case sensitivity                             On
Escape DOS devices                           Off
Escape trailing spaces                       Off
Mac OS X style resource forks                Off
Mac OS X Finder information                  Off
-----------------------------------------------------------------
2020-05-11 21:04:14.553638 +0000  <CLIENT-286>  Making directory /tmp/coucou/rdiff-backup.tmp.0
2020-05-11 21:04:14.553802 +0000  <CLIENT-286>  Touching /tmp/coucou/rdiff-backup.tmp.0/5-_ a.snapshot.gz
2020-05-11 21:04:14.553948 +0000  <CLIENT-286>  Deleting /tmp/coucou/rdiff-backup.tmp.0/5-_ a.snapshot.gz
2020-05-11 21:04:14.554872 +0000  <CLIENT-286>  Exception ''ascii' codec can't encode characters in position 91-93: ordinal not in range(128)' raised of class '<class 'UnicodeEncodeError'>':
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 393, in error_check_Main
Main(arglist)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 415, in Main
take_action(rps)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 371, in take_action
Restore(rps[0], rps[1], 1)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 697, in Restore
dest_rp.conn.fs_abilities.restore_set_globals(dest_rp)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/fs_abilities.py", line 1072, in restore_set_globals
dest_fsa = FSAbilities('restore target').init_readwrite(rpout)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/fs_abilities.py", line 157, in init_readwrite
self.set_extended_filenames(subdir)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/fs_abilities.py", line 241, in set_extended_filenames
ext_rp.touch()
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/rpath.py", line 1248, in touch
log.Log("Touching %s" % self.get_safepath(), 7)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/log.py", line 150, in __call__
self.log_to_term(message, verbosity)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/log.py", line 173, in log_to_term
termfp.write(tmpstr)

Traceback (most recent call last):
File "/usr/local/bin/rdiff-backup", line 32, in <module>
rdiff_backup.Main.error_check_Main(sys.argv[1:])
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 393, in error_check_Main
Main(arglist)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 415, in Main
take_action(rps)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 371, in take_action
Restore(rps[0], rps[1], 1)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/Main.py", line 697, in Restore
dest_rp.conn.fs_abilities.restore_set_globals(dest_rp)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/fs_abilities.py", line 1072, in restore_set_globals
dest_fsa = FSAbilities('restore target').init_readwrite(rpout)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/fs_abilities.py", line 157, in init_readwrite
self.set_extended_filenames(subdir)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/fs_abilities.py", line 241, in set_extended_filenames
ext_rp.touch()
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/rpath.py", line 1248, in touch
log.Log("Touching %s" % self.get_safepath(), 7)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/log.py", line 150, in __call__
self.log_to_term(message, verbosity)
File "/usr/local/lib64/python3.6/site-packages/rdiff_backup/log.py", line 173, in log_to_term
termfp.write(tmpstr)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 91-93: ordinal not in range(128)

# Fixed code
def open_logfile_local(self, rpath):
    """Open logfile locally - should only be run on one connection"""
    assert rpath.conn is Globals.local_connection
    try:
        self.logfp = rpath.open("ab")
    except (OSError, IOError) as e:
        raise LoggerError("Unable to open logfile %s: %s" % (rpath.path, e))
    self.log_file_local = 1
    self.logrp = rpath