Skip to content

Commit

Permalink
#326: Reduced verbosity of logs for Info level
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpalme committed Mar 8, 2020
1 parent ad8156f commit 4c8d299
Show file tree
Hide file tree
Showing 32 changed files with 70 additions and 69 deletions.
1 change: 1 addition & 0 deletions src/Readme.txt
Expand Up @@ -66,6 +66,7 @@ CHANGELOG
4.5.1.0

* New: Issue #324: Removed image urls for HTML inline reports
* New: Issue #326: Reduced verbosity of logs for Info level

4.5.0.0

Expand Down
2 changes: 1 addition & 1 deletion src/ReportGenerator.Core/Parser/CloverParser.cs
Expand Up @@ -83,7 +83,7 @@ public ParserResult Parse(XContainer report)
/// <returns>The <see cref="Assembly"/>.</returns>
private Assembly ProcessAssembly(XElement[] modules, string assemblyName)
{
Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var files = modules
.Where(m => m.Attribute("name").Value.Equals(assemblyName))
Expand Down
2 changes: 1 addition & 1 deletion src/ReportGenerator.Core/Parser/CoberturaParser.cs
Expand Up @@ -96,7 +96,7 @@ public ParserResult Parse(XContainer report)
/// <returns>The <see cref="Assembly"/>.</returns>
private Assembly ProcessAssembly(XElement[] modules, string assemblyName)
{
Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var classNames = modules
.Where(m => m.Attribute("name").Value.Equals(assemblyName))
Expand Down
46 changes: 23 additions & 23 deletions src/ReportGenerator.Core/Parser/CoverageReportParser.cs
Expand Up @@ -159,9 +159,9 @@ private void MergeResults(ParserResult result1, ParserResult result2)
{
Interlocked.Increment(ref this.mergeCount);
int currentProgress = this.mergeCount;
Logger.InfoFormat(Resources.StartingMergingResult, currentProgress);
Logger.DebugFormat(Resources.StartingMergingResult, currentProgress);
result1.Merge(result2);
Logger.InfoFormat(Resources.FinishedMergingResult, currentProgress);
Logger.DebugFormat(Resources.FinishedMergingResult, currentProgress);
}

/// <summary>
Expand All @@ -183,7 +183,7 @@ private Task CreateProducer(IReadOnlyCollection<string> reportFiles, BlockingCol
reportFile =>
{
int number = Interlocked.Increment(ref counter);
Logger.InfoFormat(Resources.LoadingReport, reportFile, number, reportFiles.Count);
Logger.DebugFormat(Resources.LoadingReport, reportFile, number, reportFiles.Count);
try
{
string line1 = File.ReadLines(reportFile).First();
Expand All @@ -201,17 +201,17 @@ private Task CreateProducer(IReadOnlyCollection<string> reportFiles, BlockingCol
Logger.WarnFormat(Resources.ErrorCoverageFormat, reportFile);
}
Logger.InfoFormat(Resources.FinishedParsingFile, reportFile, number, reportFiles.Count);
Logger.DebugFormat(Resources.FinishedParsingFile, reportFile, number, reportFiles.Count);
}
catch (Exception ex) when (!(ex is UnsupportedParserException))
{
Logger.ErrorFormat(" " + Resources.ErrorDuringReadingReport, reportFile, GetHumanReadableFileSize(reportFile), ex.GetExceptionMessageForDisplay());
Logger.ErrorFormat(Resources.ErrorDuringReadingReport, reportFile, GetHumanReadableFileSize(reportFile), ex.GetExceptionMessageForDisplay());
}
});
}
finally
{
Logger.InfoFormat(Resources.ParsingCompleted, reportFiles.Count);
Logger.DebugFormat(Resources.ParsingCompleted, reportFiles.Count);
collection.CompleteAdding();
}
});
Expand Down Expand Up @@ -262,10 +262,10 @@ private IEnumerable<ParserResult> ParseXmlFile(string filePath)
{
foreach (var item in elements)
{
Logger.Debug(" " + Resources.PreprocessingReport);
Logger.Debug(Resources.PreprocessingReport);
new OpenCoverReportPreprocessor().Execute(item);

Logger.DebugFormat(" " + Resources.InitiatingParser, "OpenCover");
Logger.DebugFormat(Resources.InitiatingParser, "OpenCover");
yield return new OpenCoverParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);
}

Expand All @@ -278,10 +278,10 @@ private IEnumerable<ParserResult> ParseXmlFile(string filePath)
{
foreach (var item in elements)
{
Logger.Debug(" " + Resources.PreprocessingReport);
Logger.Debug(Resources.PreprocessingReport);
new DotCoverReportPreprocessor().Execute(item);

Logger.DebugFormat(" " + Resources.InitiatingParser, "dotCover");
Logger.DebugFormat(Resources.InitiatingParser, "dotCover");
yield return new DotCoverParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);
}

Expand All @@ -294,10 +294,10 @@ private IEnumerable<ParserResult> ParseXmlFile(string filePath)
{
foreach (var item in elements)
{
Logger.Debug(" " + Resources.PreprocessingReport);
Logger.Debug(Resources.PreprocessingReport);
new JaCoCoReportPreprocessor(this.sourceDirectories).Execute(item);

Logger.DebugFormat(" " + Resources.InitiatingParser, "JaCoCo");
Logger.DebugFormat(Resources.InitiatingParser, "JaCoCo");
var result = new JaCoCoParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);

foreach (var sourceDirectory in this.sourceDirectories)
Expand All @@ -319,15 +319,15 @@ private IEnumerable<ParserResult> ParseXmlFile(string filePath)
{
if (item.Attribute("profilerVersion") != null)
{
Logger.DebugFormat(" " + Resources.InitiatingParser, "NCover");
Logger.DebugFormat(Resources.InitiatingParser, "NCover");
yield return new NCoverParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);
}
else if (item.Attribute("clover") != null || item.Attribute("generated") != null)
{
Logger.Debug(" " + Resources.PreprocessingReport);
Logger.Debug(Resources.PreprocessingReport);
new CloverReportPreprocessor(this.sourceDirectories).Execute(item);

Logger.DebugFormat(" " + Resources.InitiatingParser, "Clover");
Logger.DebugFormat(Resources.InitiatingParser, "Clover");
var result = new CloverParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);

foreach (var sourceDirectory in this.sourceDirectories)
Expand All @@ -339,15 +339,15 @@ private IEnumerable<ParserResult> ParseXmlFile(string filePath)
}
else if (item.Attributes().Count() > 1)
{
Logger.Debug(" " + Resources.PreprocessingReport);
Logger.Debug(Resources.PreprocessingReport);
new CoberturaReportPreprocessor().Execute(item);

Logger.DebugFormat(" " + Resources.InitiatingParser, "Cobertura");
Logger.DebugFormat(Resources.InitiatingParser, "Cobertura");
yield return new CoberturaParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);
}
else
{
Logger.DebugFormat(" " + Resources.InitiatingParser, "mprof");
Logger.DebugFormat(Resources.InitiatingParser, "mprof");
yield return new MProfParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);
}
}
Expand All @@ -361,7 +361,7 @@ private IEnumerable<ParserResult> ParseXmlFile(string filePath)
{
foreach (var item in elements)
{
Logger.DebugFormat(" " + Resources.InitiatingParser, "Visual Studio");
Logger.DebugFormat(Resources.InitiatingParser, "Visual Studio");
new VisualStudioReportPreprocessor().Execute(item);

yield return new VisualStudioParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);
Expand All @@ -378,7 +378,7 @@ private IEnumerable<ParserResult> ParseXmlFile(string filePath)
{
if (item.Element("modules") != null)
{
Logger.DebugFormat(" " + Resources.InitiatingParser, "Dynamic Code Coverage");
Logger.DebugFormat(Resources.InitiatingParser, "Dynamic Code Coverage");
new DynamicCodeCoverageReportPreprocessor().Execute(item);

yield return new DynamicCodeCoverageParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(item);
Expand All @@ -404,16 +404,16 @@ private IEnumerable<ParserResult> ParseTextFile(string[] lines)

if (lines[0].StartsWith("TN:") || lines[0].StartsWith("SF:"))
{
Logger.DebugFormat(" " + Resources.InitiatingParser, "LCov");
Logger.DebugFormat(Resources.InitiatingParser, "LCov");

yield return new LCovParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(lines);
}
else if (lines[0].Contains(GCovParser.SourceElementInFirstLine))
{
Logger.Debug(" " + Resources.PreprocessingReport);
Logger.Debug(Resources.PreprocessingReport);
new GCovReportPreprocessor(this.sourceDirectories).Execute(lines);

Logger.DebugFormat(" " + Resources.InitiatingParser, "GCov");
Logger.DebugFormat(Resources.InitiatingParser, "GCov");
var result = new GCovParser(this.assemblyFilter, this.classFilter, this.fileFilter).Parse(lines);

foreach (var sourceDirectory in this.sourceDirectories)
Expand Down
2 changes: 1 addition & 1 deletion src/ReportGenerator.Core/Parser/DotCoverParser.cs
Expand Up @@ -88,7 +88,7 @@ public ParserResult Parse(XContainer report)
/// <returns>The <see cref="Assembly"/>.</returns>
private Assembly ProcessAssembly(XElement[] modules, XElement[] files, string assemblyName)
{
Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var assemblyElement = modules
.Where(m => m.Attribute("Name").Value.Equals(assemblyName));
Expand Down
Expand Up @@ -87,7 +87,7 @@ private Assembly ProcessAssembly(XElement module)
{
string assemblyName = module.Attribute("name").Value;

Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var classes = module
.Elements("functions")
Expand Down
Expand Up @@ -104,7 +104,7 @@ public string[] LoadFile(string path, out string error)
}
catch (Exception ex)
{
error = string.Format(CultureInfo.InvariantCulture, " " + Resources.ErrorDuringReadingFile, path, ex.GetExceptionMessageForDisplay());
error = string.Format(CultureInfo.InvariantCulture, Resources.ErrorDuringReadingFile, path, ex.GetExceptionMessageForDisplay());
return null;
}
}
Expand Down
Expand Up @@ -54,7 +54,7 @@ public string[] LoadFile(string path, out string error)
{
if (!File.Exists(path))
{
error = string.Format(CultureInfo.InvariantCulture, " " + Resources.FileDoesNotExist, path);
error = string.Format(CultureInfo.InvariantCulture, Resources.FileDoesNotExist, path);
return null;
}

Expand All @@ -66,7 +66,7 @@ public string[] LoadFile(string path, out string error)
}
catch (Exception ex)
{
error = string.Format(CultureInfo.InvariantCulture, " " + Resources.ErrorDuringReadingFile, path, ex.GetExceptionMessageForDisplay());
error = string.Format(CultureInfo.InvariantCulture, Resources.ErrorDuringReadingFile, path, ex.GetExceptionMessageForDisplay());
return null;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/ReportGenerator.Core/Parser/JaCoCoParser.cs
Expand Up @@ -81,7 +81,7 @@ public ParserResult Parse(XContainer report)
/// <returns>The <see cref="Assembly"/>.</returns>
private Assembly ProcessAssembly(XElement[] modules, string assemblyName)
{
Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var classNames = modules
.Where(m => m.Attribute("name").Value.Equals(assemblyName))
Expand Down
2 changes: 1 addition & 1 deletion src/ReportGenerator.Core/Parser/MProfParser.cs
Expand Up @@ -81,7 +81,7 @@ public ParserResult Parse(XContainer report)
/// <returns>The <see cref="Assembly"/>.</returns>
private Assembly ProcessAssembly(XElement[] methods, string assemblyName)
{
Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var classNames = methods
.Where(m => m.Attribute("assembly").Value.Equals(assemblyName))
Expand Down
2 changes: 1 addition & 1 deletion src/ReportGenerator.Core/Parser/NCoverParser.cs
Expand Up @@ -81,7 +81,7 @@ public ParserResult Parse(XContainer report)
/// <returns>The <see cref="Assembly"/>.</returns>
private Assembly ProcessAssembly(XElement[] modules, string assemblyName)
{
Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var classNames = modules
.Where(module => module.Attribute("assembly").Value.Equals(assemblyName))
Expand Down
2 changes: 1 addition & 1 deletion src/ReportGenerator.Core/Parser/OpenCoverParser.cs
Expand Up @@ -107,7 +107,7 @@ public ParserResult Parse(XContainer report)
/// <returns>The <see cref="Assembly"/>.</returns>
private Assembly ProcessAssembly(IDictionary<string, XElement[]> assemblyModules, XElement[] files, IDictionary<string, string> trackedMethods, string assemblyName)
{
Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var fileIdsByFilename = assemblyModules[assemblyName]
.Elements("Files")
Expand Down
Expand Up @@ -29,7 +29,7 @@ internal void Execute(XContainer report)
{
if (report.Descendants("packages").Elements("class").Any())
{
Logger.Error(" " + Resources.ErrorInvalidCoberturaReport);
Logger.Error(Resources.ErrorInvalidCoberturaReport);

// Fix malformed report files (See issues: #192, #209)
foreach (var packagesElement in report.Descendants("packages").ToArray())
Expand Down
2 changes: 1 addition & 1 deletion src/ReportGenerator.Core/Parser/VisualStudioParser.cs
Expand Up @@ -92,7 +92,7 @@ public ParserResult Parse(XContainer report)
/// <returns>The <see cref="Assembly"/>.</returns>
private Assembly ProcessAssembly(XElement[] modules, XElement[] files, string assemblyName)
{
Logger.DebugFormat(" " + Resources.CurrentAssembly, assemblyName);
Logger.DebugFormat(Resources.CurrentAssembly, assemblyName);

var classNames = modules
.Where(m => m.Element("ModuleName").Value.Equals(assemblyName))
Expand Down
Expand Up @@ -206,7 +206,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)
{
string targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, "badge_linecoverage.svg");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

File.WriteAllText(
targetPath,
Expand All @@ -216,7 +216,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)
{
targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, $"badge_shieldsio_linecoverage_{color.Item1}.svg");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

File.WriteAllText(
targetPath,
Expand All @@ -228,7 +228,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)
{
string targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, "badge_branchcoverage.svg");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

File.WriteAllText(
targetPath,
Expand All @@ -238,7 +238,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)
{
targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, $"badge_shieldsio_branchcoverage_{color.Item1}.svg");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

File.WriteAllText(
targetPath,
Expand All @@ -250,7 +250,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)
{
string targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, "badge_combined.svg");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

File.WriteAllText(
targetPath,
Expand All @@ -261,7 +261,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)
{
string targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, "badge_linecoverage.png");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

File.WriteAllBytes(
targetPath,
Expand All @@ -272,7 +272,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)
{
string targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, "badge_branchcoverage.png");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

File.WriteAllBytes(
targetPath,
Expand Down
Expand Up @@ -384,7 +384,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)

string targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, "Clover.xml");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

result.Save(targetPath);
}
Expand Down
Expand Up @@ -175,7 +175,7 @@ public void CreateSummaryReport(SummaryResult summaryResult)

string targetPath = Path.Combine(this.ReportContext.ReportConfiguration.TargetDirectory, "Cobertura.xml");

Logger.InfoFormat(" " + Resources.WritingReportFile, targetPath);
Logger.InfoFormat(Resources.WritingReportFile, targetPath);

result.Save(targetPath);
}
Expand Down

0 comments on commit 4c8d299

Please sign in to comment.