publish_to_splunk

        Build the ``self.log_payload`` from the queued log messages
        and POST it to the Splunk endpoint

        :param payload: string message to send to Splunk

def publish_to_splunk(
            self,
            payload=None):
        """publish_to_splunk

        Build the ``self.log_payload`` from the queued log messages
        and POST it to the Splunk endpoint

        :param payload: string message to send to Splunk
        """
        self.debug_log('publish_to_splunk - start')

        use_payload = payload
        if not use_payload:
            use_payload = self.log_payload

        self.num_sent = 0

        if use_payload:
            url = 'https://{}:{}/services/collector'.format(
                self.host,
                self.port)
            self.debug_log('splunk url={}'.format(
                url))

            try:
                if self.debug:
                    try:
                        msg_dict = json.loads(use_payload)
                        event_data = json.loads(msg_dict['event'])
                        msg_dict['event'] = event_data
                        self.debug_log((
                            'sending payload: {}').format(
                                ppj(msg_dict)))
                    except Exception:
                        self.debug_log((
                            'sending data payload: {}').format(
                                use_payload))
                if self.num_sent > 100000:
                    self.num_sent = 1
                else:
                    self.num_sent += 1
                send_to_splunk.send_to_splunk(
                    session=self.session,
                    url=url,
                    data=use_payload,
                    headers={'Authorization': 'Splunk {}'.format(
                        self.token)},
                    verify=self.verify,
                    timeout=self.timeout)
                self.debug_log('payload sent success')
            except Exception as e:
                try:
                    self.write_log(
                        'Exception in Splunk logging handler: {}'.format(
                            e))
                    self.write_log(traceback.format_exc())
                except Exception:
                    self.debug_log(
                        'Exception encountered,'
                        'but traceback could not be formatted')

            self.log_payload = ''
        else:
            self.debug_log(
                'no logs to send')

        self.debug_log((
            'publish_to_splunk - done - '
            'self.is_shutting_down={} self.shutdown_now={}').format(
                self.is_shutting_down(shutdown_event=self.shutdown_event),
                self.shutdown_now))