mirror of https://github.com/zulip/zulip.git
log-search: Return the filter terms, rather than changing them.
This leaves `args.filter_terms` as the raw values the user specified, before they may have been transformed to the shape that we use for substring matching.
This commit is contained in:
parent
39a7c5d106
commit
9eaaacba52
|
@ -199,13 +199,13 @@ class FilterFunc(Protocol):
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
args = parser().parse_args()
|
args = parser().parse_args()
|
||||||
|
|
||||||
(filter_types, filter_funcs) = parse_filters(args)
|
(filter_types, filter_funcs, substr_terms) = parse_filters(args)
|
||||||
logfile_names = parse_logfile_names(args)
|
logfile_names = parse_logfile_names(args)
|
||||||
if args.timeline and args.nginx:
|
if args.timeline and args.nginx:
|
||||||
print("! nginx logs not suggested for timeline, due to imprecision", file=sys.stderr)
|
print("! nginx logs not suggested for timeline, due to imprecision", file=sys.stderr)
|
||||||
|
|
||||||
use_color = sys.stdout.isatty()
|
use_color = sys.stdout.isatty()
|
||||||
lowered_terms = [term.lower() for term in args.filter_terms]
|
lowered_terms = [term.lower() for term in substr_terms]
|
||||||
try:
|
try:
|
||||||
for logfile_name in reversed(logfile_names):
|
for logfile_name in reversed(logfile_names):
|
||||||
with maybe_gzip(logfile_name) as logfile:
|
with maybe_gzip(logfile_name) as logfile:
|
||||||
|
@ -289,7 +289,7 @@ def convert_to_nginx_date(date: str) -> str:
|
||||||
|
|
||||||
def parse_filters(
|
def parse_filters(
|
||||||
args: argparse.Namespace,
|
args: argparse.Namespace,
|
||||||
) -> Tuple[Set[FilterType], List[FilterFunc]]:
|
) -> Tuple[Set[FilterType], List[FilterFunc], List[str]]:
|
||||||
# The heuristics below are not intended to be precise -- they
|
# The heuristics below are not intended to be precise -- they
|
||||||
# certainly count things as "IPv4" or "IPv6" addresses that are
|
# certainly count things as "IPv4" or "IPv6" addresses that are
|
||||||
# invalid. However, we expect the input here to already be
|
# invalid. However, we expect the input here to already be
|
||||||
|
@ -371,10 +371,7 @@ def parse_filters(
|
||||||
filter_funcs.append(lambda m, t=args.client: t in m["user_agent"])
|
filter_funcs.append(lambda m, t=args.client: t in m["user_agent"])
|
||||||
filter_terms.append(args.client)
|
filter_terms.append(args.client)
|
||||||
|
|
||||||
# Push back the modified raw strings, so we can use them for fast substring searches
|
return (filter_types, filter_funcs, filter_terms)
|
||||||
args.filter_terms = filter_terms
|
|
||||||
|
|
||||||
return (filter_types, filter_funcs)
|
|
||||||
|
|
||||||
|
|
||||||
def passes_filters(
|
def passes_filters(
|
||||||
|
|
Loading…
Reference in New Issue