Usage Example
Usage Example
To create a log file and start saving logs, include the following code in your plugin:
@Override
public void onEnable() {
Plugin htgLoggersPlugin = getServer().getPluginManager().getPlugin("HTGLoggers");
if (htgLoggersPlugin instanceof HTGLoggers) {
HTGLoggersAPI.initialize((HTGLoggers) htgLoggersPlugin);
HTGLoggersAPI.createLogFile("MyPlugin");
HTGLoggersAPI.logToFile("Plugin started successfully!", "MyPlugin");
} else {
getLogger().log(Level.WARNING, "HTGLoggers plugin not found or incompatible!");
}
}
This will create a log file named MyPlugin-log.log
in the HTGLoggers data folder and log a startup message.
Log Levels
You can use different logging levels to categorize your logs:
INFO: General information logs.
WARNING: Warnings about potential issues.
ERROR: Errors that need immediate attention.
Example:
HTGLoggersAPI.log("This is an info message.");
HTGLoggersAPI.logToFile("This is a warning message!", "MyPlugin");
Last updated