Last version: 0.0.2
TODO
- Simple log method call using method name, return value and total execution time
@Loggable
public static int example1() {
return 42;
}
log output:
12:10:03.870 [main] INFO org.smartlog.ExampleAspect - example1 - [42], trace: [] [1 ms]
- Auto log uncaught exception
@Loggable
public static void example2() {
throw new RuntimeException("example uncaught exception");
}
log output:
14:55:08.885 [main] ERROR org.smartlog.ExampleAspect - example2 - [java.lang.RuntimeException: example uncaught exception], trace: [] [0 ms]
java.lang.RuntimeException: example uncaught exception
at org.smartlog.ExampleAspect.example2(ExampleAspect.java:21)
at org.smartlog.ExampleAspect.main(ExampleAspect.java:61)
- Custom title, result and trace
import static org.smartlog.TraceFlag.MARK_TIME;
import static org.smartlog.TraceFlag.WRITE_TIME;
@Loggable
public static void example3() {
SmartLog.title("Custom title");
SmartLog.trace(MARK_TIME, "make request to...");
// request remote server
SmartLog.trace(WRITE_TIME, "got result %d", 42);
SmartLog.trace("try parse");
// parse
SmartLog.trace("ok");
SmartLog.result("custom result");
}
log output:
15:07:50.918 [main] INFO org.smartlog.ExampleAspect - Custom title - [custom result], trace: [make request to...; got result 42 [2 ms]; try parse; ok] [8 ms]
<dependencies>
<dependency>
<groupId>io.github.ivnik</groupId>
<artifactId>smartlog</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>io.github.ivnik</groupId>
<artifactId>smartlog</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.10</version>
<configuration>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<aspectLibraries>
<aspectLibrary>
<groupId>io.github.ivnik</groupId>
<artifactId>smartlog-aop</artifactId>
<version>0.0.2</version>
</aspectLibrary>
</aspectLibraries>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>