Logging System

This commit is contained in:
NekoMonci12
2025-05-08 20:39:32 +07:00
parent 786b3223a2
commit 5c0f7dba3b
2 changed files with 54 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
package org.yuemi.yuelicenser;
package org.yuemi.feather;
// Bukkit
import org.bukkit.Bukkit;
@@ -9,21 +9,22 @@ import org.bukkit.event.EventHandler;
// PlaceholderAPI
//import me.clip.placeholderapi.PlaceholderAPI;
//import me.clip.placeholderapi.expansion.PlaceholderExpansion;
// YueMi
import org.yuemi.feather.functions.LoggerUtil;
public class Main extends JavaPlugin {
public enum LogType {
NONE, LOW, MEDIUM, HIGH
}
private LogType logType = LogType.LOW;
String pluginName = getDescription().getName();
@Override
public void onEnable() {
// Save the default config if it doesn't exist yet
saveDefaultConfig();
saveDefaultConfig(); // Save the default config if it doesn't exist yet
LoggerUtil.logs(1, "Enabling " + pluginName);
}
@Override
public void onDisable() {
// Implement Here
LoggerUtil.logs(1, "Disabling " + pluginName);
}
}

View File

@@ -0,0 +1,45 @@
package org.yuemi.feather.functions;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
/**
* Simple logger with numeric level input
*/
public class LoggerUtil {
/**
* Log message with numeric level:
* 1 = INFO, 2 = WARNING, 3 = ERROR, 4 = DEBUG
*/
public static void logs(int level, Object message) {
String msg = message.toString();
String prefix = "[FeatherUtils]";
String formattedMessage;
switch (level) {
case 1: // INFO
formattedMessage = String.format("%s %s%s", prefix, ChatColor.GREEN, msg);
Bukkit.getLogger().info(formattedMessage);
break;
case 2: // WARNING
formattedMessage = String.format("%s %s%s", prefix, ChatColor.YELLOW, msg);
Bukkit.getLogger().warning(formattedMessage);
break;
case 3: // ERROR
formattedMessage = String.format("%s %s%s", prefix, ChatColor.RED, msg);
Bukkit.getLogger().severe(formattedMessage);
break;
case 4: // DEBUG
formattedMessage = String.format("%s %s%s", prefix, ChatColor.GRAY, msg);
Bukkit.getLogger().info(formattedMessage);
break;
default:
// fallback to info if level wrong
formattedMessage = String.format("%s %s%s", prefix, ChatColor.GREEN, msg);
Bukkit.getLogger().info(formattedMessage);
break;
}
}
}