Add logging statement for # of tasks in DNS queue

This will make DNS issues easier to debug retroactively as we will be
able to determine, by looking at the logs, if the queue size was growing
unbounded.

Also adds some logging helpers to allow programmatically choosing the level
of logging.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=163123783
This commit is contained in:
mcilwain 2017-07-25 14:31:19 -07:00 committed by Ben McIlwain
parent 1a1fdfd531
commit 8869814e96
3 changed files with 24 additions and 4 deletions

View file

@ -19,6 +19,7 @@ import com.google.common.collect.FluentIterable;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
/** Logging wrapper. */
public class FormattingLogger {
@ -34,7 +35,15 @@ public class FormattingLogger {
this.logger = Logger.getLogger(name);
}
private void log(Level level, Throwable cause, String msg) {
public void logfmt(Level level, Throwable cause, String fmt, Object... args) {
log(level, cause, String.format(fmt, args));
}
public void logfmt(Level level, String fmt, Object... args) {
log(level, null, String.format(fmt, args));
}
private void log(Level level, @Nullable Throwable cause, String msg) {
StackTraceElement callerFrame = FluentIterable
.from(new Exception().getStackTrace())
.firstMatch(new Predicate<StackTraceElement>() {