todo/create debug logs but erase them on successgit-annexhttp://git-annex.branchable.com/todo/create_debug_logs_but_erase_them_on_success/git-annexikiwiki2020-06-17T01:18:32Zcomment 1http://git-annex.branchable.com/todo/create_debug_logs_but_erase_them_on_success/comment_1_72b1e3b25a221f42ea7919aaecd6012d/joey2020-06-17T01:18:32Z2020-03-16T18:09:30Z
<p>I'm doubtful about this:</p>
<ul>
<li>It's not super likely that a debug log will have enough information in it
to replicate a one-off problem. At best they generally provide some clues
that need to be confirmed with experiments, so the problem needs to be
reproduced before I can fix it.</li>
<li>This risks accumulating a bunch of debug logs if the user is doing things
that fail. Things can fail for a wide array or reasons that do not need
to be debugged, eg git-annex get fails all the time for valid reasons
such as a host not being accessible or drive not being mounted.</li>
<li>A debug log might contain some sensitive information, git-annex should
certianly not be sending them around without the user's eyes on them.</li>
<li>If the user noticed git-annex is accumulating a bunch of debug logs,
and does feel they are sensitive information, they may lose trust in
git-annex.</li>
</ul>
comment 2http://git-annex.branchable.com/todo/create_debug_logs_but_erase_them_on_success/comment_2_8809f216aac308962917053ea24b9022/lykos2020-06-17T01:18:32Z2020-03-26T20:36:28Z
<p>When testing a new version of git-annex-remote-googledrive, I often use a wrapper script like this:</p>
<pre><code># .zshrc.local
f_git_annex () {
log_file=$(mktemp "$(git rev-parse --git-dir 2>/dev/null)/annex/debug.XXX.log" 2>/dev/null)
if [ $? -ne 0 ]; then
echo "Error creating log file. Proceeding without logging."
git annex $@
return $?
fi
git annex $@ --debug 2> $log_file
if [ $? -ne 0 ]; then
echo "Errors occurred. Debug log in $log_file"
return $?
else
rm $log_file
fi
}
alias ga='f_git_annex'
</code></pre>
<p>It's good enough for me in those cases. Changing the first line of the function to something like this
<code>
log_file=$(umask 077; mktemp /tmp/annex.debug.XXX.log" 2>/dev/null)
</code>
would help against accumulating logs.</p>