def ttylog_write(logfile, length, direction, stamp, data=None):
 with open(logfile, 'ab') as f:
  (sec, usec) = (int(stamp), int((1000000 * (stamp - int(stamp)))))
  f.write(struct.pack('<iLiiLL', 3, 0, length, direction, sec, usec))
  f.write(data)

def ttylog_write ( logfile , length , direction , stamp , data = None ) : with open ( logfile , 'ab' ) as f : ( sec , usec ) = ( int ( stamp ) , int ( ( 1000000 * ( stamp - int ( stamp ) ) ) ) ) f . write ( struct . pack ( '<iLiiLL' , 3 , 0 , length , direction , sec , usec ) ) f . write ( data )
write to tty log .