rage: limit x2pagent log size on Windows

Summary:
Use the _tail() function which can limit size and has some other smarts.

Also, tweak some progress spinner messages to show up better. "collecting information" was too long and you only saw "collecting". The sub-section spinners "collecting {something}" were also too long and you also only saw "collecting".

Reviewed By: quark-zju

Differential Revision: D33830014

fbshipit-source-id: cb3693c7cb52ac2d060a2da400c9f21ba03f9048
This commit is contained in:
Muir Manders 2022-01-27 16:08:53 -08:00 committed by Facebook GitHub Bot
parent b351568962
commit 847a1651f0

View File

@ -278,16 +278,18 @@ def checkproxyagentstate(ui):
logs = "OS not supported"
if pycompat.iswindows:
username = util.getuser()
logs = shcmd(
"type C:\\Users\\{}\\AppData\\Local\\facebook\\fb-x2pagentd\\fb-x2pagentd.log".format(
username
)
logs = _tail(
"C:\\Users\\{}\\AppData\\Local\\facebook\\fb-x2pagentd".format(username),
["fb-x2pagentd.log"],
nlines=100,
)
elif pycompat.islinux:
logs = shcmd("journalctl --user-unit x2pagentd.service | tail -n 100")
elif pycompat.isdarwin:
logs = shcmd(
"cat ~/Library/Application\\ Support/fb-x2pagentd/fb-x2pagentd.log | tail -n 100"
logs = _tail(
os.path.expanduser("~/Library/Application Support/fb-x2pagentd"),
["fb-x2pagentd.log"],
nlines=100,
)
return """{}
@ -555,7 +557,7 @@ def _makerage(ui, repo, **opts):
profile.append((time.time() - allstart, "basic info", None))
for name, gen in detailed:
start = time.time()
with progress.spinner(ui, "collecting %r" % name):
with progress.spinner(ui, name):
value = _failsafe(gen)
finish = time.time()
msg.append(
@ -599,7 +601,7 @@ def rage(ui, repo, *pats, **opts):
advice = Please see our FAQ guide: https://...
"""
with progress.spinner(ui, "collecting information"):
with progress.spinner(ui, "collecting"):
with ui.configoverride({("ui", "color"): "False"}):
# Disable colors when generating a rage.
color.setup(ui)