show_search_results

    Show search results like rsyslog or as pretty-printed
    JSON dictionaries per log for debugging drill-down fields

    :param log_rec: log record from splunk
    :param code_view: show as a normal tail -f <log file> view
    :param json_view: pretty print each log's dictionary
    :param show_message_details

def show_search_results(
        log_rec,
        code_view=True,
        json_view=False,
        show_message_details=False):
    """show_search_results

    Show search results like rsyslog or as pretty-printed
    JSON dictionaries per log for debugging drill-down fields

    :param log_rec: log record from splunk
    :param code_view: show as a normal tail -f <log file> view
    :param json_view: pretty print each log's dictionary
    :param show_message_details
    """

    log_dict = None
    try:
        log_dict = json.loads(
            log_rec)
    except Exception as e:
        log.error((
            'Failed logging record={} with ex={}').format(
                log_rec,
                e))
        return
    # end of try/ex

    if not log_dict:
        log.error((
            'Failed to parse log_rec={} as a dictionary').format(
                log_rec))
        return

    if code_view:
        comp_name = log_dict.get(
            'name',
            '')
        logger_name = log_dict.get(
            'logger_name',
            '')
        use_log_name = (
            '{}').format(
            logger_name)
        if logger_name:
            use_log_name = '{}'.format(
                logger_name)
        else:
            if comp_name:
                use_log_name = '{}'.format(
                    comp_name)

        prefix_log = (
            '{} {} - {} -').format(
                log_dict.get(
                    'systime',
                    log_dict.get(
                        'asctime',
                        '')),
                use_log_name,
                log_dict.get(
                    'levelname',
                    ''))

        suffix_log = ''
        if log_dict.get(
                'exc',
                ''):
            suffix_log = (
                '{} exc={}').format(
                    suffix_log,
                    log_dict.get(
                        'exc',
                        ''))

        if show_message_details:
            suffix_log = (
                'dc={} env={} '
                'source={} line={}').format(
                    log_dict.get(
                        'dc',
                        ''),
                    log_dict.get(
                        'env',
                        ''),
                    log_dict.get(
                        'path',
                        ''),
                    log_dict.get(
                        'lineno',
                        ''))

        msg = (
            '{} {} {}').format(
                prefix_log,
                log_dict.get(
                    'message',
                    ''),
                suffix_log)

        if log_dict['levelname'] == 'INFO':
            log.info((
                '{}').format(
                    msg))
        elif log_dict['levelname'] == 'DEBUG':
            log.debug((
                '{}').format(
                    msg))
        elif log_dict['levelname'] == 'ERROR':
            log.error((
                '{}').format(
                    msg))
        elif log_dict['levelname'] == 'CRITICAL':
            log.critical((
                '{}').format(
                    msg))
        elif log_dict['levelname'] == 'WARNING':
            log.warning((
                '{}').format(
                    msg))
        else:
            log.debug((
                '{}').format(
                    msg))
    elif json_view:
        if log_dict['levelname'] == 'INFO':
            log.info((
                '{}').format(
                    ppj(log_dict)))
        elif log_dict['levelname'] == 'DEBUG':
            log.debug((
                '{}').format(
                    ppj(log_dict)))
        elif log_dict['levelname'] == 'ERROR':
            log.error((
                '{}').format(
                    ppj(log_dict)))
        elif log_dict['levelname'] == 'CRITICAL':
            log.critical((
                '{}').format(
                    ppj(log_dict)))
        elif log_dict['levelname'] == 'WARNING':
            log.warning((
                '{}').format(
                    ppj(log_dict)))
        else:
            log.debug((
                '{}').format(
                    ppj(log_dict)))
    else:
        log.error((
            'Please use either code_view or json_view to view the logs'))