diff options
author | Raman Tenneti <rtenneti@google.com> | 2021-09-27 15:15:47 -0700 |
---|---|---|
committer | Raman Tenneti <rtenneti@google.com> | 2021-09-28 18:22:49 +0000 |
commit | bbe883649402d428d1996e1ef0d81e43c7a780a0 (patch) | |
tree | 78692c87e78fc200054a8e9ba6c11c264e1b2a3d /git_trace2_event_log.py | |
parent | 9d96f58f5fcec101c612e61c3e2526ca071d89ea (diff) | |
download | git-repo-bbe883649402d428d1996e1ef0d81e43c7a780a0.tar.gz |
superproject: Log syncstate's parameter as data-json it it is an array.
All the values of syncstate are strings, check the first byte and last
byte to see if it is an array. For syncstate data, there were no false
positives.
Tested:
$ repo_dev sync
Verified event logged for argv is "data-json".
$./run_tests
Bug: [google internal] b/201102002
Change-Id: Id56adb532b80267f08d09147ac663cdd5987ce87
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/319075
Reviewed-by: Mike Frysinger <vapier@google.com>
Tested-by: Raman Tenneti <rtenneti@google.com>
Diffstat (limited to 'git_trace2_event_log.py')
-rw-r--r-- | git_trace2_event_log.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/git_trace2_event_log.py b/git_trace2_event_log.py index 0d4f23f4..0e5e9089 100644 --- a/git_trace2_event_log.py +++ b/git_trace2_event_log.py | |||
@@ -167,9 +167,9 @@ class EventLog(object): | |||
167 | repo_config = {k: v for k, v in config.items() if k.startswith('repo.')} | 167 | repo_config = {k: v for k, v in config.items() if k.startswith('repo.')} |
168 | self.LogConfigEvents(repo_config, 'def_param') | 168 | self.LogConfigEvents(repo_config, 'def_param') |
169 | 169 | ||
170 | def GetDataEventName(self, key): | 170 | def GetDataEventName(self, value): |
171 | """Returns the 'data-json' if the key is argv else returns 'data'.""" | 171 | """Returns 'data-json' if the value is an array else returns 'data'.""" |
172 | return 'data-json' if key.endswith('sys.argv') else 'data' | 172 | return 'data-json' if value[0] == '[' and value[-1] == ']' else 'data' |
173 | 173 | ||
174 | def LogDataConfigEvents(self, config, prefix): | 174 | def LogDataConfigEvents(self, config, prefix): |
175 | """Append a 'data' event for each config key/value in |config| to the current log. | 175 | """Append a 'data' event for each config key/value in |config| to the current log. |
@@ -182,7 +182,7 @@ class EventLog(object): | |||
182 | prefix: Prefix for each key that is logged. | 182 | prefix: Prefix for each key that is logged. |
183 | """ | 183 | """ |
184 | for key, value in config.items(): | 184 | for key, value in config.items(): |
185 | event = self._CreateEventDict(self.GetDataEventName(key)) | 185 | event = self._CreateEventDict(self.GetDataEventName(value)) |
186 | event['key'] = f'{prefix}/{key}' | 186 | event['key'] = f'{prefix}/{key}' |
187 | event['value'] = value | 187 | event['value'] = value |
188 | self._log.append(event) | 188 | self._log.append(event) |