Skip to content

Commit

Permalink
Differentiate some warnings that aren't really warnings (#6476)
Browse files Browse the repository at this point in the history
* Differentiate some warnings that aren't really warnings

* Delegate error up to prevent fallbacks from failing
  • Loading branch information
ChadNedzlek authored Oct 27, 2020
1 parent 013ba8a commit b2cb6e5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 76 deletions.
10 changes: 6 additions & 4 deletions src/Microsoft.DotNet.Arcade.Sdk/src/DownloadFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ public override bool Execute()
return true;
}
}

Log.LogError($"Download from all targets failed. List of attempted targets: {string.Join(", ", Uris.Select(m => m.ItemSpec))}");
}

Log.LogWarning($"Failed to download file using addresses in {nameof(Uri)} and/or {nameof(Uris)}.");
Log.LogError($"Failed to download file using addresses in {nameof(Uri)} and/or {nameof(Uris)}.");

return false;
}
Expand All @@ -117,7 +119,7 @@ private async Tasks.Task<bool> DownloadFromUriAsync(string uri) {
{
if (e.InnerException is OperationCanceledException)
{
Log.LogError($"Download of '{uri}' to '{DestinationPath}' has been cancelled.");
Log.LogMessage($"Download of '{uri}' to '{DestinationPath}' has been cancelled.");
return false;
}

Expand Down Expand Up @@ -161,11 +163,11 @@ private async Tasks.Task<bool> DownloadWithRetriesAsync(HttpClient httpClient, s

if (attempt > Retries)
{
Log.LogWarning($"Failed to download '{uri}' to '{DestinationPath}'");
Log.LogMessage($"Failed to download '{uri}' to '{DestinationPath}': {e.Message}");
return false;
}

Log.LogWarning($"Retrying download of '{uri}' to '{DestinationPath}' due to failure: '{e.Message}' ({attempt}/{Retries})");
Log.LogMessage($"Retrying download of '{uri}' to '{DestinationPath}' due to failure: '{e.Message}' ({attempt}/{Retries})");

await Tasks.Task.Delay(RetryDelayMilliseconds).ConfigureAwait(false);
continue;
Expand Down
8 changes: 0 additions & 8 deletions src/Microsoft.DotNet.Helix/Sdk/LoggerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,6 @@ public static void LogErrorFromException(
}
}

public static void LogWarning(this TaskLoggingHelper log, FailureCategory category, string message, params object[] messageArgs)
{
using (EnterFailureCategoryScope(log, category))
{
log.LogWarning(message, messageArgs);
}
}

public struct FailureCategoryScope : IDisposable
{
private TaskLoggingHelper _log;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static async Task<int> Main(string[] args)
ServiceClientModel model = generator.Create(document);

var codeFactory = new ServiceClientCodeFactory();
List<CodeFile> code = codeFactory.GenerateCode(model, generatorOptions, logger);
List<CodeFile> code = codeFactory.GenerateCode(model, generatorOptions);

var outputDirectory = new DirectoryInfo(output);
outputDirectory.Create();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using HandlebarsDotNet;
using Microsoft.DotNet.SwaggerGenerator.Languages;
using Microsoft.DotNet.SwaggerGenerator.Modeler;
using Microsoft.Extensions.Logging;

namespace Microsoft.DotNet.SwaggerGenerator
{
Expand All @@ -19,17 +18,14 @@ public GenerateCodeContext(
ServiceClientModel clientModel,
GeneratorOptions options,
Templates templates,
Language language,
ILogger logger)
Language language)
{
_language = language;
ClientModel = clientModel;
Options = options;
Templates = templates;
Logger = logger;
}

public ILogger Logger { get; }
public ServiceClientModel ClientModel { get; }
public GeneratorOptions Options { get; }
public Templates Templates { get; }
Expand Down Expand Up @@ -62,7 +58,7 @@ public void WriteTemplate(string filePath, Template template, object context, bo

public class ServiceClientCodeFactory
{
public List<CodeFile> GenerateCode(ServiceClientModel model, GeneratorOptions options, ILogger logger)
public List<CodeFile> GenerateCode(ServiceClientModel model, GeneratorOptions options)
{
Language language = Language.Get(options.LanguageName);

Expand All @@ -74,7 +70,7 @@ public List<CodeFile> GenerateCode(ServiceClientModel model, GeneratorOptions op

RegisterTemplates(hb, templates);

var context = new GenerateCodeContext(model, options, templates, language, logger);
var context = new GenerateCodeContext(model, options, templates, language);
language.GenerateCode(context);

return context.Files.Values.ToList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private async System.Threading.Tasks.Task ExecuteAsync()

Log.LogMessage(MessageImportance.Low, $"Generating code files for language '{options.LanguageName}'");
var codeFactory = new ServiceClientCodeFactory();
List<CodeFile> code = codeFactory.GenerateCode(model, options, new MSBuildLogger(Log));
List<CodeFile> code = codeFactory.GenerateCode(model, options);

Log.LogMessage(MessageImportance.High, $"Generating {SwaggerDocumentUri} -> {OutputDirectory}");
var outputDirectory = new DirectoryInfo(OutputDirectory);
Expand Down

This file was deleted.

0 comments on commit b2cb6e5

Please sign in to comment.