From a5b40a28450c965bb4b77656820fdd0a78768fe4 Mon Sep 17 00:00:00 2001 From: Raman Tenneti Date: Tue, 16 Mar 2021 14:24:14 -0700 Subject: repo: Add a new "command" event type to git trace2 logging in repo. Add a new "event": "command", which is emitted at when all command arguments have been processed. Additional fields: "name": Name of the primary command (ex: repo, git) "subcommands"': List of the sub-commands once command-line arguments are processed Examples: Command: repo --version Event: {"event": "command", , "name": "repo", "subcommands": ["version"] } Bug: [google internal] b/178507266 Testing: - Unit tests - Verified repo git trace2 logs had expected data Change-Id: I825bd0ecedee45135382461a4ba10f987f09aef3 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/300343 Reviewed-by: Ian Kasprzak Reviewed-by: Mike Frysinger Tested-by: Raman Tenneti --- git_trace2_event_log.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'git_trace2_event_log.py') diff --git a/git_trace2_event_log.py b/git_trace2_event_log.py index 8c33d80b..8f12d1a9 100644 --- a/git_trace2_event_log.py +++ b/git_trace2_event_log.py @@ -132,6 +132,18 @@ class EventLog(object): exit_event['code'] = result self._log.append(exit_event) + def CommandEvent(self, name, subcommands): + """Append a 'command' event to the current log. + + Args: + name: Name of the primary command (ex: repo, git) + subcommands: List of the sub-commands (ex: version, init, sync) + """ + command_event = self._CreateEventDict('command') + command_event['name'] = name + command_event['subcommands'] = subcommands + self._log.append(command_event) + def DefParamRepoEvents(self, config): """Append a 'def_param' event for each repo.* config key to the current log. -- cgit v1.2.3-54-g00ecf