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

No clear path to set a custom logger #432

Open
ImaginaryDevelopment opened this issue Apr 26, 2022 · 1 comment
Open

No clear path to set a custom logger #432

ImaginaryDevelopment opened this issue Apr 26, 2022 · 1 comment

Comments

@ImaginaryDevelopment
Copy link

Maybe I'm just not having luck following the source code, but it appears to me that logging is service-located at https://github.com/haf/expecto/blob/main/Expecto/Expecto.Impl.fs#L15

I see no clear way to inject Serilog or any other LogProvider. The only example given in documentation appears to show how to get Logary to log into the Expecto logger, without anyway to hook up a custom logger for Expecto to use.

The motivating case might be simple enough to solve, I have dotnet watch test running, which appears to by default, print every single skipped test. I have over 400 tests, and I'm trying to REPL write a new section of 4 tests. so I put in ftestlist and proceed.
Each change I make I get ~10 lines of errors somewhere in the spam of 400 lines letting me know the name of every single test it skipped.

However I'd like to be able to solve the larger case of being able to hook a different log provider into Expecto.

@jwosty
Copy link
Contributor

jwosty commented Jul 11, 2023

It looks like Logary's adapter uses some reflection magic to pull this off: https://github.com/causiq/logary/blob/master/src/adapters/Logary.Adapters.Facade/Logary.Adapters.Facade.fs

I imagine it's hypothetically possible to write a different adapter that plugs into something else (i.e. Microsoft.Extensions.Logging), but that's probably easier said than done...

EDIT: Logger is an abstract class; there should be a way to provide your own implementation/adapter:

type Logger =

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants