Skip to content

Commit

Permalink
Updated debug logging (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
lwj5 authored and sitfoxfly committed Jul 24, 2019
1 parent d3c10f8 commit 2715b4f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion src/main/java/ai/preferred/venom/Crawler.java
Expand Up @@ -318,7 +318,8 @@ private void run() {
connections.acquire();
pendingJobs.add(job);
threadPool.execute(() -> {
LOGGER.debug("Preparing to fetch {}", job.getRequest().getUrl());
LOGGER.debug("Preparing job {} - {} (try {}/{}).",
Integer.toHexString(job.hashCode()), job.getRequest().getUrl(), job.getTryCount(), maxTries);
final CrawlerRequest crawlerRequest = prepareRequest(job.getRequest(), job.getTryCount());
if (Thread.currentThread().isInterrupted()) {
pendingJobs.remove(job);
Expand All @@ -340,16 +341,22 @@ private void run() {
final Callback callback = new Callback() {
@Override
public void completed(final @NotNull Request request, final @NotNull Response response) {
LOGGER.debug("Completed received for job {} - {}.", Integer.toHexString(job.hashCode()),
job.getRequest().getUrl());
completableResponseFuture.complete(response);
}

@Override
public void failed(final @NotNull Request request, final @NotNull Exception ex) {
LOGGER.debug("Failed received for job {} - {}.", Integer.toHexString(job.hashCode()),
job.getRequest().getUrl());
completableResponseFuture.completeExceptionally(ex);
}

@Override
public void cancelled(final @NotNull Request request) {
LOGGER.debug("Cancelled received for job {} - {}.", Integer.toHexString(job.hashCode()),
job.getRequest().getUrl());
completableResponseFuture.cancel(true);
}
};
Expand Down
Expand Up @@ -137,7 +137,7 @@ public JobScheduler(final BlockingQueue<Job> queue) {
public final void add(final Request r, final Handler h, final Priority p, final Priority pf) {
final Job job = new BasicJob(r, h, p, pf, queue);
queue.add(job);
LOGGER.debug("Job {} - {} added to queue.", job.toString(), r.getUrl());
LOGGER.debug("Added job {} - {} to queue.", Integer.toHexString(job.hashCode()), r.getUrl());
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ai/preferred/venom/job/BasicJob.java
Expand Up @@ -104,7 +104,7 @@ public final void reQueue() {
tryCount++;
queue.add(this);

LOGGER.debug("Job {} - {} re-queued.", this.toString(), request.getUrl());
LOGGER.debug("Re-queued job {} - {}.", Integer.toHexString(hashCode()), request.getUrl());
}

@Override
Expand Down

0 comments on commit 2715b4f

Please sign in to comment.