Skip to content

Consider making functions controller logging synchronous #343

@idg10

Description

@idg10

We create a logger for the FunctionsController at

private static readonly ILoggerFactory Log = LoggerFactory.Create(builder => builder.AddConsole());

The problem with using the normal console logging functionality is that they are invisible to SpecFlow. Microsoft's console logger carefully avoids blocking the caller, dumping all log operations to a queue which it then drains on a dedicated thread. This does not work well with how SpecFlow+NUnit captures output: they essentially redirect Console.Out in-process. The console logger's use of a worker thread to write things out deferred effectively bypasses that.

If we want logging to be visible in test results, it looks like we have to call Console.WriteLine synchronously. (It's odd that there isn't some less flaky mechanism—there is actually a tracing interface, but its implementation appears just to call Console.WriteLine, and in any case, it doesn't seem that we can get hold of that tracing API.)

We'd need to write a custom ILogger that does this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions