mirror of
https://gerrit.googlesource.com/git-repo
synced 2026-11-12 23:37:19 +00:00
Align with Google style guides and `import git_command` as a module rather than import symbols out of it. Change-Id: If80d95203e240dd6591e465ef75500c72401d2bf Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/648503 Commit-Queue: Mike Frysinger <vapier@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Tested-by: Mike Frysinger <vapier@google.com>
50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
# Copyright (C) 2020 The Android Open Source Project
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
"""Event logging in the git trace2 EVENT format."""
|
|
|
|
import git_command
|
|
from git_trace2_event_log_base import BaseEventLog
|
|
|
|
|
|
class EventLog(BaseEventLog):
|
|
"""Event log that records events that occurred during a repo invocation.
|
|
|
|
Events are written to the log as a consecutive JSON entries, one per line.
|
|
Entries follow the git trace2 EVENT format.
|
|
|
|
Each entry contains the following common keys:
|
|
- event: The event name
|
|
- sid: session-id - Unique string to allow process instance to be
|
|
identified.
|
|
- thread: The thread name.
|
|
- time: is the UTC time of the event.
|
|
|
|
Valid 'event' names and event specific fields are documented here:
|
|
https://git-scm.com/docs/api-trace2#_event_format
|
|
"""
|
|
|
|
def __init__(self, **kwargs):
|
|
super().__init__(
|
|
repo_source_version=git_command.RepoSourceVersion(), **kwargs
|
|
)
|
|
|
|
def Write(self, path=None, **kwargs):
|
|
if path is None:
|
|
path = self._GetEventTargetPath()
|
|
return super().Write(path=path, **kwargs)
|
|
|
|
def _GetEventTargetPath(self):
|
|
return git_command.GetEventTargetPath()
|