From b355a0a63e65a77a30b84ccc6465797f8a13a876 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Thu, 28 Apr 2022 17:32:35 -0700 Subject: [PATCH] log-search: Default to searching python logfiles. These have more accurate timestamps, and have user information -- but are harder to parse, and will not show requests when Django or Tornado is stopped. --- scripts/log-search | 67 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/scripts/log-search b/scripts/log-search index 5f60b68c56..2e8e04d003 100755 --- a/scripts/log-search +++ b/scripts/log-search @@ -15,7 +15,7 @@ from scripts.lib.zulip_tools import BOLD, CYAN, ENDC, FAIL, GRAY, OKBLUE def parser() -> argparse.ArgumentParser: parser = argparse.ArgumentParser( - description="Search nginx logfiles for an IP or hostname, ignoring commonly-fetched URLs." + description="Search logfiles for an IP or hostname, ignoring commonly-fetched URLs." ) log_selection = parser.add_argument_group("File selection") log_selection_options = log_selection.add_mutually_exclusive_group() @@ -40,6 +40,12 @@ def parser() -> argparse.ArgumentParser: choices=range(0, 24), default=3, ) + log_selection.add_argument( + "--nginx", + "-N", + help="Parse from NGINX logs, not server.log", + action="store_true", + ) filtering = parser.add_argument_group("Filtering") filtering.add_argument("filter", help="IP address or hostname to search for") @@ -103,6 +109,36 @@ NGINX_LOG_LINE_RE = re.compile( re.X, ) +PYTHON_LOG_LINE_RE = re.compile( + r""" + (?P \d+-\d+-\d+ ) \s+ + (?P