Annotated logging of the code
- Logging of start and/or finish of method execution
- Tracking time spent by the method
Just add the @Stagelog
annotation above a method with required parameters:
@Stage(startMessage = "Initialization...", finishMessage = "Initialization finished", trackTime = true)
private void init() {
loadConfig();
loadData();
applyConfig();
}
@Stage("Load config")
private void loadConfig() {
// ...
sleep(100);
}
@Stage(trackTime = true)
private void loadData() {
// ...
sleep(200);
}
@Stage(startMessage = "Apply config")
private void applyConfig() {
// ...
sleep(300);
}
Then build your app.
Result output:
Initialization...
Load config
Example.loadData()...
Example.loadData() finished in 00:00:00.206
Apply config
Initialization finished in 00:00:00.617
-
Add the
jitpack
repository in yourpom.xml
<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>
-
Add the
stagelog
dependency<dependency> <groupId>com.github.0x100</groupId> <artifactId>stagelog</artifactId> <version>master-SNAPSHOT</version> </dependency>
-
Add the
jitpack
repository in your rootbuild.gradle
at the end of repositories:allprojects { repositories { // ... maven { url 'https://jitpack.io' } } }
-
Add the dependency
dependencies { implementation 'com.github.0x100:stagelog:master-SNAPSHOT' }
See examples in the code.
Fork the repository, make changes, write a test for your code, send me a pull request. I will review your changes and apply them to the master branch shortly, provided they don't violate quality standards. To avoid frustration, before sending a pull request please run the Maven build:
$ mvn clean package
Good luck and have fun!