diff --git a/CSExeCOMServer/TypeLib.cs b/CSExeCOMServer/TypeLib.cs index ecb91b6..9cad16d 100644 --- a/CSExeCOMServer/TypeLib.cs +++ b/CSExeCOMServer/TypeLib.cs @@ -10,38 +10,34 @@ internal static class TypeLib { public static void Register(string tlbPath) { - Trace.WriteLine($"Registering type library:"); - Trace.Indent(); - Trace.WriteLine(tlbPath); - Trace.Unindent(); + Trace.TraceInformation($"Registering type library:"); + Trace.TraceInformation(tlbPath); ComTypes.ITypeLib typeLib; int hr = OleAut32.LoadTypeLibEx(tlbPath, OleAut32.REGKIND.REGKIND_NONE, out typeLib); if (hr < 0) { - Trace.WriteLine($"Registering type library failed: 0x{hr:x}"); + Trace.TraceError($"Registering type library failed: 0x{hr:x}"); return; } hr = OleAut32.RegisterTypeLibForUser(typeLib, tlbPath, string.Empty); if (hr < 0) { - Trace.WriteLine($"Registering type library failed: 0x{hr:x}"); + Trace.TraceError($"Registering type library failed: 0x{hr:x}"); return; } - Trace.WriteLine($"Registering type library succeeded."); + Trace.TraceInformation($"Registering type library succeeded."); } public static void Unregister(string tlbPath) { - Trace.WriteLine($"Unregistering type library:"); - Trace.Indent(); - Trace.WriteLine(tlbPath); - Trace.Unindent(); + Trace.TraceInformation($"Unregistering type library:"); + Trace.TraceInformation(tlbPath); ComTypes.ITypeLib typeLib; int hr = OleAut32.LoadTypeLibEx(tlbPath, OleAut32.REGKIND.REGKIND_NONE, out typeLib); if (hr < 0) { - Trace.WriteLine($"Unregistering type library failed: 0x{hr:x}"); + Trace.TraceError($"Unregistering type library failed: 0x{hr:x}"); return; } @@ -55,7 +51,7 @@ public static void Unregister(string tlbPath) hr = OleAut32.UnRegisterTypeLib(ref attr.guid, attr.wMajorVerNum, attr.wMinorVerNum, attr.lcid, attr.syskind); if (hr < 0) { - Trace.WriteLine($"Unregistering type library failed: 0x{hr:x}"); + Trace.TraceError($"Unregistering type library failed: 0x{hr:x}"); } } } diff --git a/CSExeCOMServer/app.config b/CSExeCOMServer/app.config index 7d05e3c..18705f3 100644 --- a/CSExeCOMServer/app.config +++ b/CSExeCOMServer/app.config @@ -19,4 +19,12 @@ + + + + + + + + diff --git a/PresenceProvider/Mattermost/Client.cs b/PresenceProvider/Mattermost/Client.cs index 3e0b651..3d61eb3 100644 --- a/PresenceProvider/Mattermost/Client.cs +++ b/PresenceProvider/Mattermost/Client.cs @@ -54,7 +54,7 @@ private void UpdateURLs() _serverUrl = GetValueFromConfig(Constants.MattermostServerURL); if (_secret == string.Empty || _serverUrl == string.Empty) { - Trace.WriteLine("Invalid server url or secret."); + Trace.TraceError("Invalid server url or secret."); throw new Exception("Invalid server url or secret."); } _pluginUrl = new Uri($"{_serverUrl}/plugins/{Constants.PluginId}/api/v1/"); @@ -90,7 +90,7 @@ private void InitializeStore() } } catch (Exception ex) { - Trace.WriteLine(ex.StackTrace); + Trace.TraceError(ex.StackTrace); } } @@ -104,11 +104,11 @@ private void InitializeWebsocketClientInNewThread() // Wait for the websocket client "_wsClient" to get initialized by the other thread running parallely while (_wsClient == null) ; - Trace.WriteLine("Websocket client connected."); + Trace.TraceInformation("Websocket client connected."); } catch (Exception ex) { - Trace.WriteLine("ERROR: " + ex.ToString()); + Trace.TraceError("ERROR: " + ex.ToString()); } } @@ -126,12 +126,12 @@ private void InitializeWebsocketClient() client.ReconnectTimeout = TimeSpan.FromSeconds(wsTimeout); client.ReconnectionHappened.Subscribe(info => { - Trace.WriteLine("Reconnection happened, type: " + info.Type); + Trace.TraceInformation("Reconnection happened, type: " + info.Type); }); client.DisconnectionHappened.Subscribe(info => { - Trace.WriteLine("Disconnection happened, type: " + info.Type); + Trace.TraceInformation("Disconnection happened, type: " + info.Type); if (info.Type == DisconnectionType.Error || info.Type == DisconnectionType.ByServer) { throw new Exception("Error in connecting to websocket server."); @@ -142,7 +142,7 @@ private void InitializeWebsocketClient() _wsClient = client; mre.WaitOne(); - Trace.WriteLine("Websocket client closed."); + Trace.TraceInformation("Websocket client closed."); } private string GetValueFromConfig(string key) @@ -164,7 +164,7 @@ private string GetValueFromConfig(string key) return configNode[key].GetValue(); } catch (Exception ex) { - Trace.WriteLine(ex.Message); + Trace.TraceError(ex.Message); return string.Empty; } } diff --git a/PresenceProvider/OtherInterfaces/IMClientAsyncOperation.cs b/PresenceProvider/OtherInterfaces/IMClientAsyncOperation.cs index 97abc3d..8832f7b 100644 --- a/PresenceProvider/OtherInterfaces/IMClientAsyncOperation.cs +++ b/PresenceProvider/OtherInterfaces/IMClientAsyncOperation.cs @@ -13,7 +13,7 @@ public IMClientAsyncOperation() public void CancelOperation() { - Trace.WriteLine("Operation cancelled"); + Trace.TraceInformation("Operation cancelled"); } private dynamic _asyncState; diff --git a/PresenceProvider/OtherInterfaces/IMClientContact.cs b/PresenceProvider/OtherInterfaces/IMClientContact.cs index 4a9e2f2..818f656 100644 --- a/PresenceProvider/OtherInterfaces/IMClientContact.cs +++ b/PresenceProvider/OtherInterfaces/IMClientContact.cs @@ -107,7 +107,7 @@ public object GetContactInformation(ContactInformationType _contactInformationTy } } catch (Exception ex) { - Trace.WriteLine(ex.StackTrace); + Trace.TraceError(ex.StackTrace); return null; } } @@ -175,7 +175,7 @@ public void RaiseOnContactInformationChangedEvent(ContactInformationChangedEvent handler(this, _eventData); } catch (Exception ex) { - Trace.WriteLine(ex.StackTrace); + Trace.TraceError(ex.StackTrace); } } } diff --git a/PresenceProvider/OtherInterfaces/IMClientContactManager.cs b/PresenceProvider/OtherInterfaces/IMClientContactManager.cs index 89a8c1f..29489fb 100644 --- a/PresenceProvider/OtherInterfaces/IMClientContactManager.cs +++ b/PresenceProvider/OtherInterfaces/IMClientContactManager.cs @@ -84,7 +84,7 @@ public AsynchronousOperation Lookup(string _lookupString, object _contactsAndGro callback.OnLookup(this, null, asyncOperation); } catch (Exception ex) { - Trace.WriteLine(ex.StackTrace); + Trace.TraceError(ex.StackTrace); } return asyncOperation; } diff --git a/PresenceProvider/PresenceProvider.cs b/PresenceProvider/PresenceProvider.cs index df885c9..009bfae 100644 --- a/PresenceProvider/PresenceProvider.cs +++ b/PresenceProvider/PresenceProvider.cs @@ -1,5 +1,4 @@ - -#region Using directives +#region Using directives using System; using System.Diagnostics; using System.Runtime.InteropServices; @@ -35,7 +34,7 @@ public static void Register(Type t) } catch (Exception ex) { - Trace.WriteLine(ex.StackTrace); // Log the error + Trace.TraceError(ex.StackTrace); // Log the error throw ex; // Re-throw the exception } }