add additional debug output
This commit is contained in:
Родитель
57382d5dc0
Коммит
8430da62cb
|
@ -271,7 +271,9 @@ namespace Azure.Sdk.Tools.TestProxy.Tests
|
|||
"Body differences:" + Environment.NewLine +
|
||||
"Request and record bodies do not match at index 40:" + Environment.NewLine +
|
||||
" request: \"e and long.\"" + Environment.NewLine +
|
||||
" record: \"e and long but it also doesn't\"" + Environment.NewLine,
|
||||
" record: \"e and long but it also doesn't\"" + Environment.NewLine +
|
||||
"Remaining Unmatched Entries:" + Environment.NewLine +
|
||||
" -> http://remote-host" + Environment.NewLine,
|
||||
exception.Message);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Azure.Sdk.Tools.TestProxy.CommandOptions;
|
||||
|
||||
namespace Azure.Sdk.Tools.TestProxy.Common
|
||||
{
|
||||
|
@ -31,6 +32,8 @@ namespace Azure.Sdk.Tools.TestProxy.Common
|
|||
// internal for testing
|
||||
internal static ILogger Logger { get; set; }
|
||||
|
||||
private static string LogMode { get; set; }
|
||||
|
||||
public static void ConfigureLogger(ILoggerFactory factory)
|
||||
{
|
||||
if (Logger == null && factory != null)
|
||||
|
@ -39,6 +42,11 @@ namespace Azure.Sdk.Tools.TestProxy.Common
|
|||
}
|
||||
}
|
||||
|
||||
public static void ConfigureLoggerVerboseLevel(DefaultOptions defaultOptions)
|
||||
{
|
||||
LogMode = "VerboseSanitizer";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Used to retrieve the final log level setting. This is a "runtime" setting that is checking the result AFTER
|
||||
/// accounting for launchSettings, appSettings, and environment variable settings.
|
||||
|
@ -215,5 +223,11 @@ namespace Azure.Sdk.Tools.TestProxy.Common
|
|||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static void LogVerbose(string output)
|
||||
{
|
||||
// todo: add recognition of modes from startup
|
||||
System.Console.WriteLine(output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
using Azure.Core;
|
||||
|
@ -127,7 +127,7 @@ namespace Azure.Sdk.Tools.TestProxy.Common
|
|||
}
|
||||
}
|
||||
|
||||
throw new TestRecordingMismatchException(GenerateException(request, bestScoreEntry));
|
||||
throw new TestRecordingMismatchException(GenerateException(request, bestScoreEntry, entries));
|
||||
}
|
||||
|
||||
public virtual int CompareBodies(byte[] requestBody, byte[] recordBody, StringBuilder descriptionBuilder = null)
|
||||
|
@ -213,7 +213,7 @@ namespace Azure.Sdk.Tools.TestProxy.Common
|
|||
return req.ToUri().ToString();
|
||||
}
|
||||
|
||||
private string GenerateException(RecordEntry request, RecordEntry bestScoreEntry)
|
||||
private string GenerateException(RecordEntry request, RecordEntry bestScoreEntry, IList<RecordEntry> entries)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.AppendLine($"Unable to find a record for the request {request.RequestMethod} {request.RequestUri}");
|
||||
|
@ -244,6 +244,20 @@ namespace Azure.Sdk.Tools.TestProxy.Common
|
|||
|
||||
CompareBodies(request.Request.Body, bestScoreEntry.Request.Body, builder);
|
||||
|
||||
// todo: enable MODES here?
|
||||
if (entries != null && entries.Count > 0)
|
||||
{
|
||||
builder.AppendLine("Remaining Unmatched Entries:");
|
||||
foreach(var entry in entries)
|
||||
{
|
||||
builder.AppendLine($" -> {entry.RequestUri}");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
builder.AppendLine("There were no entries remaining to be matched against.");
|
||||
}
|
||||
|
||||
return builder.ToString();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
@ -49,7 +49,11 @@ namespace Azure.Sdk.Tools.TestProxy.Common
|
|||
/// <returns>An updated value of the input string, with replacement operations completed if necessary.</returns>
|
||||
public static string ReplaceValue(string inputValue, string targetValue, string replacementValue)
|
||||
{
|
||||
return inputValue.Replace(targetValue, replacementValue);
|
||||
var result = inputValue.Replace(targetValue, replacementValue);
|
||||
|
||||
DebugLogger.LogVerbose($"String Sanitized Applied:\nBefore: \n{inputValue}\nAfter: \n{result}");
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -112,6 +116,11 @@ namespace Azure.Sdk.Tools.TestProxy.Common
|
|||
replacement = rx.Replace(inputValue, replacementValue);
|
||||
}
|
||||
|
||||
if (regex != null)
|
||||
{
|
||||
DebugLogger.LogVerbose($"Regex \"{regex??"N/A"}\" Applied:\nBefore:\n{inputValue}\nAfter:\n{replacement}");
|
||||
}
|
||||
|
||||
return replacement;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,6 +76,8 @@ namespace Azure.Sdk.Tools.TestProxy
|
|||
DefaultStore = Resolver.ResolveStore(defaultOptions.StoragePlugin ?? "GitStore");
|
||||
var assetsJson = string.Empty;
|
||||
|
||||
DebugLogger.ConfigureLoggerVerboseLevel(defaultOptions);
|
||||
|
||||
switch (commandObj)
|
||||
{
|
||||
case ConfigLocateOptions configOptions:
|
||||
|
|
Загрузка…
Ссылка в новой задаче