Fixing up error logging

Fixing issue where plaintext passwords could be written to logs
Fixing up todo issues where error events needed to be passed back from the
service layer when the hosting component fails.
This commit is contained in:
Benjamin Russell
2016-08-12 17:38:41 -07:00
parent ba144bd5d0
commit 1acc8c9122
4 changed files with 34 additions and 8 deletions

View File

@@ -0,0 +1,28 @@
//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol.Contracts;
namespace Microsoft.SqlTools.ServiceLayer.Hosting.Contracts
{
/// <summary>
/// Parameters to be used for reporting hosting-level errors, such as protocol violations
/// </summary>
public class HostingErrorParams
{
/// <summary>
///
/// </summary>
public string Message { get; set; }
}
public class HostingErrorEvent
{
public static readonly
EventType<HostingErrorParams> Type =
EventType<HostingErrorParams>.Create("hostingError");
}
}

View File

@@ -243,6 +243,11 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting.Protocol
// previous message. In this case, do not try to dispatch it.
if (newMessage != null)
{
// Verbose logging
string logMessage = String.Format("Received message of type[{0}] and method[{1}]",
newMessage.MessageType, newMessage.Method);
Logger.Write(LogLevel.Verbose, logMessage);
// Process the message
await this.DispatchMessage(newMessage, this.MessageWriter);
}

View File

@@ -112,13 +112,6 @@ namespace Microsoft.SqlTools.ServiceLayer.Hosting.Protocol
// Get the JObject for the JSON content
JObject messageObject = JObject.Parse(messageContent);
// Load the message
Logger.Write(
LogLevel.Verbose,
string.Format(
"READ MESSAGE:\r\n\r\n{0}",
messageObject.ToString(Formatting.Indented)));
// Return the parsed message
return this.messageSerializer.DeserializeMessage(messageObject);
}

View File

@@ -6,7 +6,7 @@
using System.Threading.Tasks;
using Microsoft.SqlTools.ServiceLayer.Hosting.Protocol;
namespace Microsoft.SqlTools.ServiceLayer.Test.Message
namespace Microsoft.SqlTools.ServiceLayer.Test.Messaging
{
#region Request Types