Jason Chang | f19b310 | 2023-09-01 16:07:34 -0700 | [diff] [blame] | 1 | from git_command import GetEventTargetPath |
Mike Frysinger | 6447733 | 2023-08-21 21:20:32 -0400 | [diff] [blame] | 2 | from git_command import RepoSourceVersion |
Jason Chang | f19b310 | 2023-09-01 16:07:34 -0700 | [diff] [blame] | 3 | from git_trace2_event_log_base import BaseEventLog |
Ian Kasprzak | 30bc354 | 2020-12-23 10:08:20 -0800 | [diff] [blame] | 4 | |
| 5 | |
Jason Chang | f19b310 | 2023-09-01 16:07:34 -0700 | [diff] [blame] | 6 | class EventLog(BaseEventLog): |
Gavin Mak | ea2e330 | 2023-03-11 06:46:20 +0000 | [diff] [blame] | 7 | """Event log that records events that occurred during a repo invocation. |
Ian Kasprzak | 30bc354 | 2020-12-23 10:08:20 -0800 | [diff] [blame] | 8 | |
Gavin Mak | ea2e330 | 2023-03-11 06:46:20 +0000 | [diff] [blame] | 9 | Events are written to the log as a consecutive JSON entries, one per line. |
| 10 | Entries follow the git trace2 EVENT format. |
Ian Kasprzak | 30bc354 | 2020-12-23 10:08:20 -0800 | [diff] [blame] | 11 | |
Gavin Mak | ea2e330 | 2023-03-11 06:46:20 +0000 | [diff] [blame] | 12 | 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 Kasprzak | 30bc354 | 2020-12-23 10:08:20 -0800 | [diff] [blame] | 18 | |
Gavin Mak | ea2e330 | 2023-03-11 06:46:20 +0000 | [diff] [blame] | 19 | Valid 'event' names and event specific fields are documented here: |
| 20 | https://git-scm.com/docs/api-trace2#_event_format |
Josh Steadmon | 244c9a7 | 2022-03-08 10:24:43 -0800 | [diff] [blame] | 21 | """ |
| 22 | |
Jason Chang | f19b310 | 2023-09-01 16:07:34 -0700 | [diff] [blame] | 23 | def __init__(self, **kwargs): |
| 24 | super().__init__(repo_source_version=RepoSourceVersion(), **kwargs) |
Josh Steadmon | 244c9a7 | 2022-03-08 10:24:43 -0800 | [diff] [blame] | 25 | |
Jason Chang | f19b310 | 2023-09-01 16:07:34 -0700 | [diff] [blame] | 26 | def Write(self, path=None, **kwargs): |
Gavin Mak | ea2e330 | 2023-03-11 06:46:20 +0000 | [diff] [blame] | 27 | if path is None: |
| 28 | path = self._GetEventTargetPath() |
Jason Chang | f19b310 | 2023-09-01 16:07:34 -0700 | [diff] [blame] | 29 | return super().Write(path=path, **kwargs) |
Gavin Mak | ea2e330 | 2023-03-11 06:46:20 +0000 | [diff] [blame] | 30 | |
Jason Chang | f19b310 | 2023-09-01 16:07:34 -0700 | [diff] [blame] | 31 | def _GetEventTargetPath(self): |
| 32 | return GetEventTargetPath() |