jsalinaspolo / logcapture Goto Github PK
View Code? Open in Web Editor NEWA testing library for asserting logging messages
License: MIT License
A testing library for asserting logging messages
License: MIT License
Hi,
Is there a migration document to upgrade from 1.2.2 to 1.3.0 for instance? As I am seeing many unrelated tests failing once I update the version.
I am using:
kotlin("jvm") version "1.8.22"
io.kotest version 5.3.1
testImplementation("org.logcapture:logcapture-core:1.2.2")
testImplementation("org.logcapture:logcapture-kotest:1.2.2")
Thanks
Hello there,
First, a big thank you for the library, as it's proving very useful in our test cases.
As stated in the title, is it currently possible to check for the log messages X times, for example, when logging as part of a loop?
I'm going through the source code, but I have not found anything related to this.
Regards
The logged method returns void, so can concatenated logged assertions.
@jsalinaspolo
Not sure if this has been raised before, but is there away to have the same APIs but return a boolean instead?
So instead of
logged(aLog().info().withMessage("a message"))
maybe something like
isLogged(aLog().info().withMessage("a message")) == true
The reason is that this will give more flexibility to work with other frameworks like kotest where I can have a precondition like
until(10.seconds) {
isLogged(aLog().info().withMessage("a message"))
}
Do let me know if this is something we can have or not.
Thanks.
Hi guys, really cool to see that you all have been working on this. Without knowing of the existence of this project I have built something similar to the core module of this project... Maybe we can share some knowledge to learn from each-others solutions, see here: https://github.com/Hakky54/log-captor
But the main reason why I opened this issue is when I tried to understand the underlying core engine of the logcapture, I see that every log will be added to the Stubappender
which is a custom implementation of an appender
containing a list. The Stubappender
has an additional method called events()
which will return the iloggingevents. In this way the logs can be retrieved and asserted. There is already a ListAppender
available within Logback, and I am using it in my library, which is capable of doing the same as the Stubappender and much more. So I am wondering why you guys preferred to use a custom Appender instead of the ListAppender. Looking forward to get your thoughts on this topic ๐
This issue provides visibility into Renovate updates and their statuses. Learn more
These updates have all been created already. Click a checkbox below to force a retry/rebase of any.
These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.
Using the DSL is possible to verify async logs, so using the JUnitRules should be possible as well.
Instead of throwing a RuntimeException with the log message not found, would be helpful to display the logs captured.
Investigate usage of hamcrest matchers or logback custom Filters.
Should support assert on message using the log format replacing {} with the arguments.
Let's say I have something like this in my production code:
var username = "fred";
MDC.put("user", username);
logger.warn("The user " + username + " has requested xyz");
I would like to be able to check that the message contains a string that matches a certain MDC key:
logCaptureListener.logged(aLog().withMdc("user", ???).withMessage(Mathers.containsString(<whatever was in Mdc>));
Perhaps this feature can be delivered in a similar way to Mockito's or Mockk's "capture" facitilities.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.