def build_pattern(log_format):
 if (log_format == 'combined'):
  log_format = LOG_FORMAT_COMBINED
 elif (log_format == 'common'):
  log_format = LOG_FORMAT_COMMON
 pattern = re.sub(REGEX_SPECIAL_CHARS, '\\\\\\1', log_format)
 pattern = re.sub(REGEX_LOG_FORMAT_VARIABLE, '(?P<\\1>.*)', pattern)
 return re.compile(pattern)

def build_pattern ( log_format ) : if ( log_format == 'combined' ) : log_format = LOG_FORMAT_COMBINED elif ( log_format == 'common' ) : log_format = LOG_FORMAT_COMMON pattern = re . sub ( REGEX_SPECIAL_CHARS , '\\\\\\1' , log_format ) pattern = re . sub ( REGEX_LOG_FORMAT_VARIABLE , '(?P<\\1>.*)' , pattern ) return re . compile ( pattern )
build regular expression to parse given format .