Commit cd057e1d authored by Vincent Pelletier's avatar Vincent Pelletier

Save a string concatenation per log line when not required.

parent 3c1a4794
...@@ -678,8 +678,8 @@ DURATION_US_FORMAT = '%D' ...@@ -678,8 +678,8 @@ DURATION_US_FORMAT = '%D'
DURATION_S_FORMAT = '%T' DURATION_S_FORMAT = '%T'
server_name_group_dict = { server_name_group_dict = {
'%v': lambda x: x.group('servername') + '/', '%v': lambda x, path: x.group('servername') + '/' + path,
'%V': lambda x: x.group('canonical_servername') + '/', '%V': lambda x, path: x.group('canonical_servername') + '/' + path,
} }
logformat_dict = { logformat_dict = {
...@@ -1174,7 +1174,7 @@ def main(): ...@@ -1174,7 +1174,7 @@ def main():
parser.error('--match-servername %s requested, but missing ' parser.error('--match-servername %s requested, but missing '
'from logformat.' % args.match_servername) 'from logformat.' % args.match_servername)
get_url_prefix = server_name_group_dict.get(args.match_servername, get_url_prefix = server_name_group_dict.get(args.match_servername,
lambda _: '') lambda _, path: path)
line_regex = '' line_regex = ''
expensive_line_regex = '' expensive_line_regex = ''
try: try:
...@@ -1318,7 +1318,7 @@ def main(): ...@@ -1318,7 +1318,7 @@ def main():
url = url_match.group('url') url = url_match.group('url')
if url.startswith('http'): if url.startswith('http'):
url = splithost(splittype(url)[1])[1] url = splithost(splittype(url)[1])[1]
url = get_url_prefix(match) + url url = get_url_prefix(match, url)
for site, prefix_match, action in site_list: for site, prefix_match, action in site_list:
if prefix_match(url) is not None: if prefix_match(url) is not None:
break break
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment