Skip to content

Commit

Permalink
Improved: Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
Bram1903 committed Apr 25, 2024
1 parent d1af08b commit 236e3b1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.deathmotion.antihealthindicator.managers.CacheManager;
import com.deathmotion.antihealthindicator.managers.PacketManager;
import com.deathmotion.antihealthindicator.managers.UpdateManager;
import com.deathmotion.antihealthindicator.wrappers.PlatformLoggerWrapperImpl;
import com.deathmotion.antihealthindicator.wrappers.LogManager;
import com.deathmotion.antihealthindicator.wrappers.interfaces.Scheduler;
import com.github.retrooper.packetevents.PacketEvents;
import lombok.Getter;
Expand All @@ -34,7 +34,7 @@
@Getter
public abstract class AHIPlatform<P> {

private final PlatformLoggerWrapperImpl loggerWrapper = new PlatformLoggerWrapperImpl();
private final LogManager logManager = new LogManager();
protected Scheduler scheduler;
private CacheManager<P> cacheManager;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ private void compareVersions(List<Integer> currentVersion, List<Integer> latestV

private void printUpdateInfo(boolean printToConsole, String formattedVersion) {
if (printToConsole) {
platform.getLoggerWrapper().info("Found a new version " + formattedVersion);
platform.getLoggerWrapper().info(GITHUB_RELEASES_URL);
platform.getLogManager().info("Found a new version " + formattedVersion);
platform.getLogManager().info(GITHUB_RELEASES_URL);
}

if (shouldNotifyInGame()) {
Expand All @@ -136,10 +136,10 @@ private void printUpdateInfo(boolean printToConsole, String formattedVersion) {
* @param e An instance of IOException representing the occurred error.
*/
private void LogUpdateError(IOException e) {
platform.getLoggerWrapper().error("<--------------------------------------------------------------->");
platform.getLoggerWrapper().error("Failed to check for a new release!");
platform.getLoggerWrapper().error("Error message:\n" + e.getMessage());
platform.getLoggerWrapper().info(GITHUB_RELEASES_URL);
platform.getLoggerWrapper().error("<--------------------------------------------------------------->");
platform.getLogManager().error("<--------------------------------------------------------------->");
platform.getLogManager().error("Failed to check for a new release!");
platform.getLogManager().error("Error message:\n" + e.getMessage());
platform.getLogManager().info(GITHUB_RELEASES_URL);
platform.getLogManager().error("<--------------------------------------------------------------->");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,21 @@

package com.deathmotion.antihealthindicator.wrappers;

import com.deathmotion.antihealthindicator.wrappers.interfaces.LoggerWrapper;

import java.util.logging.Logger;

public final class PlatformLoggerWrapperImpl implements LoggerWrapper {
public final class LogManager {

private final Logger logger = Logger.getLogger("AntiHealthIndicator");

@Override
public void info(String message) {
logger.info(message);
}

@Override
public void warning(String message) {
logger.warning(message);
}

@Override
public void error(String message) {
logger.severe(message);
}

@Override
public void debug(String message) {
logger.fine(message);
}
}

This file was deleted.

0 comments on commit 236e3b1

Please sign in to comment.