Improve logging OUT-538
authorThomas
Fri, 01 Feb 2019 10:54:24 +0100
branchOUT-538
changeset 2562 3dbba3e9ed86
parent 2561 26c3a4099ae2
child 2567 c8842fc0a516
Improve logging
Extensions/MailItemExtensions.cs
ThisAddIn.cs
Wrappers/WatchedWindow.cs
--- a/Extensions/MailItemExtensions.cs	Fri Feb 01 09:57:03 2019 +0100
+++ b/Extensions/MailItemExtensions.cs	Fri Feb 01 10:54:24 2019 +0100
@@ -2011,7 +2011,7 @@
                 MsgProcessor processor = new MsgProcessor();
                 if (processor.ProcessSentMessage(message, Globals.ThisAddIn.Settings.ExtraKeys, out PEPMessage msg) != Globals.ReturnStatus.Success)
                 {
-                    Log.Error("ProcessOutgoing: Error processing message.");
+                    Log.Error("ProcessAndSendMessageAsync: Error processing message.");
                     sendError = true;
                     return null;
                 }
@@ -2045,13 +2045,13 @@
                 catch (Exception ex)
                 {
                     sendError = true;
-                    Log.Error("ProcessOutgoingAsync: Error sending message. " + ex.ToString());
+                    Log.Error("ProcessAndSendMessageAsync: Error sending message. " + ex.ToString());
                 }
             }
 
             if (sendError)
             {
-                Log.Error("Application_ItemSend: Send failure.");
+                Log.Error("ProcessAndSendMessageAsync: Send failure.");
                 bool cancel = false;
                 omi.Display();
 
@@ -2066,7 +2066,7 @@
                     cancel = (result != DialogResult.Yes);
                 }
 
-                Log.Info("Application_ItemSend: Error during sending. " + (cancel ? "User aborted sending." : "user chose to send mail unencrypted."));
+                Log.Info("ProcessAndSendMessageAsync: Error during sending. " + (cancel ? "User aborted sending." : "user chose to send mail unencrypted."));
 
                 if (cancel == false)
                 {
--- a/ThisAddIn.cs	Fri Feb 01 09:57:03 2019 +0100
+++ b/ThisAddIn.cs	Fri Feb 01 10:54:24 2019 +0100
@@ -445,7 +445,7 @@
                                     {
                                         SmtpAddress = address,
                                         IsSecureStorageEnabled = false,
-                                        IsSyncEnabled = false,                                        
+                                        IsSyncEnabled = false,
                                         Type = Outlook.OlAccountType.olExchange.ToString(),
                                         UserName = userName
                                     });
@@ -3333,6 +3333,7 @@
                     // If the message has already been processed, just send it out
                     if (processingState == MailItemExtensions.ProcessingState.Processed)
                     {
+                        Log.Verbose("Application_ItemSend: Message already processed. Sending directly...");
                         return;
                     }
 
@@ -3348,7 +3349,7 @@
                     else if (omi.GetIsForcefullyProtected())
                     {
                         // If ForceProtected, create special mail
-                        Log.Info("Sending forcefully protected message.");
+                        Log.Info("Application_ItemSend: Sending forcefully protected message.");
 
                         if (FPPMessage.ProcessOutgoing(omi) == Globals.ReturnStatus.Success)
                         {
@@ -3378,16 +3379,19 @@
                             {
                                 /* If the message was marked to be processed in the background, cancel the normal
                                  * send process and process the message further in the dedicated method.
-                                 */ 
+                                 */
                                 if (processingState == MailItemExtensions.ProcessingState.ProcessInBackground)
                                 {
                                     cancel = true;
+                                    Log.Verbose("Application_ItemSend: Canceling normal sending and initiating background processing.");
                                     omi.ProcessAndSendMessageAsync(message);
                                     return;
                                 }
                                 else
                                 {
                                     // Process outgoing message
+                                    Log.Verbose("Application_ItemSend: Normal processing.");
+
                                     MsgProcessor processor = new MsgProcessor();
                                     if (processor.ProcessSentMessage(message, Globals.ThisAddIn.Settings.ExtraKeys, out PEPMessage processedMessage) != Globals.ReturnStatus.Success)
                                     {
--- a/Wrappers/WatchedWindow.cs	Fri Feb 01 09:57:03 2019 +0100
+++ b/Wrappers/WatchedWindow.cs	Fri Feb 01 10:54:24 2019 +0100
@@ -1374,6 +1374,7 @@
                                                                                                 NativeMethods.SetWindowPosFlags.IgnoreResize |
                                                                                                 NativeMethods.SetWindowPosFlags.HideWindow);
                         this.CurrentMailItem.SetProcessingState(MailItemExtensions.ProcessingState.ProcessInBackground);
+                        Log.Verbose("MailItem_Send: Inspector window closed.");
                     }
 
                     // Set pEp options if needed