nuke icon indicating copy to clipboard operation
nuke copied to clipboard

Cannot use outputFilter on a Tool when using .NET6 or newer

Open adusak opened this issue 3 years ago • 3 comments

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

adusak avatar May 17 '23 15:05 adusak

See https://github.com/nuke-build/nuke/issues/1169#issuecomment-1546957543

matkoch avatar May 19 '23 13:05 matkoch

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.

adusak avatar May 22 '23 10:05 adusak

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);
    }

rodion-m avatar May 15 '24 10:05 rodion-m