Skip to content

Commit

Permalink
0.2.0 - logs optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mehillid committed Oct 30, 2024
1 parent 335a278 commit 5fa58ec
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 19 deletions.
18 changes: 9 additions & 9 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.
<dependency>
<groupId>com.github.qlsolutions.JavalinFly</groupId>
<artifactId>javalinfly-core</artifactId>
<version>0.1.10b2</version>
<version>0.2.0</version>
</dependency>
```

Expand All @@ -37,7 +37,7 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.
<annotationProcessorPath>
<groupId>com.github.qlsolutions.JavalinFly</groupId>
<artifactId>javalinfly-core</artifactId>
<version>0.1.10b2</version>
<version>0.2.0</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
Expand All @@ -51,7 +51,7 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.
<dependency>
<groupId>com.github.qlsolutions.JavalinFly</groupId>
<artifactId>javalinfly-kotlin</artifactId>
<version>0.1.10b2</version>
<version>0.2.0</version>
</dependency>
```

Expand All @@ -69,20 +69,20 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.
- Dependency

```groovy
implementation 'com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.10b2'
implementation 'com.github.qlsolutions.JavalinFly:javalinfly-core:0.2.0'
```

- Annotation processor

```groovy
annotationProcessor 'com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.10b2'
annotationProcessor 'com.github.qlsolutions.JavalinFly:javalinfly-core:0.2.0'
```

- <details>
<summary>Optionally also the kotlin module</summary>

```groovy
implementation 'com.github.qlsolutions.JavalinFly:javalinfly-kotlin:0.1.10b2'
implementation 'com.github.qlsolutions.JavalinFly:javalinfly-kotlin:0.2.0'
```

</details>
Expand All @@ -93,19 +93,19 @@ Make sure you include the <a href="https://jitpack.io/">repository</a> as well.

- Dependency
```groovy
implementation("com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.10b2")
implementation("com.github.qlsolutions.JavalinFly:javalinfly-core:0.2.0")
```

- Annotation processor
```groovy
annotationProcessor("com.github.qlsolutions.JavalinFly:javalinfly-core:0.1.10b2")
annotationProcessor("com.github.qlsolutions.JavalinFly:javalinfly-core:0.2.0")
```

- <details>
<summary>Optionally also the kotlin module</summary>

```groovy
implementation("com.github.qlsolutions.JavalinFly:javalinfly-kotlin:0.1.10b2")
implementation("com.github.qlsolutions.JavalinFly:javalinfly-kotlin:0.2.0")
```

</details>
Expand Down
2 changes: 1 addition & 1 deletion javalinfly-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.10b2</version>
<version>0.2.0</version>
</parent>

<artifactId>javalinfly-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package com.quicklink.javalinfly.annotation;



import io.javalin.security.RouteRole;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
Expand All @@ -17,6 +14,7 @@

boolean generateDocumentation() default true;

boolean logs() default false;


// Info info() default @Info();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ protected void run() {

javalinFlyInjectorAnn = annotatedElement.getAnnotation(JavalinFlyInjector.class);

if(javalinFlyInjectorAnn.logs()) {
Messager.enable();
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ public class Messager {

private static File file;

public static void set(javax.annotation.processing.Messager messager) {
Messager.messager = messager;
private static boolean logs = false;

public static void enable() {
logs = true;

file = new File("debug_compiler.txt");
try {
Expand All @@ -29,6 +31,10 @@ public static void set(javax.annotation.processing.Messager messager) {
}
}

public static void set(javax.annotation.processing.Messager messager) {
Messager.messager = messager;
}

private static void writeString(@NotNull String prefix, @Nullable Element e, @NotNull String msg, @NotNull Object... args) {
try {
Files.writeString(file.toPath(), String.format("%s (at %s) - %s", prefix, e, String.format(msg, args)), StandardOpenOption.APPEND);
Expand All @@ -38,6 +44,9 @@ private static void writeString(@NotNull String prefix, @Nullable Element e, @No
}

public static void error(@NotNull Element e, @NotNull String msg, @NotNull Object... args) {
if(!logs) {
return;
}

writeString("ERROR", e, msg, args);
messager.printMessage(Kind.ERROR, String.format(msg, args), e);
Expand All @@ -46,21 +55,37 @@ public static void error(@NotNull Element e, @NotNull String msg, @NotNull Objec
}

public static void error(@NotNull String msg, @NotNull Object... args) {
if(!logs) {
return;
}

writeString("WARNING", null, msg, args);
messager.printMessage(Kind.ERROR, String.format(msg, args));

}

public static void print(@NotNull String msg, @NotNull Object... args) {
if(!logs) {
return;
}

messager.printMessage(Kind.NOTE, String.format(msg, args));
}

public static void warning(@NotNull String msg, @NotNull Object... args) {
if(!logs) {
return;
}

writeString("WARNING", null, msg, args);
messager.printMessage(Kind.WARNING, String.format(msg, args));
}

public static void warning(@NotNull Element e, @NotNull String msg, @NotNull Object... args) {
if(!logs) {
return;
}

messager.printMessage(Kind.WARNING, String.format(msg, args), e);
}
}
2 changes: 1 addition & 1 deletion javalinfly-example-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.10b2</version>
<version>0.2.0</version>
</parent>

<artifactId>javalinfly-example-kotlin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion javalinfly-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.10b2</version>
<version>0.2.0</version>
</parent>

<artifactId>javalinfly-example</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion javalinfly-kotlin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.10b2</version>
<version>0.2.0</version>
</parent>

<artifactId>javalinfly-kotlin</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.unldenis</groupId>
<artifactId>JavalinFly</artifactId>
<version>0.1.10b2</version>
<version>0.2.0</version>
<packaging>pom</packaging>

<modules>
Expand Down

0 comments on commit 5fa58ec

Please sign in to comment.