Added logging

This commit is contained in:
M66B 2019-06-25 08:05:28 +02:00
parent cf03e9f94f
commit 02936de391
4 changed files with 38 additions and 4 deletions

View File

@ -246,6 +246,7 @@ class Core {
db.operation().deleteOperation(op.id);
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(context, folder.name + " " + Helper.formatThrowable(ex));
db.operation().setOperationError(op.id, Helper.formatThrowable(ex));
if (message != null && !(ex instanceof IllegalArgumentException))
@ -1069,6 +1070,7 @@ class Core {
Log.w(folder.name, ex);
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(context, folder.name + " " + Helper.formatThrowable(ex));
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
}

View File

@ -191,8 +191,11 @@ public class EntityRule {
} else
matched = haystack.toLowerCase().contains(needle.trim().toLowerCase());
EntityLog.log(context, "Rule=" + name + " matched=" + matched +
" needle=" + needle + " haystack=" + haystack + " regex=" + regex);
EntityLog.log(context, "Rule=" + name +
" matched=" + matched +
" needle=" + needle +
" haystack=" + haystack +
" regex=" + regex);
return matched;
}

View File

@ -151,6 +151,9 @@ public class ServiceSend extends LifecycleService {
db.operation().deleteOperation(op.id);
} catch (Throwable ex) {
Log.e(outbox.name, ex);
EntityLog.log(
ServiceSend.this,
outbox.name + " " + Helper.formatThrowable(ex));
db.operation().setOperationError(op.id, Helper.formatThrowable(ex));
if (message != null)
@ -363,8 +366,9 @@ public class ServiceSend extends LifecycleService {
Address[] to = imessage.getAllRecipients();
itransport.sendMessage(imessage, to);
long time = new Date().getTime();
EntityLog.log(this, "Sent via " + ident.host + "/" + ident.user +
" to " + TextUtils.join(", ", to));
EntityLog.log(this,
"Sent via " + ident.host + "/" + ident.user +
" to " + TextUtils.join(", ", to));
// Append replied/forwarded text
StringBuilder sb = new StringBuilder();
@ -429,6 +433,8 @@ public class ServiceSend extends LifecycleService {
throw ex;
}
EntityLog.log(this, ident.name + " last attempt: " + new Date(message.last_attempt));
long now = new Date().getTime();
long delayed = now - message.last_attempt;
if (delayed > IDENTITY_ERROR_AFTER * 60 * 1000L || ex instanceof SendFailedException) {

View File

@ -595,8 +595,12 @@ public class ServiceSynchronize extends LifecycleService {
else
try {
wlFolder.acquire();
String message = e.getMessage();
Log.w(account.name + " alert: " + message);
EntityLog.log(
ServiceSynchronize.this, account.name + " " +
Helper.formatThrowable(new Core.AlertException(message)));
db.account().setAccountError(account.id, message);
if (message != null && !message.startsWith("Too many simultaneous connections")) {
@ -702,6 +706,7 @@ public class ServiceSynchronize extends LifecycleService {
// Report account connection error
if (account.last_connected != null && !ConnectionHelper.airplaneMode(this)) {
EntityLog.log(this, account.name + " last connected: " + new Date(account.last_connected));
long now = new Date().getTime();
long delayed = now - account.last_connected - account.poll_interval * 60 * 1000L;
if (delayed > ACCOUNT_ERROR_AFTER * 60 * 1000L && backoff > BACKOFF_ERROR_AFTER) {
@ -846,6 +851,9 @@ public class ServiceSynchronize extends LifecycleService {
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
ServiceSynchronize.this,
folder.name + " " + Helper.formatThrowable(ex));
state.error(ex);
} finally {
wlMessage.release();
@ -874,6 +882,9 @@ public class ServiceSynchronize extends LifecycleService {
db.folder().setFolderTotal(folder.id, count < 0 ? null : count);
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
ServiceSynchronize.this,
folder.name + " " + Helper.formatThrowable(ex));
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
state.error(ex);
} finally {
@ -925,6 +936,9 @@ public class ServiceSynchronize extends LifecycleService {
}
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
ServiceSynchronize.this,
folder.name + " " + Helper.formatThrowable(ex));
state.error(ex);
} finally {
wlMessage.release();
@ -944,6 +958,9 @@ public class ServiceSynchronize extends LifecycleService {
}
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
ServiceSynchronize.this,
folder.name + " " + Helper.formatThrowable(ex));
state.error(new FolderClosedException(ifolder, "IDLE"));
} finally {
Log.i(folder.name + " end idle");
@ -1022,6 +1039,9 @@ public class ServiceSynchronize extends LifecycleService {
} catch (Throwable ex) {
Log.e(folder.name, ex);
EntityLog.log(
ServiceSynchronize.this,
folder.name + " " + Helper.formatThrowable(ex));
db.folder().setFolderError(folder.id, Helper.formatThrowable(ex));
state.error(ex);
} finally {
@ -1134,6 +1154,9 @@ public class ServiceSynchronize extends LifecycleService {
Log.w(ex);
} catch (Throwable ex) {
Log.e(account.name, ex);
EntityLog.log(
ServiceSynchronize.this,
account.name + " " + Helper.formatThrowable(ex));
db.account().setAccountError(account.id, Helper.formatThrowable(ex));
} finally {
// Stop watching for operations