docs: def record(file_path, topic_names=[], host=jps.env.get_master_host(), sub_port=jps.DEFAULT_SUB_PORT):
      '''record the topic data to the file
      '''
      class TopicRecorder(object):
  
          def __init__(self, file_path, topic_names):
              self._topic_names = topic_names
              self._file_path = file_path
              self._output = open(self._file_path, 'w')
              signal.signal(signal.SIGINT, self._handle_signal)
              signal.signal(signal.SIGTERM, self._handle_signal)
              header = {}
              header['topic_names'] = topic_names
              header['start_date'] = str(datetime.datetime.today())
              header_string = json.dumps({'header': header})
              tail_removed_header = header_string[0:-1]
              self._output.write(tail_removed_header + ',\n')
              self._output.write(' "data": [\n')
              self._has_no_data = True
  
          def callback(self, msg, topic):
              if self._output.closed:
                  return
              raw_msg = '{topic} {msg}'.format(topic=topic, msg=msg)
              if not self._topic_names or topic in self._topic_names:
                  if not self._has_no_data:
                      self._output.write(',\n')
                  else:
                      self._has_no_data = False
                  self._output.write(json.dumps([time.time(), raw_msg]))
  
          def close(self):
              if not self._output.closed:
                  self._output.write('\n]}')
                  self._output.close()
  
          def _handle_signal(self, signum, frame):
              self.close()
              sys.exit(0)
  
      writer = TopicRecorder(file_path, topic_names)
      sub = jps.Subscriber('*', writer.callback, host=host, sub_port=sub_port)
      sub.spin()
      writer.close()