Esempio n. 1
0
    def write_log(self, log_message):
        """write_log

        Write logs to stdout

        :param log_message: message to log
        """
        print('{} tcpsp {}'.format(rnow(), log_message))
Esempio n. 2
0
def force_flush():
    """force_flush"""
    if SPLUNK_DEBUG:
        print('{} -------------------------------'.format(
            rnow()))
        print('{} splunkpub: force_flush - start'.format(
            rnow()))
    worked = True
    for instance in instances:
        try:
            instance.force_flush()
        except Exception as e:
            worked = False
            if SPLUNK_DEBUG:
                print(
                    '{} - force_flush instance={} '
                    '- hit ex={}'.format(
                        rnow(),
                        instance,
                        e))
        # end of try/ex
    if not worked:
        if SPLUNK_DEBUG:
            print('{} Failed flushing queues'.format(
                rnow()))
    if SPLUNK_DEBUG:
        print('{} splunkpub: force_flush - done'.format(
            rnow()))
        print('{} -------------------------------'.format(
            rnow()))
Esempio n. 3
0
def perform_exit():
    """perform_exit

    Handling at-the-exit events
    ---------------------------

    This will cleanup each worker process which
    could be in the middle of a request/sleep/block
    action. This has been tested on python 3 with
    Celery and single processes.

    """
    if SPLUNK_DEBUG:
        print('{} -------------------------------'.format(
            rnow()))
        print('{} splunkpub: atexit.register - start'.format(
            rnow()))
    worked = True
    for instance in instances:
        try:
            if SPLUNK_DEBUG:
                print('{} - shutting down instance={} - start'.format(
                    rnow(),
                    instance))
            instance.shutdown()
            if SPLUNK_DEBUG:
                print('{} - shutting down instance={} - done'.format(
                    rnow(),
                    instance))
        except Exception as e:
            worked = False
            if SPLUNK_DEBUG:
                print(
                    '{} - shutting down instance={} '
                    '- hit ex={} during shutdown'.format(
                        rnow(),
                        instance,
                        e))
        # end of try/ex
    if not worked:
        if SPLUNK_DEBUG:
            print('{} Failed exiting'.format(
                rnow()))
    if SPLUNK_DEBUG:
        print('{} splunkpub: atexit.register - done'.format(
            rnow()))
        print('{} -------------------------------'.format(
            rnow()))
    def debug_log(self, log_message):
        """debug_log

        Write logs that only show up in debug mode.
        To turn on debugging with environment variables
        please set this environment variable:

        ::

            export SPLUNK_DEBUG="1"

        :param log_message: message to log
        """
        if self.debug:
            print('{} mpsplunkpub DEBUG {}'.format(rnow(), log_message))
    def write_log(self, log_message):
        """write_log

        :param log_message: message to log
        """
        print('{} mpsplunkpub {}'.format(rnow(), log_message))