Skip to content
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

GH-2101: Disable report printing if verbosity of logger is Quiet #4148

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Cake.Cli/Hosts/BuildScriptHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private async Task<CakeReport> internalRunTargetAsync()

if (report != null && !report.IsEmpty)
{
_reportPrinter.Write(report);
_reportPrinter.Write(report, _log.Verbosity);
}

return report;
Expand Down
12 changes: 11 additions & 1 deletion src/Cake.Cli/Infrastructure/CakeSpectreReportPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,18 @@ public CakeSpectreReportPrinter(IAnsiConsole console)
}

/// <inheritdoc/>
public void Write(CakeReport report)
public void Write(CakeReport report, Verbosity verbosity)
{
if (report == null)
{
throw new ArgumentNullException(nameof(report));
}

if (verbosity <= Verbosity.Quiet)
{
return;
}

// Create a table
var table = new Table().Border(TableBorder.SimpleHeavy);
table.Width(100);
Expand Down
7 changes: 6 additions & 1 deletion src/Cake.Core/CakeReportPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,18 @@ public CakeReportPrinter(IConsole console, ICakeContext context)
}

/// <inheritdoc/>
public void Write(CakeReport report)
public void Write(CakeReport report, Verbosity verbosity)
{
if (report == null)
{
throw new ArgumentNullException(nameof(report));
}

if (verbosity <= Verbosity.Quiet)
{
return;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR @deniszykov! As you can see in this comment in the original issue we wouldn't want to change the semantics of the Quiet verbosity in order to hide the report - this means users don't have a way to suppress the log messages and see the report anymore.

Could you add a new command-line argument to Cake called --no-report that hides the report? (regardless of the Verbosity)

try
{
var maxTaskNameLength = 29;
Expand Down
3 changes: 2 additions & 1 deletion src/Cake.Core/ICakeReportPrinter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ public interface ICakeReportPrinter
/// Writes the specified report to a target.
/// </summary>
/// <param name="report">The report to write.</param>
void Write(CakeReport report);
/// <param name="verbosity">The <see cref="Verbosity"/> at which the report should be written.</param>
void Write(CakeReport report, Verbosity verbosity);

/// <summary>
/// Writes the specified lifecyle steps (i.e. Setup/TearDown) to a target.
Expand Down