log-search: Support user-agent / client limit.

This commit is contained in:
Alex Vandiver 2024-02-26 14:58:25 +00:00 committed by Tim Abbott
parent 9ca0cd9bbd
commit b7e42ca17a
1 changed files with 10 additions and 0 deletions

View File

@ -103,6 +103,12 @@ def parser() -> argparse.ArgumentParser:
filtering.add_argument(
"--no-other", "-O", help="Exclude paths not explicitly included", action="store_true"
)
filtering.add_argument(
"--client",
"--user-agent",
"-C",
help="Only include requests whose client/user-agent contains this string",
)
output = parser.add_argument_group("Output")
output.add_argument("--full-line", "-F", help="Show full matching line", action="store_true")
@ -332,6 +338,10 @@ def parse_filters(
filter_funcs.append(filter_func)
filter_terms.append(filter_term)
if args.client:
filter_funcs.append(lambda m, t=args.client: t in m["user_agent"])
filter_terms.append(args.client)
# Push back the modified raw strings, so we can use them for fast substring searches
args.filter_terms = filter_terms