repo_trace: drop notification of trace file name.
The trace file is local to the workspace. We shouldn't tell the user
that on every command that they run.
Change-Id: I8674ab485bd5142814a043a225bf8aaca7795752
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/351234
Tested-by: LaMont Jones <lamontjones@google.com>
Reviewed-by: Xin Li <delphij@google.com>
diff --git a/repo_trace.py b/repo_trace.py
index fcd8650..d79408d 100644
--- a/repo_trace.py
+++ b/repo_trace.py
@@ -57,9 +57,9 @@
_TRACE = True
-def _SetTraceFile():
+def _SetTraceFile(quiet):
global _TRACE_FILE
- _TRACE_FILE = _GetTraceFile()
+ _TRACE_FILE = _GetTraceFile(quiet)
class Trace(ContextDecorator):
@@ -68,13 +68,21 @@
"""Generate nanoseconds of time in a py3.6 safe way"""
return int(time.time() * 1e+9)
- def __init__(self, fmt, *args, first_trace=False):
+ def __init__(self, fmt, *args, first_trace=False, quiet=True):
+ """Initialize the object.
+
+ Args:
+ fmt: The format string for the trace.
+ *args: Arguments to pass to formatting.
+ first_trace: Whether this is the first trace of a `repo` invocation.
+ quiet: Whether to suppress notification of trace file location.
+ """
if not IsTrace():
return
self._trace_msg = fmt % args
if not _TRACE_FILE:
- _SetTraceFile()
+ _SetTraceFile(quiet)
if first_trace:
_ClearOldTraces()
@@ -109,12 +117,13 @@
return False
-def _GetTraceFile():
+def _GetTraceFile(quiet):
"""Get the trace file or create one."""
# TODO: refactor to pass repodir to Trace.
repo_dir = os.path.dirname(os.path.dirname(__file__))
trace_file = os.path.join(repo_dir, _TRACE_FILE_NAME)
- print(f'Trace outputs in {trace_file}', file=sys.stderr)
+ if not quiet:
+ print(f'Trace outputs in {trace_file}', file=sys.stderr)
return trace_file