[git] Add debug logging for start and finish of all Git commands.

Log start in start(), because runInCurrentThread doesn't cover all usages of start() (some history commands are called via start()).
Log finish in runInCurrentThread(), because start() is async.
This commit is contained in:
Kirill Likhodedov
2012-05-25 15:50:41 +04:00
parent 99e7bd87f5
commit 8ace69b58e
2 changed files with 21 additions and 1 deletions
@@ -136,4 +136,8 @@ public class GitCommand {
return new GitCommand(this, LockingPolicy.READ);
}
@Override
public String toString() {
return myName;
}
}
@@ -96,6 +96,8 @@ public abstract class GitHandler {
private Runnable mySuspendAction; // Suspend action used by {@link #suspendWriteLock()}
private Runnable myResumeAction; // Resume action used by {@link #resumeWriteLock()}
private long myStartTime; // git execution start timestamp
/**
* A constructor
@@ -387,12 +389,19 @@ public abstract class GitHandler {
checkNotStarted();
try {
// setup environment
myStartTime = System.currentTimeMillis();
if (!myProject.isDefault() && !mySilent && (myVcs != null)) {
myVcs.showCommandLine("cd " + myWorkingDirectory);
myVcs.showCommandLine(printableCommandLine());
LOG.info("cd " + myWorkingDirectory);
LOG.info(myCommandLine.getCommandLineString());
}
else {
LOG.debug("cd " + myWorkingDirectory);
LOG.debug(myCommandLine.getCommandLineString());
}
// setup environment
if (!myNoSSHFlag && myProjectSettings.isIdeaSsh()) {
GitSSHService ssh = GitSSHIdeaService.getInstance();
myEnv.put(GitSSHHandler.GIT_SSH_ENV, ssh.getScriptPath().getPath());
@@ -721,6 +730,13 @@ public abstract class GitHandler {
vcs.getCommandLock().writeLock().unlock();
break;
}
if (myStartTime > 0) {
LOG.debug(String.format("git %s took %s ms", myCommand, System.currentTimeMillis() - myStartTime));
}
else {
LOG.debug(String.format("git %s finished.", myCommand));
}
}
}