code: def log_text(text):
          
          if text.endswith('\n'):
              text = text[:-len('\n')]
          #text  = text.replace('\n', '\n\t\t')           # text CSV
          ltime = time.strftime("%X")
          msecs = (time.time() % 1) * 1000
          return '[%s.%04d] %s' % (ltime, msecs, text)
docs: Log lines of text, inserting a timestamp.
  
          @type  text: str
          @param text: Text to log.
  
          @rtype:  str
          @return: Log line.