INNER CODE UNIT · Python

extract_variables

lebinh/ngxtop · ngxtop/config_parser.py:143

def extract_variables(log_format):
    """
    Extract all variables from a log format string.
    :param log_format: format string to extract
    :return: iterator over all variables in given format string
    """
    if log_format == 'combined':
        log_format = LOG_FORMAT_COMBINED
    elif log_format == 'common':
        log_format = LOG_FORMAT_COMMON
    elif log_format == 'caddy':
        # Define the fields available in Caddy logs
        for field in ['remote_addr', 'remote_user', 'time_local', 'request', 
                     'status', 'body_bytes_sent', 'http_referer', 'http_user_agent',
                     'request_time', 'request_uri', 'request_path', 'host']:
            yield field
        return
    for match in re.findall(REGEX_LOG_FORMAT_VARIABLE, log_format):

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…