Skip to content

Commit

Permalink
Logging refactory
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagolvlsantos committed May 6, 2024
1 parent 5712858 commit a5a8986
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,25 @@ public Object perform(ProceedingJoinPoint jp, Class<A> type) throws Throwable {
long total = time;
init(jp, dynamic);
String simpleName = type.getSimpleName();
String name = signature.getName();
log.info("** @{}({}).init: {} ms, @{} **", simpleName, name, System.currentTimeMillis() - time, dynamic);
String group = dynamic.value();
String method = signature.getName();
log.info("** @{}({}[{}]).init: {} ms, @{} **", simpleName, group, method, System.currentTimeMillis() - time,
dynamic);
time = System.currentTimeMillis();
try {
Object result = success(jp, dynamic, jp.proceed());
log.info("** @{}({}).success: {} ms **", simpleName, name, System.currentTimeMillis() - time);
log.info("** @{}({}[{}]).success: {} ms **", simpleName, group, method, System.currentTimeMillis() - time);
return result;
} catch (Throwable e) {
Throwable error = error(jp, dynamic, e);
log.error("** @{}({}).failure: {} ms **", simpleName, name, System.currentTimeMillis() - time);
log.error("** @{}({}[{}]).failure: {} ms **", simpleName, group, method, System.currentTimeMillis() - time);
throw error;
} finally {
try {
time = System.currentTimeMillis();
finish(dynamic);
long current = System.currentTimeMillis();
log.info("** @{}({}).finalyze: {} ms, TOTAL: {} ms **", simpleName, name, current - time,
log.info("** @{}({}[{}]).finalyze: {} ms, TOTAL: {} ms **", simpleName, group, method, current - time,
current - total);
} finally {
manager.endTransaction(context, dynamic);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,18 @@ public void clean(IGitAnnotation annotation) throws GitAPIException {
Git git = entry.getValue();
git.close();
}
log.info("Close gits = {}", this.gitInstances.keySet());
log.debug("close gits({}) = {}", annotation.value(), this.gitInstances.keySet());
}
this.gitInstances.clear();

this.pulledReads.clear();
this.gitReads.clear();

if (!this.pulledWrites.isEmpty()) {
for (Map.Entry<Git, File> entry : this.pulledWrites.entrySet()) {
cleanDirectory(entry.getValue());
}
log.info("Clean writes = {}", this.pulledWrites.values());
log.debug("clean writes({}) = {}", annotation.value(), this.pulledWrites.values());
}
this.pulledWrites.clear();
this.gitWrites.clear();
Expand All @@ -393,7 +394,7 @@ public void clean(IGitAnnotation annotation) throws GitAPIException {
for (Map.Entry<String, File> entry : this.gitCommits.entrySet()) {
cleanDirectory(entry.getValue());
}
log.info("Clean commits = {}", this.gitCommits.keySet());
log.debug("clean commits({}) = {}", annotation.value(), this.gitCommits.keySet());
}
this.gitCommits.clear();

Expand All @@ -411,9 +412,9 @@ protected void cleanDirectory(File dir) {
error = e;
} finally {
if (error == null) {
log.debug("clean(success):{} time={}", dir, System.currentTimeMillis() - time);
log.debug("clean(success): {} time={}", dir, System.currentTimeMillis() - time);
} else {
log.debug("clean(error:{}): time={} error={}", dir, System.currentTimeMillis() - time,
log.debug("clean(error: {}): time={} error={}", dir, System.currentTimeMillis() - time,
error.getMessage());
}
}
Expand Down Expand Up @@ -444,7 +445,7 @@ private Iterable<RevCommit> log(String group, String path, Git git, Integer skip
command = command.setMaxCount(max);
}
Iterable<RevCommit> call = command.call();
log.info("log({}):{}, time={}", group, normalizedPath, System.currentTimeMillis() - time);
log.info("log({}): {}, time={}", group, normalizedPath, System.currentTimeMillis() - time);
return call;
}
}

0 comments on commit a5a8986

Please sign in to comment.