Cannot use outputFilter on a Tool when using .NET6 or newer
Usage Information
7.0.1
Description
outputFilter not declared on Tool delegate when using .NET 6 or newer
Reproduction Steps
[PathVariable("mytool")]
public Tool MyTool;
MyTool("do stuff", outputFilter: log => log.Contains("line I want completely removed") ? null : log);
Expected Behavior
I would like to be able to use the func for filtering/modifying the tool output.
Actual Behavior
outputFilter not declared on Tool delegate when using .NET 6 or newer
Regression?
yes it worked in 7.0.0
Known Workarounds
No response
Could you help with a pull-request?
Yes
See https://github.com/nuke-build/nuke/issues/1169#issuecomment-1546957543
I saw that issue, and while that is great for redacting secrets it does not really help with what I am trying to achieve.
I am using a cli tool that is logging ton of useless text. And I wanted to filter out some of the messages (whole log lines) which I previously did with the output filter.
I would be glad to try and tackle this via a PR, but I understand if you don't want to solve it this way.
It's possible to use a custom log function for this purpose, based on the default logger, for example:
public static void DefaultLogger(OutputType type, string output)
{
// here you can inject the filter...
if (type == OutputType.Std)
Log.Debug(output);
else
Log.Error(output);
}