Replace logging with Log4j
Used to be logged with `System.out.println`
This commit is contained in:
parent
d43be9b51e
commit
2056f44b43
2 changed files with 20 additions and 22 deletions
|
|
@ -1,5 +1,8 @@
|
|||
package com.axolotlmaid.optionsprofiles;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
|
@ -7,6 +10,7 @@ import java.nio.file.Paths;
|
|||
|
||||
public class OptionsProfilesMod {
|
||||
public static final String MOD_ID = "optionsprofiles";
|
||||
public static final Logger LOGGER = LogManager.getLogger("Options Profiles");
|
||||
|
||||
public static void init() {
|
||||
Path profilesDirectory = Paths.get("options-profiles");
|
||||
|
|
@ -15,8 +19,7 @@ public class OptionsProfilesMod {
|
|||
try {
|
||||
Files.createDirectory(profilesDirectory);
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred when creating the 'options-profiles' directory.");
|
||||
e.printStackTrace();
|
||||
LOGGER.error("An error occurred when creating the 'options-profiles' directory.", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package com.axolotlmaid.optionsprofiles.profiles;
|
||||
|
||||
import com.axolotlmaid.optionsprofiles.OptionsProfilesMod;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
|
@ -24,15 +26,14 @@ public class Profiles {
|
|||
Files.createDirectory(profile);
|
||||
|
||||
if (Files.exists(profile)) {
|
||||
System.out.println("[Options Profiles] Profile created.");
|
||||
OptionsProfilesMod.LOGGER.info("Profile created");
|
||||
|
||||
writeOptionsFilesIntoProfile(profileName);
|
||||
} else {
|
||||
System.out.println("[Options Profiles] Profile was not created successfully.");
|
||||
OptionsProfilesMod.LOGGER.warn("Profile was not created successfully");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println("[Options Profiles] An error occurred when creating a profile.");
|
||||
e.printStackTrace();
|
||||
OptionsProfilesMod.LOGGER.error("An error occurred when creating a profile", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -57,13 +58,11 @@ public class Profiles {
|
|||
Files.write(profileOptions, line.getBytes(), StandardOpenOption.CREATE, StandardOpenOption.APPEND);
|
||||
Files.write(profileOptions, "\n".getBytes(), StandardOpenOption.APPEND);
|
||||
} catch (IOException e) {
|
||||
System.out.println("[Options Profiles] An error occurred when writing a profile.");
|
||||
e.printStackTrace();
|
||||
OptionsProfilesMod.LOGGER.error("An error occurred when writing a profile", e);
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
System.out.println("[Options Profiles] An error occurred when reading an options file.");
|
||||
e.printStackTrace();
|
||||
OptionsProfilesMod.LOGGER.error("An error occurred when reading an options file.", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -136,13 +135,11 @@ public class Profiles {
|
|||
Files.write(options, line.getBytes(), StandardOpenOption.APPEND);
|
||||
Files.write(options, "\n".getBytes(), StandardOpenOption.APPEND);
|
||||
} catch (IOException e) {
|
||||
System.out.println("[Options Profiles] An error occurred when loading a profile.");
|
||||
e.printStackTrace();
|
||||
OptionsProfilesMod.LOGGER.error("An error occurred when loading a profile", e);
|
||||
}
|
||||
});
|
||||
} catch (IOException e) {
|
||||
System.out.println("[Options Profiles] An error occurred when loading a profile.");
|
||||
e.printStackTrace();
|
||||
OptionsProfilesMod.LOGGER.error("An error occurred when loading a profile", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -168,19 +165,18 @@ public class Profiles {
|
|||
Path newProfile = Paths.get("options-profiles/" + newProfileName);
|
||||
|
||||
if (Files.exists(newProfile))
|
||||
System.out.println("[Options Profiles] New profile already exists!");
|
||||
OptionsProfilesMod.LOGGER.warn("A profile with that name already exists!");
|
||||
|
||||
try {
|
||||
Files.move(profile, newProfile);
|
||||
|
||||
if (Files.exists(newProfile)) {
|
||||
System.out.println("[Options Profiles] Profile renamed.");
|
||||
OptionsProfilesMod.LOGGER.info("Profile renamed");
|
||||
} else {
|
||||
System.out.println("[Options Profiles] Profile was not renamed successfully.");
|
||||
OptionsProfilesMod.LOGGER.warn("Profile was not renamed successfully!");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println("[Options Profiles] Profile was not renamed successfully.");
|
||||
e.printStackTrace();
|
||||
OptionsProfilesMod.LOGGER.error("Profile not renamed successfully", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -193,10 +189,9 @@ public class Profiles {
|
|||
.map(Path::toFile)
|
||||
.forEach(File::delete);
|
||||
} catch (IOException e) {
|
||||
System.out.println("[Options Profiles] Profile was not deleted.");
|
||||
e.printStackTrace();
|
||||
OptionsProfilesMod.LOGGER.error("Profile was not deleted", e);
|
||||
}
|
||||
|
||||
System.out.println("[Options Profiles] Profile deleted.");
|
||||
OptionsProfilesMod.LOGGER.info("Profile deleted");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue