diff --git a/git_trace2_event_log_base.py b/git_trace2_event_log_base.py index 2f1aac76..56db7a8f 100644 --- a/git_trace2_event_log_base.py +++ b/git_trace2_event_log_base.py @@ -130,10 +130,10 @@ class BaseEventLog: "time": datetime.datetime.now(datetime.timezone.utc).isoformat(), } - def StartEvent(self): + def StartEvent(self, argv): """Append a 'start' event to the current log.""" start_event = self._CreateEventDict("start") - start_event["argv"] = sys.argv + start_event["argv"] = argv self._log.append(start_event) def ExitEvent(self, result): @@ -159,9 +159,11 @@ class BaseEventLog: 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 = self._CreateEventDict("cmd_name") + name = f"{name}-" + name += "-".join(subcommands) command_event["name"] = name - command_event["subcommands"] = subcommands + command_event["hierarchy"] = name self._log.append(command_event) def LogConfigEvents(self, config, event_dict_name): diff --git a/main.py b/main.py index b00aadbd..9f415e38 100755 --- a/main.py +++ b/main.py @@ -357,7 +357,7 @@ class _Repo: start = time.time() cmd_event = cmd.event_log.Add(name, event_log.TASK_COMMAND, start) cmd.event_log.SetParent(cmd_event) - git_trace2_event_log.StartEvent() + git_trace2_event_log.StartEvent(["repo", name] + argv) git_trace2_event_log.CommandEvent(name="repo", subcommands=[name]) def execute_command_helper(): diff --git a/tests/test_git_trace2_event_log.py b/tests/test_git_trace2_event_log.py index 4658a793..d3214887 100644 --- a/tests/test_git_trace2_event_log.py +++ b/tests/test_git_trace2_event_log.py @@ -150,7 +150,7 @@ class EventLogTestCase(unittest.TestCase): """ - self._event_log_module.StartEvent() + self._event_log_module.StartEvent([]) with tempfile.TemporaryDirectory(prefix="event_log_tests") as tempdir: log_path = self._event_log_module.Write(path=tempdir) self._log_data = self.readLog(log_path) @@ -213,10 +213,8 @@ class EventLogTestCase(unittest.TestCase): """ - name = "repo" - subcommands = ["init" "this"] self._event_log_module.CommandEvent( - name="repo", subcommands=subcommands + name="repo", subcommands=["init", "this"] ) with tempfile.TemporaryDirectory(prefix="event_log_tests") as tempdir: log_path = self._event_log_module.Write(path=tempdir) @@ -225,12 +223,10 @@ class EventLogTestCase(unittest.TestCase): self.assertEqual(len(self._log_data), 2) command_event = self._log_data[1] self.verifyCommonKeys(self._log_data[0], expected_event_name="version") - self.verifyCommonKeys(command_event, expected_event_name="command") + self.verifyCommonKeys(command_event, expected_event_name="cmd_name") # Check for 'command' event specific fields. self.assertIn("name", command_event) - self.assertIn("subcommands", command_event) - self.assertEqual(command_event["name"], name) - self.assertEqual(command_event["subcommands"], subcommands) + self.assertEqual(command_event["name"], "repo-init-this") def test_def_params_event_repo_config(self): """Test 'def_params' event data outputs only repo config keys. @@ -382,17 +378,17 @@ class EventLogTestCase(unittest.TestCase): socket_path = os.path.join(tempdir, "server.sock") server_ready = threading.Condition() # Start "server" listening on Unix domain socket at socket_path. + server_thread = threading.Thread( + target=serverLoggingThread, + args=(socket_path, server_ready, received_traces), + ) try: - server_thread = threading.Thread( - target=serverLoggingThread, - args=(socket_path, server_ready, received_traces), - ) server_thread.start() with server_ready: server_ready.wait(timeout=120) - self._event_log_module.StartEvent() + self._event_log_module.StartEvent([]) path = self._event_log_module.Write( path=f"af_unix:{socket_path}" )