Skip to content

Add Diagnostic logging level for protocol message JSON #519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,20 @@ public async Task<Message> ReadMessage()

// Load the message
this.logger.Write(
LogLevel.Verbose,
LogLevel.Diagnostic,
string.Format(
"READ MESSAGE:\r\n\r\n{0}",
messageObject.ToString(Formatting.Indented)));

// Return the parsed message
return this.messageSerializer.DeserializeMessage(messageObject);
Message parsedMessage = this.messageSerializer.DeserializeMessage(messageObject);

this.logger.Write(
LogLevel.Verbose,
$"Received {parsedMessage.MessageType} '{parsedMessage.Method}'" +
(!string.IsNullOrEmpty(parsedMessage.Id) ? $" with id {parsedMessage.Id}" : string.Empty));

return parsedMessage;
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,14 @@ public async Task WriteMessage(Message messageToWrite)
this.messageSerializer.SerializeMessage(
messageToWrite);

// Log the JSON representation of the message
this.logger.Write(
LogLevel.Verbose,
$"Writing {messageToWrite.MessageType} '{messageToWrite.Method}'" +
(!string.IsNullOrEmpty(messageToWrite.Id) ? $" with id {messageToWrite.Id}" : string.Empty));

// Log the JSON representation of the message
this.logger.Write(
LogLevel.Diagnostic,
string.Format(
"WRITE MESSAGE:\r\n\r\n{0}",
JsonConvert.SerializeObject(
Expand Down
5 changes: 5 additions & 0 deletions src/PowerShellEditorServices/Utility/ILogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ namespace Microsoft.PowerShell.EditorServices.Utility
/// </summary>
public enum LogLevel
{
/// <summary>
/// Indicates a diagnostic log message.
/// </summary>
Diagnostic,

/// <summary>
/// Indicates a verbose log message.
/// </summary>
Expand Down