Only log in case the operation took longer than 100 ms

This commit is contained in:
chimp1984 2020-12-15 00:56:06 -05:00
parent 0e7dd21745
commit 02d163f5dc
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3

View File

@ -375,7 +375,10 @@ public class PersistenceManager<T extends PersistableEnvelope> {
// reference to the persistable object.
getWriteToDiskExecutor().execute(() -> writeToDisk(serialized, completeHandler));
log.info("Serializing {} took {} msec", fileName, System.currentTimeMillis() - ts);
long duration = System.currentTimeMillis() - ts;
if (duration > 100) {
log.info("Serializing {} took {} msec", fileName, duration);
}
} catch (Throwable e) {
log.error("Error in saveToFile toProtoMessage: {}, {}", persistable.getClass().getSimpleName(), fileName);
e.printStackTrace();
@ -437,7 +440,10 @@ public class PersistenceManager<T extends PersistableEnvelope> {
e.printStackTrace();
log.error("Cannot close resources." + e.getMessage());
}
log.info("Writing the serialized {} completed in {} msec", fileName, System.currentTimeMillis() - ts);
long duration = System.currentTimeMillis() - ts;
if (duration > 100) {
log.info("Writing the serialized {} completed in {} msec", fileName, duration);
}
persistenceRequested = false;
if (completeHandler != null) {
UserThread.execute(completeHandler);