Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = 'fr.sandro642.github'
version = '0.3.3-STABLE'
version = '0.3.4-STABLE'

tasks.register('printVersion') {
doLast {
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ And if you thought APIs were complicated, think again! With ConnectLib, it's lik
---

```java
Stable Version: 0.3.3-STABLE
Stable Version: 0.3.4-STABLE
```

---
Expand Down Expand Up @@ -58,6 +58,7 @@ Changelog:
- [0.2.6.4-STABLE]: Added asynchronous job execution, allowing you to run tasks in the background without blocking your main application thread.
- [0.2.7.2-STABLE]: Remove implementation Project Reactor
- [0.2.9-STABLE]: Added support query variables in routes, allowing you to pass parameters directly in the URL.
- [0.3.3-STABLE]: Minecraft Version 1.16 - Latest Version support + LangType 2.0 - Remove AnnotHandler, you can use logger.showLogs(); to display logs.
```

---
Expand Down
145 changes: 0 additions & 145 deletions src/main/java/fr/sandro642/github/annotations/AnnotHandler.java

This file was deleted.

118 changes: 72 additions & 46 deletions src/main/java/fr/sandro642/github/misc/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,63 +5,89 @@
* It provides methods to log messages with different severity levels:
* INFO, WARN, ERROR, and CRITICAL.
*
* Use setShowLogs(true/false) to control console output.
* Logs are always saved to file regardless of the setting.
*
* @author Sandro642
* @version 1.0
*/

public class Logger {

private Logs logs = new Logs();
private Logs logs = new Logs();
private static boolean showLogs = false; // Default: logs are hidden

/**
* Enable console output for logs.
* Call this method once to display all logs in console.
* By default, logs are only saved to file without console output.
* Logs are always saved to file regardless of this setting.
*/
public void showLogs() {
showLogs = true;
}

/**
* Method to display an informational message in the console.
* This method prints the message in green color and logs it.
* @param msg
*/
public void INFO(String msg) {
// Green
String INFO = "\u001B[32m[INFO] \u001B[0m";
System.out.println(INFO + msg);
/**
* Method to display an informational message in the console.
* This method prints the message in green color if showLogs is enabled,
* and always logs it to file.
* @param msg The message to log
*/
public void INFO(String msg) {
if (showLogs) {
// Green
String INFO = "\u001B[32m[INFO] \u001B[0m";
System.out.println(INFO + msg);
}

logs.MakeALog(msg, "INFO");
}
logs.MakeALog(msg, "INFO");
}

/**
* Method to display a warning message in the console.
* This method prints the message in yellow color and logs it.
* @param msg
*/
public void WARN(String msg) {
// Yellow
String WARN = "\u001B[33m[WARN] \u001B[0m";
System.out.println(WARN + msg);
/**
* Method to display a warning message in the console.
* This method prints the message in yellow color if showLogs is enabled,
* and always logs it to file.
* @param msg The message to log
*/
public void WARN(String msg) {
if (showLogs) {
// Yellow
String WARN = "\u001B[33m[WARN] \u001B[0m";
System.out.println(WARN + msg);
}

logs.MakeALog(msg, "WARN");
}
logs.MakeALog(msg, "WARN");
}

/**
* Method to display an error message in the console.
* This method prints the message in red color and logs it.
* @param msg
*/
public void ERROR(String msg) {
// Red
String ERROR = "\u001B[31m[ERROR] \u001B[0m";
System.out.println(ERROR + msg);
/**
* Method to display an error message in the console.
* This method prints the message in red color if showLogs is enabled,
* and always logs it to file.
* @param msg The message to log
*/
public void ERROR(String msg) {
if (showLogs) {
// Red
String ERROR = "\u001B[31m[ERROR] \u001B[0m";
System.out.println(ERROR + msg);
}

logs.MakeALog(msg, "ERROR");
}
logs.MakeALog(msg, "ERROR");
}

/**
* Method to display a critical message in the console.
* This method prints the message in magenta color and logs it.
* @param msg
*/
public void CRITICAL(String msg) {
// Magenta
String CRITICAL = "\u001B[35m[CRITICAL] \u001B[0m";
System.out.println(CRITICAL + msg);
/**
* Method to display a critical message in the console.
* This method prints the message in magenta color if showLogs is enabled,
* and always logs it to file.
* @param msg The message to log
*/
public void CRITICAL(String msg) {
if (showLogs) {
// Magenta
String CRITICAL = "\u001B[35m[CRITICAL] \u001B[0m";
System.out.println(CRITICAL + msg);
}

logs.MakeALog(msg, "CRITICAL");
}
}
logs.MakeALog(msg, "CRITICAL");
}
}
8 changes: 5 additions & 3 deletions src/test/java/fr/sandro642/github/test/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import fr.sandro642.github.enums.ResourceType;
import fr.sandro642.github.enums.VersionType;
import fr.sandro642.github.misc.EnumLoader;
import fr.sandro642.github.misc.Logger;
import org.junit.jupiter.api.Test;

import java.util.Map;
Expand Down Expand Up @@ -49,12 +50,12 @@ public void initializeCAPI() {


public static void main(String[] args) {
connectLib.Init(ResourceType.TEST_RESOURCES, LangType.ENGLISH, TestRoutes.class);

connectLib.Init(ResourceType.TEST_RESOURCES, LangType.FRENCH, TestRoutes.class);
try {
connectLib.Logger().showLogs();

CompletableFuture<ApiFactory> apiFactoryCompletableFuture = connectLib.JobGetInfos()
.getRoutes(VersionType.V1_BRANCH, MethodType.GET, TestRoutes.HELLO)
.getRoutes( MethodType.GET, TestRoutes.HELLO)
.getResponse();

ApiFactory response = apiFactoryCompletableFuture.get(5, TimeUnit.SECONDS);
Expand All @@ -67,6 +68,7 @@ public static void main(String[] args) {
}
}


@Test
public void testUseFullRoute() {
connectLib.Init(ResourceType.TEST_RESOURCES, LangType.FRENCH, TestRoutes.class);
Expand Down