code: def build_into_splunk_tcp_message(
              self,
              body):
          
          # is for an authenticated Splunk TCP Port
          log_msg = None
          if self.token:
              if IS_PY2:
                  log_msg = ('token={}, body={}').format(
                      self.token,
                      body)
              else:
                  log_msg = ('token={}, body={}').format(
                      self.token,
                      body).encode()
          else:
              if IS_PY2:
                  log_msg = ('{}').format(
                      body)
              else:
                  log_msg = body.encode()
          # end of support for building different
          # Splunk socket-ready messages
  
          self.debug_log('build={}'.format(
              log_msg))
  
          return log_msg
docs: build_into_splunk_tcp_message
  
          Format a message for a Splunk JSON sourcetype
  
          :param body: splunk JSON dictionary msg body