0x100 / stagelog

Annotated logging of the code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StageLog

Annotated logging of the code

build

Features

  • Logging of start and/or finish of method execution
  • Tracking time spent by the method

Using

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

How to add it in your project

Maven

  1. Add the jitpack repository in your pom.xml

    <repositories>
        <repository>
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>
    </repositories>
  2. Add the stagelog dependency

    <dependency>
        <groupId>com.github.0x100</groupId>
        <artifactId>stagelog</artifactId>
        <version>master-SNAPSHOT</version>
    </dependency>

Gradle

  1. Add the jitpack repository in your root build.gradle at the end of repositories:

    allprojects {
        repositories {
            // ...
            maven { url 'https://jitpack.io' }
        }
    }
  2. Add the dependency

    dependencies {
        implementation 'com.github.0x100:stagelog:master-SNAPSHOT'
    }

Examples

See examples in the code.

How to contribute

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!

About

Annotated logging of the code

License:MIT License


Languages

Language:Java 100.0%