mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 19:48:32 +02:00
Rationalize logging statements across codebase
This fixes up the following problems: 1. Using string concatenation instead of the formatting variant methods. 2. Logging or swallowing exception messages without logging the exception itself (this swallows the stack trace). 3. Unnecessary logging on re-thrown exceptions. 4. Unnecessary use of formatting variant methods when not necessary. 5. Complicated logging statements involving significant processing not being wrapped inside of a logging level check. 6. Redundant logging both of an exception itself and its message (this is unnecessary duplication). 7. Use of the base Logger class instead of our FormattingLogger class. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=182419837
This commit is contained in:
parent
f22a42cd42
commit
81dc2bbbc3
47 changed files with 172 additions and 154 deletions
|
@ -87,14 +87,14 @@ class EscrowTaskRunner {
|
|||
final Duration interval) {
|
||||
Callable<Void> lockRunner =
|
||||
() -> {
|
||||
logger.info("tld=" + registry.getTld());
|
||||
logger.infofmt("TLD: %s", registry.getTld());
|
||||
DateTime startOfToday = clock.nowUtc().withTimeAtStartOfDay();
|
||||
Cursor cursor = ofy().load().key(Cursor.createKey(cursorType, registry)).now();
|
||||
final DateTime nextRequiredRun = (cursor == null ? startOfToday : cursor.getCursorTime());
|
||||
if (nextRequiredRun.isAfter(startOfToday)) {
|
||||
throw new NoContentException("Already completed");
|
||||
}
|
||||
logger.info("cursor=" + nextRequiredRun);
|
||||
logger.infofmt("Cursor: %s", nextRequiredRun);
|
||||
task.runWithLock(nextRequiredRun);
|
||||
ofy()
|
||||
.transact(
|
||||
|
|
|
@ -60,7 +60,7 @@ final class JSchSshSession implements Closeable {
|
|||
*/
|
||||
JSchSshSession create(JSch jsch, URI uri) throws JSchException {
|
||||
RdeUploadUrl url = RdeUploadUrl.create(uri);
|
||||
logger.info("Connecting to SSH endpoint: " + url);
|
||||
logger.infofmt("Connecting to SSH endpoint: %s", url);
|
||||
Session session = jsch.getSession(
|
||||
url.getUser().orElse("domain-registry"),
|
||||
url.getHost(),
|
||||
|
@ -99,7 +99,7 @@ final class JSchSshSession implements Closeable {
|
|||
try {
|
||||
chan.cd(dir);
|
||||
} catch (SftpException e) {
|
||||
logger.warning(e.toString());
|
||||
logger.warning(e, "Could not open SFTP channel.");
|
||||
mkdirs(chan, dir);
|
||||
chan.cd(dir);
|
||||
}
|
||||
|
|
|
@ -223,9 +223,7 @@ public final class RdeStagingAction implements Runnable {
|
|||
response.setPayload(message);
|
||||
return;
|
||||
}
|
||||
for (PendingDeposit pending : pendings.values()) {
|
||||
logger.infofmt("%s", pending);
|
||||
}
|
||||
pendings.values().stream().map(Object::toString).forEach(logger::info);
|
||||
RdeStagingMapper mapper = new RdeStagingMapper(lenient ? LENIENT : STRICT, pendings);
|
||||
|
||||
response.sendJavaScriptRedirect(createJobPath(mrRunner
|
||||
|
|
|
@ -167,7 +167,7 @@ public final class RdeStagingReducer extends Reducer<PendingDeposit, DepositFrag
|
|||
}
|
||||
if (!fragment.error().isEmpty()) {
|
||||
failed = true;
|
||||
logger.severe(fragment.error());
|
||||
logger.severefmt("Fragment error: %s", fragment.error());
|
||||
}
|
||||
}
|
||||
for (IdnTableEnum idn : IdnTableEnum.values()) {
|
||||
|
|
|
@ -149,9 +149,7 @@ public class RdeHostLinkAction implements Runnable {
|
|||
case HOST_NOT_FOUND:
|
||||
getContext().incrementCounter("hosts not found");
|
||||
logger.severefmt(
|
||||
"Host with name %s and repoid %s not found",
|
||||
xjcHost.getName(),
|
||||
xjcHost.getRoid());
|
||||
"Host with name %s and repoid %s not found", xjcHost.getName(), xjcHost.getRoid());
|
||||
break;
|
||||
case SUPERORDINATE_DOMAIN_IN_PENDING_DELETE:
|
||||
getContext()
|
||||
|
|
|
@ -65,7 +65,7 @@ public class RdeHostReader extends InputReader<JaxbFragment<XjcRdeHostElement>>
|
|||
parser.skipHosts(offset + count);
|
||||
return parser;
|
||||
} catch (Exception e) {
|
||||
logger.severefmt(e, "Error opening rde file %s/%s", importBucketName, importFileName);
|
||||
logger.severefmt(e, "Error opening RDE file %s/%s", importBucketName, importFileName);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue