[geary/wip/structured-logging: 3/4] Convert key classes to implement Loggable
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/structured-logging: 3/4] Convert key classes to implement Loggable
- Date: Sat, 29 Dec 2018 02:54:10 +0000 (UTC)
commit 4a8afa1c917f2da1a83ade9d99be7136b75911e7
Author: Michael Gratton <mike vee net>
Date: Sat Dec 29 13:34:29 2018 +1100
Convert key classes to implement Loggable
Make accounts, folders, client sessions and account ops implement
Loggable, remove manual context from log messages there and in
subclasses.
src/engine/api/geary-account.vala | 26 ++--
src/engine/api/geary-client-service.vala | 23 +++-
src/engine/api/geary-folder.vala | 22 +++-
.../gmail/imap-engine-gmail-folder.vala | 4 +-
.../imap-engine/imap-engine-account-operation.vala | 18 +--
.../imap-engine/imap-engine-generic-account.vala | 62 +++++-----
.../imap-engine/imap-engine-minimal-folder.vala | 133 +++++++++++----------
src/engine/imap/api/imap-client-service.vala | 26 ++--
src/engine/imap/transport/imap-deserializer.vala | 6 +-
9 files changed, 179 insertions(+), 141 deletions(-)
---
diff --git a/src/engine/api/geary-account.vala b/src/engine/api/geary-account.vala
index d381208a..8e13c623 100644
--- a/src/engine/api/geary-account.vala
+++ b/src/engine/api/geary-account.vala
@@ -20,7 +20,7 @@
* A list of all Accounts may be retrieved from the {@link Engine} singleton.
*/
-public abstract class Geary.Account : BaseObject {
+public abstract class Geary.Account : BaseObject, Loggable {
/** Number of times to attempt re-authentication. */
@@ -60,8 +60,6 @@ public abstract class Geary.Account : BaseObject {
public Geary.ProgressMonitor opening_monitor { get; protected set; }
public Geary.ProgressMonitor sending_monitor { get; protected set; }
- protected string id { get; private set; }
-
public signal void opened();
@@ -173,12 +171,17 @@ public abstract class Geary.Account : BaseObject {
public signal void email_flags_changed(Geary.Folder folder,
Gee.Map<Geary.EmailIdentifier, Geary.EmailFlags> map);
+ /** {@inheritDoc} */
+ public Logging.Flag loggable_flags {
+ get; protected set; default = Logging.Flag.ALL;
+ }
+
+ /** {@inheritDoc} */
+ public Loggable? loggable_parent { get { return null; } }
+
protected Account(AccountInformation information) {
this.information = information;
- this.id = "%s[%s]".printf(
- information.id, information.service_provider.to_value()
- );
}
/**
@@ -381,12 +384,13 @@ public abstract class Geary.Account : BaseObject {
*/
public abstract async Gee.MultiMap<Geary.EmailIdentifier, Geary.FolderPath>?
get_containing_folders_async(
Gee.Collection<Geary.EmailIdentifier> ids, Cancellable? cancellable) throws Error;
-
- /**
- * Used only for debugging. Should not be used for user-visible strings.
- */
+
+ /** {@inheritDoc} */
public virtual string to_string() {
- return this.id;
+ return "%s(%s)".printf(
+ this.get_type().name(),
+ this.information.id
+ );
}
/** Fires a {@link opened} signal. */
diff --git a/src/engine/api/geary-client-service.vala b/src/engine/api/geary-client-service.vala
index c0617205..dd7085ca 100644
--- a/src/engine/api/geary-client-service.vala
+++ b/src/engine/api/geary-client-service.vala
@@ -14,7 +14,7 @@
* configuration and life-cycle of client sessions that do connect to
* the service.
*/
-public abstract class Geary.ClientService : BaseObject {
+public abstract class Geary.ClientService : BaseObject, Loggable {
/**
@@ -34,6 +34,15 @@ public abstract class Geary.ClientService : BaseObject {
/** Determines if this manager has been started. */
public bool is_running { get; protected set; default = false; }
+ /** {@inheritDoc} */
+ public Logging.Flag loggable_flags {
+ get; protected set; default = Logging.Flag.ALL;
+ }
+
+ /** {@inheritDoc} */
+ public Loggable? loggable_parent { get { return _loggable_parent; } }
+ private weak Loggable? _loggable_parent = null;
+
protected ClientService(AccountInformation account,
@@ -90,6 +99,18 @@ public abstract class Geary.ClientService : BaseObject {
public abstract async void stop(GLib.Cancellable? cancellable = null)
throws GLib.Error;
+ /** {@inheritDoc} */
+ public virtual string to_string() {
+ return "%s(%s)".printf(
+ this.get_type().name(),
+ this.configuration.protocol.to_value()
+ );
+ }
+
+ /** Sets the service's logging parent. */
+ internal void set_loggable_parent(Loggable parent) {
+ this._loggable_parent = parent;
+ }
private void on_untrusted_host(TlsNegotiationMethod method,
GLib.TlsConnection cx) {
diff --git a/src/engine/api/geary-folder.vala b/src/engine/api/geary-folder.vala
index afdd1ee7..deee9f3e 100644
--- a/src/engine/api/geary-folder.vala
+++ b/src/engine/api/geary-folder.vala
@@ -61,7 +61,7 @@
*
* @see Geary.SpecialFolderType
*/
-public abstract class Geary.Folder : BaseObject {
+public abstract class Geary.Folder : BaseObject, Loggable {
/**
* Indicates if a folder has been opened, and if so in which way.
@@ -234,6 +234,15 @@ public abstract class Geary.Folder : BaseObject {
/** Monitor for notifying of progress when opening the folder. */
public abstract Geary.ProgressMonitor opening_monitor { get; }
+ /** {@inheritDoc} */
+ public Logging.Flag loggable_flags {
+ get; protected set; default = Logging.Flag.ALL;
+ }
+
+ /** {@inheritDoc} */
+ public Loggable? loggable_parent {
+ get { return this.account; }
+ }
/**
* Fired when the folder moves through stages of being opened.
@@ -669,10 +678,13 @@ public abstract class Geary.Folder : BaseObject {
public abstract async Geary.Email fetch_email_async(Geary.EmailIdentifier email_id,
Geary.Email.Field required_fields, ListFlags flags, Cancellable? cancellable = null) throws Error;
- /**
- * Used for debugging. Should not be used for user-visible labels.
- */
+ /** {@inheritDoc} */
public virtual string to_string() {
- return "%s:%s".printf(this.account.information.id, this.path.to_string());
+ return "%s(%s:%s)".printf(
+ this.get_type().name(),
+ this.account.information.id,
+ this.path.to_string()
+ );
}
+
}
diff --git a/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala
b/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala
index dc8eb3fe..ba346ae2 100644
--- a/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala
+++ b/src/engine/imap-engine/gmail/imap-engine-gmail-folder.vala
@@ -68,7 +68,7 @@ private class Geary.ImapEngine.GmailFolder : MinimalFolder, FolderSupport.Archiv
// messages are removed from all labels)
Gee.Set<Imap.UID>? uids = yield folder.copy_email_uids_async(email_ids, trash.path, cancellable);
if (uids == null || uids.size == 0) {
- debug("%s: Can't true-remove %d emails, no COPYUIDs returned", folder.to_string(),
+ GLib.debug("%s: Can't true-remove %d emails, no COPYUIDs returned", folder.to_string(),
email_ids.size);
return;
@@ -87,7 +87,7 @@ private class Geary.ImapEngine.GmailFolder : MinimalFolder, FolderSupport.Archiv
yield account.release_folder_session(imap_trash);
}
- debug("%s: Successfully true-removed %d/%d emails", folder.to_string(), uids.size,
+ GLib.debug("%s: Successfully true-removed %d/%d emails", folder.to_string(), uids.size,
email_ids.size);
}
}
diff --git a/src/engine/imap-engine/imap-engine-account-operation.vala
b/src/engine/imap-engine/imap-engine-account-operation.vala
index ea9641b0..99a7fdb3 100644
--- a/src/engine/imap-engine/imap-engine-account-operation.vala
+++ b/src/engine/imap-engine/imap-engine-account-operation.vala
@@ -33,9 +33,17 @@
* equal_to} method to specify which instances are considered to be
* duplicates.
*/
-public abstract class Geary.ImapEngine.AccountOperation : Geary.BaseObject {
+public abstract class Geary.ImapEngine.AccountOperation : BaseObject, Loggable {
+ /** {@inheritDoc} */
+ public Logging.Flag loggable_flags {
+ get; protected set; default = Logging.Flag.ALL;
+ }
+
+ /** {@inheritDoc} */
+ public Loggable? loggable_parent { get { return account; } }
+
/** The account this operation applies to. */
protected weak Geary.Account account { get; private set; }
@@ -103,13 +111,9 @@ public abstract class Geary.ImapEngine.AccountOperation : Geary.BaseObject {
return (op != null && (this == op || this.get_type() == op.get_type()));
}
- /**
- * Provides a representation of this operation for debugging.
- *
- * By default simply returns the name of the class.
- */
+ /** {@inheritDoc} */
public virtual string to_string() {
- return this.get_type().name();
+ return get_type().name();
}
}
diff --git a/src/engine/imap-engine/imap-engine-generic-account.vala
b/src/engine/imap-engine/imap-engine-generic-account.vala
index 2bde62d3..9382590f 100644
--- a/src/engine/imap-engine/imap-engine-generic-account.vala
+++ b/src/engine/imap-engine/imap-engine-generic-account.vala
@@ -77,6 +77,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
this.imap.ready.connect(on_pool_session_ready);
this.imap.connection_failed.connect(on_pool_connection_failed);
this.imap.login_failed.connect(on_pool_login_failed);
+ this.imap.set_loggable_parent(this);
this.smtp = new Smtp.ClientService(
config,
@@ -84,6 +85,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
outgoing_remote,
new Outbox.Folder(this, this.local)
);
+ this.smtp.set_loggable_parent(this);
this.smtp.email_sent.connect(on_email_sent);
this.smtp.report_problem.connect(notify_report_problem);
@@ -180,9 +182,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
try {
yield this.smtp.stop();
} catch (Error err) {
- debug(
- "%s: Error stopping SMTP service: %s", to_string(), err.message
- );
+ debug("Error stopping SMTP service: %s", err.message);
}
// Block obtaining and reusing IMAP connections
@@ -207,11 +207,11 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
notify_folders_available_unavailable(null, remotes);
foreach (Geary.Folder folder in locals) {
- debug("%s: Waiting for local to close: %s", to_string(), folder.to_string());
+ debug("Waiting for local to close: %s", folder.to_string());
yield folder.wait_for_close_async();
}
foreach (Geary.Folder folder in remotes) {
- debug("%s: Waiting for remote to close: %s", to_string(), folder.to_string());
+ debug("Waiting for remote to close: %s", folder.to_string());
yield folder.wait_for_close_async();
}
@@ -220,9 +220,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
try {
yield this.imap.stop();
} catch (Error err) {
- debug(
- "%s: Error stopping IMAP service: %s", to_string(), err.message
- );
+ debug("Error stopping IMAP service: %s", err.message);
}
this.remote_ready_lock = null;
@@ -245,9 +243,9 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
public override async void rebuild_async(Cancellable? cancellable = null) throws Error {
if (open)
throw new EngineError.ALREADY_OPEN("Account cannot be open during rebuild");
-
- message("%s: Rebuilding account local data", to_string());
-
+
+ message("Rebuilding account local data");
+
// get all the storage locations associated with this Account
File db_file;
File attachments_dir;
@@ -255,24 +253,21 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
out attachments_dir);
if (yield Files.query_exists_async(db_file, cancellable)) {
- message(
- "%s: Deleting database file %s...",
- to_string(), db_file.get_path()
- );
+ message("Deleting database file %s...", db_file.get_path());
yield db_file.delete_async(GLib.Priority.DEFAULT, cancellable);
}
if (yield Files.query_exists_async(attachments_dir, cancellable)) {
message(
- "%s: Deleting attachments directory %s...",
- to_string(), attachments_dir.get_path()
+ "Deleting attachments directory %s...",
+ attachments_dir.get_path()
);
yield Files.recursive_delete_async(
attachments_dir, GLib.Priority.DEFAULT, cancellable
);
}
- message("%s: Rebuild complete", to_string());
+ message("Rebuild complete");
}
/**
@@ -285,7 +280,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
public void queue_operation(AccountOperation op)
throws EngineError {
check_open();
- debug("%s: Enqueuing operation: %s", this.to_string(), op.to_string());
+ debug("Enqueuing operation: %s", op.to_string());
this.processor.enqueue(op);
}
@@ -303,7 +298,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
public async Imap.AccountSession claim_account_session(Cancellable? cancellable = null)
throws Error {
check_open();
- debug("%s: Acquiring account session", this.to_string());
+ debug("Acquiring account session");
yield this.remote_ready_lock.wait_async(cancellable);
Imap.ClientSession client =
yield this.imap.claim_authorized_session_async(cancellable);
@@ -314,7 +309,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
* Returns an IMAP account session to the pool for re-use.
*/
public void release_account_session(Imap.AccountSession session) {
- debug("%s: Releasing account session", this.to_string());
+ debug("Releasing account session");
Imap.ClientSession? old_session = session.close();
if (old_session != null) {
this.imap.release_session_async.begin(
@@ -323,9 +318,9 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
try {
this.imap.release_session_async.end(res);
} catch (Error err) {
- debug("%s: Error releasing account session: %s",
- to_string(),
- err.message);
+ debug(
+ "Error releasing account session: %s", err.message
+ );
}
}
);
@@ -347,7 +342,7 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
Cancellable cancellable)
throws Error {
check_open();
- debug("%s: Acquiring folder session", this.to_string());
+ debug("Acquiring folder session for: %s", path.to_string());
yield this.remote_ready_lock.wait_async(cancellable);
// We manually construct an account session here and then
@@ -398,14 +393,13 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
* Returns an IMAP folder session to the pool for cleanup and re-use.
*/
public async void release_folder_session(Imap.FolderSession session) {
- debug("%s: Releasing folder session", this.to_string());
+ debug("Releasing folder session");
Imap.ClientSession? old_session = session.close();
if (old_session != null) {
try {
yield this.imap.release_session_async(old_session);
} catch (Error err) {
- debug("%s: Error releasing %s session: %s",
- to_string(),
+ debug("Error releasing %s session: %s",
session.folder.path.to_string(),
err.message);
}
@@ -694,7 +688,11 @@ private abstract class Geary.ImapEngine.GenericAccount : Geary.Account {
throws Error {
Geary.FolderPath? path = information.get_special_folder_path(special);
if (path != null) {
- debug("Previously used %s for special folder %s", path.to_string(), special.to_string());
+ debug(
+ "Previously used \"%s\" for special folder %s",
+ path.to_string(),
+ special.to_string()
+ );
} else {
// This is the first time we're turning a non-special folder into a special one.
// After we do this, we'll record which one we picked in the account info.
@@ -1163,8 +1161,8 @@ internal class Geary.ImapEngine.LoadFolders : AccountOperation {
Geary.Folder target = yield generic.fetch_folder_async(path, cancellable);
specials.set(special, target);
} catch (Error err) {
- debug("%s: Previously used special folder %s does not exist: %s",
- generic.information.id, special.to_string(), err.message);
+ debug("Previously used special folder %s does not exist: %s",
+ special.to_string(), err.message);
}
}
}
@@ -1254,7 +1252,7 @@ internal class Geary.ImapEngine.UpdateRemoteFolders : AccountOperation {
if (err is IOError || err is ImapError)
throw err;
debug("Ignoring error listing child folders of %s: %s",
- (parent != null ? parent.to_string() : "root"), err.message);
+ (parent != null ? parent.to_string() : "root"), err.message);
results_suspect = true;
}
diff --git a/src/engine/imap-engine/imap-engine-minimal-folder.vala
b/src/engine/imap-engine/imap-engine-minimal-folder.vala
index abbca331..3a6b04e0 100644
--- a/src/engine/imap-engine/imap-engine-minimal-folder.vala
+++ b/src/engine/imap-engine/imap-engine-minimal-folder.vala
@@ -236,7 +236,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
public async Imap.FolderSession claim_remote_session(Cancellable? cancellable = null)
throws Error {
check_open("claim_remote_session");
- debug("%s: Claiming folder session", this.to_string());
+ debug("Claiming folder session");
// If remote has not yet been opened and we are not in the
@@ -255,7 +255,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
public override async bool close_async(Cancellable? cancellable = null)
throws Error {
check_open("close_async");
- debug("%s: Scheduling folder close", this.to_string());
+ debug("Scheduling folder close");
// Although it's inefficient in the case of just decrementing
// the open count, pass all requests to close via the replay
// queue so that other operations queued are interleaved in an
@@ -299,7 +299,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
private async void normalize_folders(Geary.Imap.FolderSession session,
Cancellable cancellable)
throws Error {
- debug("%s: Begin normalizing remote and local folders", to_string());
+ debug("Begin normalizing remote and local folders");
Geary.Imap.FolderProperties local_properties = this.local_folder.get_properties();
Geary.Imap.FolderProperties remote_properties = session.folder.properties;
@@ -338,7 +338,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
//
// see http://tools.ietf.org/html/rfc3501#section-2.3.1.1
if (local_properties.uid_validity.value != remote_properties.uid_validity.value) {
- debug("%s: UID validity changed, detaching all email: %s -> %s", to_string(),
+ debug("UID validity changed, detaching all email: %s -> %s",
local_properties.uid_validity.value.to_string(),
remote_properties.uid_validity.value.to_string());
yield detach_all_emails_async(cancellable);
@@ -363,7 +363,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// if no earliest UID, that means no messages in local store, so nothing to update
if (local_earliest_id == null || local_latest_id == null) {
- debug("%s: local store empty, nothing to normalize", to_string());
+ debug("local store empty, nothing to normalize");
return;
}
@@ -384,7 +384,8 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
bool is_dirty = (already_marked_ids != null && already_marked_ids.size > 0);
if (is_dirty)
- debug("%s: %d remove markers found, folder is dirty", to_string(), already_marked_ids.size);
+ debug("%d remove markers found, folder is dirty",
+ already_marked_ids.size);
// a full normalize works from the highest possible UID on the remote and work down to the lowest
UID on
// the local; this covers all messages appended since last seen as well as any removed
@@ -393,9 +394,10 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// if either local UID is out of range of the current highest UID, then something very wrong
// has occurred; the only recourse is to wipe all associations and start over
if (local_earliest_id.uid.compare_to(last_uid) > 0 || local_latest_id.uid.compare_to(last_uid) > 0) {
- debug("%s: Local UID(s) higher than remote UIDNEXT, detaching all email: %s/%s remote=%s",
- to_string(), local_earliest_id.uid.to_string(), local_latest_id.uid.to_string(),
- last_uid.to_string());
+ debug("Local UID(s) higher than remote UIDNEXT, detaching all email: %s/%s remote=%s",
+ local_earliest_id.uid.to_string(),
+ local_latest_id.uid.to_string(),
+ last_uid.to_string());
yield detach_all_emails_async(cancellable);
return;
}
@@ -416,7 +418,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// email is the same, then nothing has been added or removed,
// and we're done.
if (!is_dirty && uidnext_diff == 0 && local_message_count == remote_message_count) {
- debug("%s: No messages added/removed since last opened, normalization completed", to_string());
+ debug("No messages added/removed since last opened, normalization completed");
return;
}
@@ -430,16 +432,16 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
Imap.UID first_uid;
if (!is_dirty && uidnext_diff == (remote_message_count - local_message_count)) {
first_uid = local_latest_id.uid.next(true);
-
- debug("%s: Messages only appended (local/remote UIDNEXT=%s/%s total=%d/%d diff=%s), gathering
mail UIDs %s:%s",
- to_string(), local_properties.uid_next.to_string(), remote_properties.uid_next.to_string(),
+
+ debug("Messages only appended (local/remote UIDNEXT=%s/%s total=%d/%d diff=%s), gathering mail
UIDs %s:%s",
+ local_properties.uid_next.to_string(), remote_properties.uid_next.to_string(),
local_properties.select_examine_messages, remote_properties.select_examine_messages,
uidnext_diff.to_string(),
first_uid.to_string(), last_uid.to_string());
} else {
first_uid = local_earliest_id.uid;
-
- debug("%s: Messages appended/removed (local/remote UIDNEXT=%s/%s total=%d/%d diff=%s), gathering
mail UIDs %s:%s",
- to_string(), local_properties.uid_next.to_string(), remote_properties.uid_next.to_string(),
+
+ debug("Messages appended/removed (local/remote UIDNEXT=%s/%s total=%d/%d diff=%s), gathering
mail UIDs %s:%s",
+ local_properties.uid_next.to_string(), remote_properties.uid_next.to_string(),
local_properties.select_examine_messages, remote_properties.select_examine_messages,
uidnext_diff.to_string(),
first_uid.to_string(), last_uid.to_string());
}
@@ -460,10 +462,10 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
remote_uids = new Gee.HashSet<Imap.UID>();
check_open("normalize_folders (list remote)");
-
- debug("%s: Loaded local (%d) and remote (%d) UIDs, normalizing...", to_string(),
- local_uids.size, remote_uids.size);
-
+
+ debug("Loaded local (%d) and remote (%d) UIDs, normalizing...",
+ local_uids.size, remote_uids.size);
+
Gee.HashSet<Imap.UID> removed_uids = new Gee.HashSet<Imap.UID>();
Gee.HashSet<Imap.UID> appended_uids = new Gee.HashSet<Imap.UID>();
Gee.HashSet<Imap.UID> inserted_uids = new Gee.HashSet<Imap.UID>();
@@ -499,9 +501,9 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
}
}
}, cancellable);
-
- debug("%s: changes since last seen: removed=%d appended=%d inserted=%d", to_string(),
- removed_uids.size, appended_uids.size, inserted_uids.size);
+
+ debug("Changes since last seen: removed=%d appended=%d inserted=%d",
+ removed_uids.size, appended_uids.size, inserted_uids.size);
/*
* Step 4: Synchronise local folder with remote
@@ -556,10 +558,10 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
}
}
}, cancellable);
-
- debug("%s: Finished creating/merging %d emails", to_string(), created_or_merged.size);
+
+ debug("Finished creating/merging %d emails", created_or_merged.size);
}
-
+
check_open("normalize_folders (created/merged appended/inserted emails)");
// Convert removed UIDs into EmailIdentifiers and detach immediately
@@ -593,57 +595,60 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// there may be operations pending on the remote queue for these removed emails; notify
// operations that the email has shuffled off this mortal coil
replay_queue.notify_remote_removed_ids(removed_ids);
-
+
// notify subscribers about emails that have been removed
- debug("%s: Notifying of %d removed emails since last opened", to_string(), removed_ids.size);
+ debug("Notifying of %d removed emails since last opened",
+ removed_ids.size);
notify_email_removed(removed_ids);
-
+
count_change_reason |= Folder.CountChangeReason.REMOVED;
}
-
+
// notify inserted (new email located somewhere inside the local vector)
if (inserted_ids.size > 0) {
- debug("%s: Notifying of %d inserted emails since last opened", to_string(), inserted_ids.size);
+ debug("Notifying of %d inserted emails since last opened",
+ inserted_ids.size);
notify_email_inserted(inserted_ids);
-
+
count_change_reason |= Folder.CountChangeReason.INSERTED;
}
-
+
// notify inserted (new email located somewhere inside the local vector that had to be
// created, i.e. no portion was stored locally)
if (locally_inserted_ids.size > 0) {
- debug("%s: Notifying of %d locally inserted emails since last opened", to_string(),
- locally_inserted_ids.size);
+ debug("Notifying of %d locally inserted emails since last opened",
+ locally_inserted_ids.size);
notify_email_locally_inserted(locally_inserted_ids);
-
+
count_change_reason |= Folder.CountChangeReason.INSERTED;
}
-
+
// notify appended (new email added since the folder was last opened)
if (appended_ids.size > 0) {
- debug("%s: Notifying of %d appended emails since last opened", to_string(), appended_ids.size);
+ debug("Notifying of %d appended emails since last opened",
+ appended_ids.size);
notify_email_appended(appended_ids);
-
+
count_change_reason |= Folder.CountChangeReason.APPENDED;
}
-
- // notify locally appended (new email never seen before added since the folder was last
- // opened)
+
+ // notify locally appended (new email never seen before added
+ // since the folder was last opened)
if (locally_appended_ids.size > 0) {
- debug("%s: Notifying of %d locally appended emails since last opened", to_string(),
- locally_appended_ids.size);
+ debug("Notifying of %d locally appended emails since last opened",
+ locally_appended_ids.size);
notify_email_locally_appended(locally_appended_ids);
-
+
count_change_reason |= Folder.CountChangeReason.APPENDED;
}
-
+
if (count_change_reason != Folder.CountChangeReason.NONE) {
- debug("%s: Notifying of %Xh count change reason (%d remote messages)", to_string(),
- count_change_reason, remote_message_count);
+ debug("Notifying of %Xh count change reason (%d remote messages)",
+ count_change_reason, remote_message_count);
notify_email_count_changed(remote_message_count, count_change_reason);
}
- debug("%s: Completed normalize_folder", to_string());
+ debug("Completed normalize_folder");
}
/**
@@ -788,7 +793,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
this.remote_open_timer.start();
}
- debug("%s: Folder opened", to_string());
+ debug("Folder opened");
return true;
}
@@ -818,7 +823,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
private async void close_internal_locked(Folder.CloseReason local_reason,
Folder.CloseReason remote_reason,
Cancellable? cancellable) {
- debug("%s: Folder closing", to_string());
+ debug("Folder closing");
// Ensure we don't attempt to start opening a remote while
// closing
@@ -860,15 +865,13 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// Close the replay queues; if a "clean" close, flush pending
// operations so everything gets a chance to run; if forced
// close, drop everything outstanding
- debug("Closing replay queue for %s (flush_pending=%s): %s",
- to_string(), flush_pending.to_string(), this.replay_queue.to_string());
+ debug("Closing replay queue for (flush_pending=%s): %s",
+ flush_pending.to_string(), this.replay_queue.to_string());
try {
yield this.replay_queue.close_async(flush_pending);
- debug("Closed replay queue for %s: %s",
- to_string(), this.replay_queue.to_string());
+ debug("Closed replay queue: %s", this.replay_queue.to_string());
} catch (Error err) {
- debug("Error closing %s replay queue: %s",
- to_string(), err.message);
+ warning("Error closing replay queue: %s", err.message);
}
// Actually close the remote folder
@@ -893,7 +896,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// Notify waiting tasks
this.closed_semaphore.blind_notify();
- debug("%s: Folder closed", to_string());
+ debug("Folder closed");
}
/**
@@ -922,7 +925,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// Should only be called when remote_mutex is locked, i.e. use open_remote_session()
private async void open_remote_session_locked(Cancellable? cancellable) {
- debug("%s: Opening remote session", to_string());
+ debug("Opening remote session");
// Note that any IOError.CANCELLED errors caught below do not
// cause any error signals to be fired and do not force
@@ -1055,8 +1058,8 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// Use the session param rather than remote_session attr since
// it may not be available yet
int remote_count = session.folder.properties.email_total;
- debug("%s on_remote_appended: remote_count=%d appended=%d",
- to_string(), remote_count, appended);
+ debug("on_remote_appended: remote_count=%d appended=%d",
+ remote_count, appended);
// from the new remote total and the old remote total, glean the SequenceNumbers of the
// new email(s)
@@ -1081,7 +1084,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// Use the session param rather than remote_session attr since
// it may not be available yet
int remote_count = session.folder.properties.email_total;
- debug("%s on_remote_updated: remote_count=%d position=%s", to_string(),
+ debug("on_remote_updated: remote_count=%d position=%s",
remote_count, position.to_string());
this.replay_queue.schedule_server_notification(
@@ -1094,8 +1097,8 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// Use the session param rather than remote_session attr since
// it may not be available yet
int remote_count = session.folder.properties.email_total;
- debug("%s on_remote_removed: remote_count=%d position=%s",
- to_string(), remote_count, position.to_string());
+ debug("on_remote_removed: remote_count=%d position=%s",
+ remote_count, position.to_string());
// notify of removal to all pending replay operations
replay_queue.notify_remote_removed_position(position);
@@ -1468,7 +1471,7 @@ private class Geary.ImapEngine.MinimalFolder : Geary.Folder, Geary.FolderSupport
// Fetch e-mail from folder using force update, which will cause the cache to be bypassed
// and the latest to be gotten from the server (updating the cache in the process)
- debug("%s: fetching %d flags", this.to_string(), local_map.keys.size);
+ debug("Fetching %d flags", local_map.keys.size);
Gee.List<Geary.Email>? list_remote = yield list_email_by_sparse_id_async(
local_map.keys,
Email.Field.FLAGS,
diff --git a/src/engine/imap/api/imap-client-service.vala b/src/engine/imap/api/imap-client-service.vala
index e37b55eb..fbd86561 100644
--- a/src/engine/imap/api/imap-client-service.vala
+++ b/src/engine/imap/api/imap-client-service.vala
@@ -201,8 +201,7 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
// this, but it's easy and works for now
int attempts = 0;
while (this.all_sessions.size > 0) {
- debug("[%s] Waiting for client sessions to disconnect...",
- this.account.id);
+ debug("Waiting for client sessions to disconnect...");
Timeout.add(250, this.stop.callback);
yield;
@@ -271,8 +270,8 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
// Don't check_open(), it's valid for this to be called when
// is_running is false, that happens during mop-up
- debug("[%s] Returning session with %d of %d free",
- this.account.id, this.free_queue.size, this.all_sessions.size);
+ debug("Returning session with %d of %d free",
+ this.free_queue.size, this.all_sessions.size);
bool too_many_free = (
this.free_queue.size >= this.max_free_size &&
@@ -293,8 +292,8 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
try {
yield session.close_mailbox_async(pool_cancellable);
} catch (ImapError imap_error) {
- debug("[%s] Error attempting to close released session %s: %s",
- this.account.id, session.to_string(), imap_error.message);
+ debug("Error attempting to close released session %s: %s",
+ session.to_string(), imap_error.message);
free = false;
}
@@ -307,8 +306,7 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
}
if (free) {
- debug("[%s] Unreserving session %s",
- this.account.id, session.to_string());
+ debug("Unreserving session %s", session.to_string());
this.free_queue.send(session);
}
}
@@ -356,8 +354,7 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
});
this.free_queue.send(free);
} catch (Error err) {
- debug("[%s] Error adding new session to the pool: %s",
- this.account.id, err.message);
+ debug("Error adding new session to the pool: %s", err.message);
this.close_pool.begin();
}
}
@@ -385,8 +382,7 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
try {
yield remove_session_async(target);
} catch (Error err) {
- debug("[%s] Error removing unconnected session: %s",
- this.account.id, err.message);
+ debug("Error removing unconnected session: %s", err.message);
}
break;
@@ -424,7 +420,7 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
}
private async ClientSession create_new_authorized_session(Cancellable? cancellable) throws Error {
- debug("[%s] Opening new session", this.account.id);
+ debug("Opening new session");
ClientSession new_session = new ClientSession(remote);
// Listen for auth failures early so the client is notified if
@@ -455,8 +451,8 @@ internal class Geary.Imap.ClientService : Geary.ClientService {
try {
yield new_session.disconnect_async();
} catch (Error disconnect_err) {
- debug("[%s] Error disconnecting due to session initiation failure, ignored: %s",
- new_session.to_string(), disconnect_err.message);
+ debug("Error disconnecting due to session initiation failure, ignored: %s",
+ disconnect_err.message);
}
throw err;
diff --git a/src/engine/imap/transport/imap-deserializer.vala
b/src/engine/imap/transport/imap-deserializer.vala
index 13c7ecbe..a14855a6 100644
--- a/src/engine/imap/transport/imap-deserializer.vala
+++ b/src/engine/imap/transport/imap-deserializer.vala
@@ -252,7 +252,7 @@ public class Geary.Imap.Deserializer : BaseObject {
// wait for outstanding I/O to exit
yield closed_semaphore.wait_async();
- debug("[%s] Deserializer closed", to_string());
+ Logging.debug(Logging.Flag.DESERIALIZER, "[%s] Deserializer closed", to_string());
}
/**
@@ -808,7 +808,7 @@ public class Geary.Imap.Deserializer : BaseObject {
}
private uint on_eos() {
- debug("[%s] EOS", to_string());
+ Logging.debug(Logging.Flag.DESERIALIZER, "[%s] EOS", to_string());
// Per RFC 3501 7.1.5, we may get a EOS immediately after a
// BYE, so flush any message being processed.
@@ -828,7 +828,7 @@ public class Geary.Imap.Deserializer : BaseObject {
// only Cancellable allowed is internal used to notify when closed; all other errors should
// be reported
if (!(err is IOError.CANCELLED)) {
- debug("[%s] input error: %s", to_string(), err.message);
+ Logging.debug(Logging.Flag.DESERIALIZER, "[%s] input error: %s", to_string(), err.message);
receive_failure(err);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]