-
Notifications
You must be signed in to change notification settings - Fork 11
Description
We create a logger for the FunctionsController at
Line 19 in 6cc8a94
| 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.