From b8a7b4a629c3435d77a3266a4e6dce51dc342bd9 Mon Sep 17 00:00:00 2001 From: Jason Chang Date: Thu, 3 Aug 2023 16:18:02 -0700 Subject: [PATCH] Prefix error events with RepoErrorEvent: Prior to this change there is no way to distinguish between git sessions logs generated from repo source v.s. from git. Bug: b/294446468 Change-Id: I309f59e146c30cb08a0637e8d0b9c5d9efd5cada Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/381794 Commit-Queue: Jason Chang Reviewed-by: Joanna Wang Tested-by: Jason Chang --- git_trace2_event_log.py | 4 ++-- tests/test_git_trace2_event_log.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/git_trace2_event_log.py b/git_trace2_event_log.py index 46bd5e4b..5b99867b 100644 --- a/git_trace2_event_log.py +++ b/git_trace2_event_log.py @@ -203,8 +203,8 @@ class EventLog(object): error_event = self._CreateEventDict("error") if fmt is None: fmt = msg - error_event["msg"] = msg - error_event["fmt"] = fmt + error_event["msg"] = f"RepoErrorEvent:{msg}" + error_event["fmt"] = f"RepoErrorEvent:{fmt}" self._log.append(error_event) def _GetEventTargetPath(self): diff --git a/tests/test_git_trace2_event_log.py b/tests/test_git_trace2_event_log.py index a6078d38..9d4f24c3 100644 --- a/tests/test_git_trace2_event_log.py +++ b/tests/test_git_trace2_event_log.py @@ -338,8 +338,8 @@ class EventLogTestCase(unittest.TestCase): # Check for 'error' event specific fields. self.assertIn("msg", error_event) self.assertIn("fmt", error_event) - self.assertEqual(error_event["msg"], msg) - self.assertEqual(error_event["fmt"], fmt) + self.assertEqual(error_event["msg"], f"RepoErrorEvent:{msg}") + self.assertEqual(error_event["fmt"], f"RepoErrorEvent:{fmt}") def test_write_with_filename(self): """Test Write() with a path to a file exits with None."""