Skip to content

Commit

Permalink
improving log messages. #33 and #6
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Pinto committed May 17, 2013
1 parent 08f70b5 commit 8414def
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
import br.ufpe.cin.groundhog.GroundhogException;

/**
* Thrown when a check out cannot be performed
* @author fjsj
* Thrown when a checkout cannot be performed
* @author fjsj, gustavopinto
*/
public class CheckoutException extends GroundhogException {
private static final long serialVersionUID = 1L;

public CheckoutException(String msg) {
super(msg);
}

public CheckoutException(Throwable e) {
super(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
import java.io.File;
import java.util.Date;

import com.google.inject.Inject;

import br.ufpe.cin.groundhog.scmclient.EmptyProjectAtDateException;
import br.ufpe.cin.groundhog.scmclient.GitClient;
import br.ufpe.cin.groundhog.util.FileUtil;

import com.google.inject.Inject;

/**
* The code history analysis implementation for the Git SCM
* @author fjsj
* @author fjsj, gustavopinto
*/
public class GitCodeHistory implements CodeHistory {

private final GitClient gitClient;

@Inject
Expand All @@ -34,8 +34,7 @@ public File checkoutToDate(String project, String url, Date date) {
* @param repositoryFolder the repository where the source code is located
* @param date the date on which the checkout will be based
*/
public File checkoutToDate(String project, File repositoryFolder, final Date date)
throws CheckoutException, EmptyProjectAtDateException {
public File checkoutToDate(String project, File repositoryFolder, final Date date) {
try {
File projectFolder = new File(FileUtil.getInstance()
.createTempDir(), project);
Expand All @@ -46,7 +45,7 @@ public File checkoutToDate(String project, File repositoryFolder, final Date dat
this.gitClient.checkout(projectFolder, date);
return projectFolder;
} catch (Exception e) {
throw new CheckoutException(e);
throw new CheckoutException(e.getMessage());
}
}
}
16 changes: 12 additions & 4 deletions src/java/main/br/ufpe/cin/groundhog/main/CmdMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@
import com.google.inject.Guice;
import com.google.inject.Injector;

public class CmdMain extends GroundhogMain {

/**
* The groundhog entry point
*
* @author fjsj, gustavopinto
*/

public final class CmdMain extends GroundhogMain {
private static Logger logger = LoggerFactory.getLogger(CmdMain.class);

/**
Expand Down Expand Up @@ -154,6 +161,7 @@ public CodeHistory defineCodeHistory(SCM scm)
public File downloadAndCheckoutProject(Project project,
Date datetime, Future<File> repositoryFolderFuture)
throws InterruptedException, ExecutionException {

// Wait for project download
String name = project.getName();
File repositoryFolder = repositoryFolderFuture.get();
Expand Down Expand Up @@ -242,7 +250,7 @@ public void run(JsonInput input) {
ForgeSearch search = defineForgeSearch(input.getForge());
ForgeCrawler crawler = defineForgeCrawler(input.getForge(), destinationFolder);

String term = input.getSearch().getProjects().get(0);
String term = input.getSearch().getProjects().get(2);
List<Project> allProjects = search.getProjects(term, 1);

List<Project> projects = new ArrayList<Project>();
Expand Down Expand Up @@ -273,7 +281,7 @@ public void run() {
checkedOutRepository = downloadAndCheckoutProject(
project, datetime_, repositoryFolderFuture);
} catch (Exception e) {
logger.error(format("Error while downloading project %s",project.getName()), e);
logger.error(format("Error while downloading project %s: %s", project.getName(), e.getMessage()));
}
if (checkedOutRepository != null) {
try {
Expand All @@ -289,6 +297,7 @@ public void run() {
}
}));
}
crawler.shutdown();
ex.shutdown();

for (int i = 0; i < analysisFutures.size(); i++) {
Expand All @@ -299,7 +308,6 @@ public void run() {
}
}
logger.info("All projects downloaded and analyzed!");
crawler.shutdown();

} catch (GroundhogException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void clone(String url, File destination)
* @throws EmptyProjectAtDateException
*/
public void checkout(File repositoryFolder, Date date)
throws IOException, RefAlreadyExistsException, RefNotFoundException,
throws IOException, RefAlreadyExistsException,
InvalidRefNameException, CheckoutConflictException, GitAPIException,
EmptyProjectAtDateException {
Git git = Git.open(repositoryFolder);
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ log4j.rootCategory=INFO, stdout, file
log4j.appender.stdout.Threshold=INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] %m%n
log4j.appender.stdout.layout.ConversionPattern=%d{HH:mm:ss,SSS} %5p [%-20c{1}] %m%n

log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=groundhog.log
Expand Down

0 comments on commit 8414def

Please sign in to comment.