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
Added tear down for log captor, small enhancements #12
Conversation
Hi @AkaZver Thank you and well discovered! I like the idea and also the implementation. |
95eaee7
to
cb9cc12
Compare
cb9cc12
to
0879a91
Compare
I see this is still present within the unit tests. Would it be possible for you to also change it there to diagnosticContext? |
0879a91
to
193594d
Compare
Fixed |
By the way, what is your opinion regarding clearing the listappender within the close method. I am not quite sure if we also should add that... I have the feeling that if we clear it there it will be picked up earlier by the garbage collector if needed. The downside is that the logs are not accessible anymore when the close method is called, but would that be an issue? What is your opinion regarding this enhancement? |
If you use static captor for multiple tests then If you prefer variable creation per test method using try-with-resources you won't have access to appender outside of the scope anyway, because captor will be already destroyed with all its content (or am I missing something?). |
Yes sounds good. No need to adjust something at that level |
193594d
to
c738de7
Compare
Thank you Vasiliy for this amazing PR! It looks good to me, let's merge it 🎉 |
Your changes are now available within version |
Hello!
I discovered that if you attach captor for class it will never be detached and could potentially affect other tests, because all appenders are still visible between tests.
So I decided to add a method to safely detach captor by direct call (maybe in
@AfterAll
) or via try-with-resources.Btw, all attached appenders had no name and you couldn't identify which one was attached by library.
Also I forgot to rename variable with MDC)
Thank you.