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 <jasonnc@google.com>
Reviewed-by: Joanna Wang <jojwang@google.com>
Tested-by: Jason Chang <jasonnc@google.com>
This commit is contained in:
Jason Chang 2023-08-03 16:18:02 -07:00 committed by LUCI
parent 32b59565b7
commit b8a7b4a629
2 changed files with 4 additions and 4 deletions

View File

@ -203,8 +203,8 @@ class EventLog(object):
error_event = self._CreateEventDict("error") error_event = self._CreateEventDict("error")
if fmt is None: if fmt is None:
fmt = msg fmt = msg
error_event["msg"] = msg error_event["msg"] = f"RepoErrorEvent:{msg}"
error_event["fmt"] = fmt error_event["fmt"] = f"RepoErrorEvent:{fmt}"
self._log.append(error_event) self._log.append(error_event)
def _GetEventTargetPath(self): def _GetEventTargetPath(self):

View File

@ -338,8 +338,8 @@ class EventLogTestCase(unittest.TestCase):
# Check for 'error' event specific fields. # Check for 'error' event specific fields.
self.assertIn("msg", error_event) self.assertIn("msg", error_event)
self.assertIn("fmt", error_event) self.assertIn("fmt", error_event)
self.assertEqual(error_event["msg"], msg) self.assertEqual(error_event["msg"], f"RepoErrorEvent:{msg}")
self.assertEqual(error_event["fmt"], fmt) self.assertEqual(error_event["fmt"], f"RepoErrorEvent:{fmt}")
def test_write_with_filename(self): def test_write_with_filename(self):
"""Test Write() with a path to a file exits with None.""" """Test Write() with a path to a file exits with None."""