From 59674ed29c6b2c7e8ac98fc4f0f4fd4fd6d437c9 Mon Sep 17 00:00:00 2001 From: Keuin Date: Fri, 24 Apr 2020 13:10:00 +0800 Subject: Implemented uniformed console output (log4j) in PrintUtil. --- .../com/keuin/kbackupfabric/operation/DeleteOperation.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java') diff --git a/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java index 1e28324..be7734d 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/DeleteOperation.java @@ -1,10 +1,9 @@ package com.keuin.kbackupfabric.operation; +import com.keuin.kbackupfabric.util.PrintUtil; import com.mojang.brigadier.context.CommandContext; import net.minecraft.server.MinecraftServer; import net.minecraft.server.command.ServerCommandSource; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import java.io.File; import java.io.IOException; @@ -15,9 +14,9 @@ import static com.keuin.kbackupfabric.util.PrintUtil.msgErr; import static com.keuin.kbackupfabric.util.PrintUtil.msgInfo; import static org.apache.commons.io.FileUtils.forceDelete; -class DeleteOperation extends Confirmable { +class DeleteOperation extends AbstractConfirmableOperation { - private static final Logger LOGGER = LogManager.getLogger(); + //private static final Logger LOGGER = LogManager.getLogger(); private final String backupName; private final CommandContext context; @@ -30,13 +29,13 @@ class DeleteOperation extends Confirmable { public boolean confirm() { MinecraftServer server = context.getSource().getMinecraftServer(); String backupFileName = getBackupFileName(backupName); - LOGGER.info("Deleting backup " + backupName); + PrintUtil.info("Deleting backup " + backupName); File backupFile = new File(getBackupSaveDirectory(server), backupFileName); int tryCounter = 0; do { if (tryCounter == 5) { String msg = "Failed to delete file " + backupFileName; - LOGGER.error(msg); + PrintUtil.error(msg); msgErr(context, msg); return false; } @@ -47,7 +46,7 @@ class DeleteOperation extends Confirmable { } ++tryCounter; } while (backupFile.exists()); - LOGGER.info("Deleted backup " + backupName); + PrintUtil.info("Deleted backup " + backupName); msgInfo(context, "Deleted backup " + backupName); return true; } -- cgit v1.2.3