blob: 57edee4d38ceea6d59ff70ecb7cd0234f0c00668 [file] [log] [blame]
Jason Changf19b3102023-09-01 16:07:34 -07001from git_command import GetEventTargetPath
Mike Frysinger64477332023-08-21 21:20:32 -04002from git_command import RepoSourceVersion
Jason Changf19b3102023-09-01 16:07:34 -07003from git_trace2_event_log_base import BaseEventLog
Ian Kasprzak30bc3542020-12-23 10:08:20 -08004
5
Jason Changf19b3102023-09-01 16:07:34 -07006class EventLog(BaseEventLog):
Gavin Makea2e3302023-03-11 06:46:20 +00007 """Event log that records events that occurred during a repo invocation.
Ian Kasprzak30bc3542020-12-23 10:08:20 -08008
Gavin Makea2e3302023-03-11 06:46:20 +00009 Events are written to the log as a consecutive JSON entries, one per line.
10 Entries follow the git trace2 EVENT format.
Ian Kasprzak30bc3542020-12-23 10:08:20 -080011
Gavin Makea2e3302023-03-11 06:46:20 +000012 Each entry contains the following common keys:
13 - event: The event name
14 - sid: session-id - Unique string to allow process instance to be
15 identified.
16 - thread: The thread name.
17 - time: is the UTC time of the event.
Ian Kasprzak30bc3542020-12-23 10:08:20 -080018
Gavin Makea2e3302023-03-11 06:46:20 +000019 Valid 'event' names and event specific fields are documented here:
20 https://git-scm.com/docs/api-trace2#_event_format
Josh Steadmon244c9a72022-03-08 10:24:43 -080021 """
22
Jason Changf19b3102023-09-01 16:07:34 -070023 def __init__(self, **kwargs):
24 super().__init__(repo_source_version=RepoSourceVersion(), **kwargs)
Josh Steadmon244c9a72022-03-08 10:24:43 -080025
Jason Changf19b3102023-09-01 16:07:34 -070026 def Write(self, path=None, **kwargs):
Gavin Makea2e3302023-03-11 06:46:20 +000027 if path is None:
28 path = self._GetEventTargetPath()
Jason Changf19b3102023-09-01 16:07:34 -070029 return super().Write(path=path, **kwargs)
Gavin Makea2e3302023-03-11 06:46:20 +000030
Jason Changf19b3102023-09-01 16:07:34 -070031 def _GetEventTargetPath(self):
32 return GetEventTargetPath()