mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
repo_trace: adjust formatting, update man page.
No behavior change in this CL. Change-Id: Iab1eb01864ea8a5aec3a683200764d20786b42de Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/351474 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Xin Li <delphij@google.com>
This commit is contained in:
parent
b240d28bc0
commit
afd767103e
@ -25,7 +25,7 @@ control color usage: auto, always, never
|
|||||||
\fB\-\-trace\fR
|
\fB\-\-trace\fR
|
||||||
trace git command execution (REPO_TRACE=1)
|
trace git command execution (REPO_TRACE=1)
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-trace-to-stderr\fR
|
\fB\-\-trace\-to\-stderr\fR
|
||||||
trace outputs go to stderr in addition to
|
trace outputs go to stderr in addition to
|
||||||
\&.repo/TRACE_FILE
|
\&.repo/TRACE_FILE
|
||||||
.TP
|
.TP
|
||||||
|
@ -78,14 +78,13 @@ class Trace(ContextDecorator):
|
|||||||
|
|
||||||
if first_trace:
|
if first_trace:
|
||||||
_ClearOldTraces()
|
_ClearOldTraces()
|
||||||
self._trace_msg = '%s %s' % (_NEW_COMMAND_SEP, self._trace_msg)
|
self._trace_msg = f'{_NEW_COMMAND_SEP} {self._trace_msg}'
|
||||||
|
|
||||||
|
|
||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
if not IsTrace():
|
if not IsTrace():
|
||||||
return self
|
return self
|
||||||
|
|
||||||
print_msg = f'PID: {os.getpid()} START: {self._time()} :' + self._trace_msg + '\n'
|
print_msg = f'PID: {os.getpid()} START: {self._time()} :{self._trace_msg}\n'
|
||||||
|
|
||||||
with open(_TRACE_FILE, 'a') as f:
|
with open(_TRACE_FILE, 'a') as f:
|
||||||
print(print_msg, file=f)
|
print(print_msg, file=f)
|
||||||
@ -99,7 +98,7 @@ class Trace(ContextDecorator):
|
|||||||
if not IsTrace():
|
if not IsTrace():
|
||||||
return False
|
return False
|
||||||
|
|
||||||
print_msg = f'PID: {os.getpid()} END: {self._time()} :' + self._trace_msg + '\n'
|
print_msg = f'PID: {os.getpid()} END: {self._time()} :{self._trace_msg}\n'
|
||||||
|
|
||||||
with open(_TRACE_FILE, 'a') as f:
|
with open(_TRACE_FILE, 'a') as f:
|
||||||
print(print_msg, file=f)
|
print(print_msg, file=f)
|
||||||
@ -115,9 +114,10 @@ def _GetTraceFile():
|
|||||||
# TODO: refactor to pass repodir to Trace.
|
# TODO: refactor to pass repodir to Trace.
|
||||||
repo_dir = os.path.dirname(os.path.dirname(__file__))
|
repo_dir = os.path.dirname(os.path.dirname(__file__))
|
||||||
trace_file = os.path.join(repo_dir, _TRACE_FILE_NAME)
|
trace_file = os.path.join(repo_dir, _TRACE_FILE_NAME)
|
||||||
print('Trace outputs in %s' % trace_file, file=sys.stderr)
|
print(f'Trace outputs in {trace_file}', file=sys.stderr)
|
||||||
return trace_file
|
return trace_file
|
||||||
|
|
||||||
|
|
||||||
def _ClearOldTraces():
|
def _ClearOldTraces():
|
||||||
"""Clear the oldest commands if trace file is too big.
|
"""Clear the oldest commands if trace file is too big.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user