'Write data to the log file, if active'

def log_write(self, data, kind='input'):

    if (self.log_active and data):
        write = self.logfile.write
        if (kind == 'input'):
            if self.timestamp:
                write(time.strftime('#    %a,    %d    %b    %Y    %H:%M:%S\n', time.localtime()))
            write(data)
        elif ((kind == 'output') and self.log_output):
            odata = u'\n'.join([(u'#[Out]#    %s' % s) for s in data.splitlines()])
            write((u'%s\n' % odata))
        self.logfile.flush()
