Merge pull request #533 from s0cks/feature/log-appender

Remove Old Logging & Use Log4J2
This commit is contained in:
Ryan Dowling 2022-06-12 17:49:05 +10:00 committed by GitHub
commit 26ce237d89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
101 changed files with 1585 additions and 1555 deletions

View file

@ -1,19 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="#JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</GradleProjectSettings>
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="true" />
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
</component>
</GradleProjectSettings>
</option>
</component>
</project>

View file

@ -17,44 +17,6 @@
*/
package com.atlauncher;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.SystemTray;
import java.awt.Toolkit;
import java.awt.TrayIcon;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
import java.net.SocketAddress;
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import javax.swing.BorderFactory;
import javax.swing.InputMap;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.ToolTipManager;
import javax.swing.UIManager;
import javax.swing.text.DefaultEditorKit;
import org.mini2Dx.gettext.GetText;
import com.atlauncher.builders.HTMLBuilder;
import com.atlauncher.constants.Constants;
import com.atlauncher.data.Instance;
@ -68,21 +30,23 @@ import com.atlauncher.gui.TrayMenu;
import com.atlauncher.gui.dialogs.SetupDialog;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.PackManager;
import com.atlauncher.network.ErrorReporting;
import com.atlauncher.themes.ATLauncherLaf;
import com.atlauncher.utils.Java;
import com.atlauncher.utils.LoggingUtils;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import com.formdev.flatlaf.extras.FlatInspector;
import com.formdev.flatlaf.extras.FlatUIDefaultsInspector;
import io.github.asyncronous.toast.Toaster;
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import net.arikia.dev.drpc.DiscordEventHandlers;
import net.arikia.dev.drpc.DiscordRPC;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import oshi.SystemInfo;
import oshi.hardware.CentralProcessor;
import oshi.hardware.GraphicsCard;
@ -90,11 +54,35 @@ import oshi.hardware.HardwareAbstractionLayer;
import oshi.software.os.OSProcess;
import oshi.software.os.OperatingSystem;
import javax.swing.*;
import javax.swing.text.DefaultEditorKit;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.reflect.Method;
import java.net.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Main entry point for the application, Java runs the main method here when the
* application is launched.
*/
public class App {
private static final Logger LOG = LogManager.getLogger();
public static String[] PASSED_ARGS;
/**
@ -125,10 +113,10 @@ public class App {
public static boolean discordInitialized = false;
/**
* This allows skipping the setup dialog on first run. This is mainly used for
* This allows skipping the setup Dialog on first run. This is mainly used for
* automation tests. It can be skipped with the below command line argument.
* <p/>
* --skip-setup-dialog
* --skip-setup-Dialog
*/
public static boolean skipSetupDialog = false;
@ -258,6 +246,7 @@ public class App {
* @param args all the arguments passed in from the command line
*/
public static void main(String[] args) {
LoggingUtils.redirectSystemOutLogs();
PASSED_ARGS = args;
// Parse all the command line arguments
@ -275,10 +264,10 @@ public class App {
setupOSSpecificThings();
try {
LogManager.info("Organising filesystem");
LOG.info("Organising filesystem");
FileSystem.organise();
} catch (IOException e) {
LogManager.logStackTrace("Error organising filesystem", e, false);
LOG.error("Error organising filesystem", e);
}
// Load the settings from json, convert old properties config and validate it
@ -310,7 +299,6 @@ public class App {
SwingUtilities.invokeLater(() -> ss.setVisible(true));
console = new LauncherConsole();
LogManager.start();
if (!noConsole && settings.enableConsole) {
// Show the console if enabled.
@ -320,7 +308,7 @@ public class App {
try {
Language.init();
} catch (IOException e1) {
LogManager.logStackTrace("Error loading language", e1);
LOG.error("Error loading language", e1);
}
if (!noConsole && settings.enableConsole) {
@ -333,23 +321,23 @@ public class App {
// Try to enable the tray icon.
trySystemTrayIntegration();
} catch (Exception e) {
LogManager.logStackTrace(e, false);
LOG.error(e);
}
}
// log out the system information to the console
logSystemInformation(args);
LogManager.info("Showing splash screen and loading everything");
LOG.info("Showing splash screen and loading everything");
launcher.loadEverything(); // Loads everything that needs to be loaded
LogManager.info("Launcher finished loading everything");
LOG.info("Launcher finished loading everything");
if (settings.firstTimeRun) {
if (skipSetupDialog) {
App.settings.firstTimeRun = false;
App.settings.save();
} else {
LogManager.warn("Launcher not setup. Loading Setup Dialog");
LOG.warn("Launcher not setup. Loading Setup Dialog");
new SetupDialog();
}
}
@ -361,14 +349,14 @@ public class App {
i -> i.getName().equalsIgnoreCase(autoLaunch) || i.getSafeName().equalsIgnoreCase(autoLaunch))
.findFirst();
if (instance.isPresent()) {
LogManager.info("Opening Instance " + instance.get().launcher.name);
LOG.info("Opening Instance " + instance.get().launcher.name);
if (instance.get().launch()) {
open = false;
} else {
LogManager.error("Error Opening Instance " + instance.get().launcher.name);
LOG.error("Error Opening Instance " + instance.get().launcher.name);
}
} else {
LogManager.error("Couldn't find instance with name of " + autoLaunch + " to auto launch.");
LOG.error("Couldn't find instance with name of " + autoLaunch + " to auto launch.");
}
}
@ -376,12 +364,12 @@ public class App {
if (PackManager.addPack(packCodeToAdd)) {
Pack packAdded = PackManager.getSemiPublicPackByCode(packCodeToAdd);
if (packAdded != null) {
LogManager.info("The pack " + packAdded.getName() + " was automatically added to the launcher!");
LOG.info("The pack " + packAdded.getName() + " was automatically added to the launcher!");
} else {
LogManager.error("Error automatically adding semi public pack with code of " + packCodeToAdd + "!");
LOG.error("Error automatically adding semi public pack with code of " + packCodeToAdd + "!");
}
} else {
LogManager.error("Error automatically adding semi public pack with code of " + packCodeToAdd + "!");
LOG.error("Error automatically adding semi public pack with code of " + packCodeToAdd + "!");
}
}
@ -404,41 +392,41 @@ public class App {
Runtime.getRuntime().addShutdownHook(new Thread(DiscordRPC::discordShutdown));
} catch (Throwable e) {
LogManager.logStackTrace("Failed to initialize Discord integration", e);
LOG.error("Failed to initialize Discord integration", e);
discordInitialized = false;
}
}
}
private static void logSystemInformation(String[] args) {
LogManager.info(Constants.LAUNCHER_NAME + " Version: " + Constants.VERSION);
LOG.info(Constants.LAUNCHER_NAME + " Version: " + Constants.VERSION);
LogManager.info(String.format("App Arguments: %s", Gsons.DEFAULT_SLIM.toJson(args)));
LOG.info(String.format("App Arguments: %s", Gsons.DEFAULT_SLIM.toJson(args)));
LogManager.info(String.format("JVM Arguments: %s",
LOG.info(String.format("JVM Arguments: %s",
Gsons.DEFAULT_SLIM.toJson(ManagementFactory.getRuntimeMXBean().getInputArguments())));
SwingUtilities.invokeLater(
() -> Java.getInstalledJavas().forEach(version -> LogManager.debug(Gsons.DEFAULT.toJson(version))));
() -> Java.getInstalledJavas().forEach(version -> LOG.debug(Gsons.DEFAULT.toJson(version))));
LogManager.info("Java Version: "
LOG.info("Java Version: "
+ String.format("Java %d (%s)", Java.getLauncherJavaVersionNumber(), Java.getLauncherJavaVersion()));
LogManager.info("Java Path: " + settings.javaPath);
LOG.info("Java Path: " + settings.javaPath);
LogManager.info("64 Bit Java: " + Java.is64Bit());
LOG.info("64 Bit Java: " + Java.is64Bit());
int maxRam = OS.getMaximumRam();
LogManager.info("RAM Available: " + (maxRam == 0 ? "Unknown" : maxRam + "MB"));
LOG.info("RAM Available: " + (maxRam == 0 ? "Unknown" : maxRam + "MB"));
LogManager.info("Launcher Directory: " + FileSystem.BASE_DIR);
LOG.info("Launcher Directory: " + FileSystem.BASE_DIR);
if (OS.isMac()) {
LogManager.info("Using Mac App? " + (OS.isUsingMacApp() ? "Yes" : "No"));
LOG.info("Using Mac App? " + (OS.isUsingMacApp() ? "Yes" : "No"));
}
if (OS.isUsingFlatpak()) {
LogManager.info("Using Flatpak!");
LOG.info("Using Flatpak!");
}
try {
@ -448,33 +436,32 @@ public class App {
List<GraphicsCard> cards = hal.getGraphicsCards();
if (cards.size() != 0) {
for (GraphicsCard card : cards) {
LogManager.info("GPU: " + card.getName() + " (" + card.getVendor() + ") " + card.getVersionInfo()
LOG.info("GPU: " + card.getName() + " (" + card.getVendor() + ") " + card.getVersionInfo()
+ " " + (card.getVRam() / 1048576) + "MB VRAM");
}
}
CentralProcessor cpu = hal.getProcessor();
LogManager.info(String.format("CPU: %s %d cores/%d threads", cpu.getProcessorIdentifier().getName().trim(),
LOG.info(String.format("CPU: %s %d cores/%d threads", cpu.getProcessorIdentifier().getName().trim(),
cpu.getPhysicalProcessorCount(), cpu.getLogicalProcessorCount()));
OperatingSystem os = systemInfo.getOperatingSystem();
LogManager.info("Operating System: " + os.getFamily() + " (" + os.getVersionInfo() + ")");
LogManager.info("Bitness: " + os.getBitness());
LogManager.info("Uptime: " + os.getSystemUptime());
LogManager.info("Manufacturer: " + os.getManufacturer());
LOG.info("Operating System: " + os.getFamily() + " (" + os.getVersionInfo() + ")");
LOG.info("Bitness: " + os.getBitness());
LOG.info("Uptime: " + os.getSystemUptime());
LOG.info("Manufacturer: " + os.getManufacturer());
if (OS.isWindows() && OS.isUsingAntivirus()) {
LogManager.warn(
LOG.error(
"A running antivirus process was found on your system. If you notice any issues running Minecraft or downloading files, please whitelist ATLauncher and its folder in your antivirus program/s listed below.");
for (OSProcess process : OS.getAntivirusProcesses()) {
LogManager.info(String.format("Process %s (running at %s)", process.getName(),
process.getPath()));
LOG.info(String.format("Process %s (running at %s)", process.getName(), process.getPath()));
}
}
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error("error: ", t);
}
}
@ -536,7 +523,7 @@ public class App {
if (javaOptions != null && (javaOptions.toLowerCase().contains("-xmx")
|| javaOptions.toLowerCase().contains("-xms") || javaOptions.toLowerCase().contains("-xss"))) {
LogManager.warn("_JAVA_OPTIONS environment variable detected: " + javaOptions);
LOG.warn("_JAVA_OPTIONS environment variable detected: " + javaOptions);
if (!settings.ignoreJavaOptionsWarning) {
int ret = DialogManager.yesNoDialog().addOption(GetText.tr("Don't remind me again"))
@ -562,7 +549,7 @@ public class App {
private static void checkForBadFolderInstall() {
if (!settings.ignoreOneDriveWarning && FileSystem.BASE_DIR.toString().contains("OneDrive")) {
LogManager.warn("ATLauncher installed within OneDrive!");
LOG.warn("ATLauncher installed within OneDrive!");
int ret = DialogManager.yesNoDialog().addOption(GetText.tr("Don't remind me again"))
.setTitle(GetText.tr("ATLauncher installed within OneDrive"))
@ -582,7 +569,7 @@ public class App {
if (OS.isWindows() && !settings.ignoreProgramFilesWarning
&& FileSystem.BASE_DIR.toString().contains("Program Files")) {
LogManager.warn("ATLauncher installed within Program Files!");
LOG.warn("ATLauncher installed within Program Files!");
int ret = DialogManager.yesNoDialog().addOption(GetText.tr("Don't remind me again"))
.setTitle(GetText.tr("ATLauncher installed within Program Files"))
@ -605,7 +592,7 @@ public class App {
try {
if ((!testFile.exists() && !testFile.createNewFile())
|| !FileSystem.BASE_DIR.resolve(".test").toFile().canWrite()) {
LogManager.error("ATLauncher cannot write files!");
LOG.error("ATLauncher cannot write files!");
DialogManager.okDialog().setTitle(GetText.tr("ATLauncher cannot write files"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
@ -617,7 +604,7 @@ public class App {
System.exit(0);
}
} catch (IOException e) {
LogManager.error("ATLauncher cannot write files!");
LOG.error("ATLauncher cannot write files!");
DialogManager.okDialog().setTitle(GetText.tr("ATLauncher cannot write files"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
@ -643,7 +630,7 @@ public class App {
Method setDockIconImage = util.getMethod("setDockIconImage", Image.class);
setDockIconImage.invoke(application, Utils.getImage("/assets/image/icon-osx.png"));
} catch (Exception ex) {
LogManager.logStackTrace("Failed to set dock icon", ex);
LOG.error("Failed to set dock icon", ex);
}
}
@ -681,7 +668,7 @@ public class App {
try (FileReader fileReader = new FileReader(FileSystem.SETTINGS.toFile())) {
settings = Gsons.DEFAULT.fromJson(fileReader, Settings.class);
} catch (Throwable t) {
LogManager.logStackTrace("Error loading settings, using defaults", t, false);
LOG.error("Error loading settings, using defaults", t, false);
settings = new Settings();
}
} else {
@ -694,14 +681,14 @@ public class App {
properties.load(fileReader);
settings.convert(properties);
} catch (Throwable t) {
LogManager.logStackTrace("Error loading settings, using defaults", t, false);
LOG.error("Error loading settings, using defaults", t, false);
settings = new Settings();
}
try {
Files.delete(FileSystem.LAUNCHER_CONFIG);
} catch (IOException e) {
LogManager.warn("Failed to delete old launcher config.");
LOG.warn("Failed to delete old launcher config.");
}
}
@ -884,35 +871,24 @@ public class App {
wasUpdated = true;
}
if (options.has("debug")) {
LogManager.showDebug = true;
LogManager.debugLevel = 1;
LogManager.debug("Debug logging is enabled! Please note that this will remove any censoring of user data!");
}
if (options.has("debug-level")) {
LogManager.debugLevel = (Integer) options.valueOf("debug-level");
LogManager.debug("Debug level has been set to " + options.valueOf("debug-level") + "!");
}
skipSetupDialog = options.has("skip-setup-dialog");
if (skipSetupDialog) {
LogManager.debug("Skipping setup dialog!");
LOG.debug("Skipping setup dialog!");
}
skipTrayIntegration = options.has("skip-tray-integration");
if (skipTrayIntegration) {
LogManager.debug("Skipping tray integration!");
LOG.debug("Skipping tray integration!");
}
disableAnalytics = options.has("disable-analytics");
if (disableAnalytics) {
LogManager.debug("Disabling analytics!");
LOG.debug("Disabling analytics!");
}
disableErrorReporting = options.has("disable-error-reporting");
if (disableErrorReporting) {
LogManager.debug("Disabling error reporting!");
LOG.debug("Disabling error reporting!");
}
if (options.has("working-dir")) {
@ -924,41 +900,41 @@ public class App {
String baseLauncherDomain = String.valueOf(options.valueOf("base-launcher-domain"));
Constants.setBaseLauncherDomain(baseLauncherDomain);
LogManager.warn("Base launcher domain set to " + baseLauncherDomain);
LOG.warn("Base launcher domain set to " + baseLauncherDomain);
}
if (options.has("base-cdn-domain")) {
String baseCdnDomain = String.valueOf(options.valueOf("base-cdn-domain"));
Constants.setBaseCdnDomain(baseCdnDomain);
LogManager.warn("Base cdn domain set to " + baseCdnDomain);
LOG.warn("Base cdn domain set to " + baseCdnDomain);
}
if (options.has("base-cdn-path")) {
String baseCdnPath = String.valueOf(options.valueOf("base-cdn-path"));
Constants.setBaseCdnPath(baseCdnPath);
LogManager.warn("Base cdn path set to " + baseCdnPath);
LOG.warn("Base cdn path set to " + baseCdnPath);
}
allowAllSslCerts = options.has("allow-all-ssl-certs");
if (allowAllSslCerts) {
LogManager.warn("Allowing all ssl certs. This is insecure and should only be used for development.");
LOG.warn("Allowing all ssl certs. This is insecure and should only be used for development.");
}
noLauncherUpdate = options.has("no-launcher-update");
if (noLauncherUpdate) {
LogManager.debug("Not updating the launcher!");
LOG.debug("Not updating the launcher!");
}
noConsole = options.has("no-console");
if (noConsole) {
LogManager.debug("Not showing console!");
LOG.debug("Not showing console!");
}
closeLauncher = options.has("close-launcher");
if (closeLauncher) {
LogManager.debug("Closing launcher once Minecraft is launched!");
LOG.debug("Closing launcher once Minecraft is launched!");
}
if (options.has("proxy-type") && options.has("proxy-host") && options.has("proxy-port")) {
@ -969,7 +945,7 @@ public class App {
Proxy proxy = new java.net.Proxy(java.net.Proxy.Type.valueOf(proxyType),
new InetSocketAddress(proxyHost, proxyPort));
LogManager.warn("Proxy set to " + proxy);
LOG.warn("Proxy set to " + proxy);
ProxySelector.setDefault(new ProxySelector() {
@Override
@ -979,7 +955,7 @@ public class App {
@Override
public void connectFailed(URI uri, SocketAddress sa, IOException e) {
LogManager.logStackTrace("Connection could not be established to proxy at socket [" + sa + "]", e);
LOG.error("Connection could not be established to proxy at socket [" + sa + "]", e);
}
});
}
@ -987,7 +963,7 @@ public class App {
if (options.has("config-override")) {
configOverride = (String) options.valueOf("config-override");
LogManager.warn("Config overridden: " + configOverride);
LOG.warn("Config overridden: " + configOverride);
}
}
}

View file

@ -17,11 +17,14 @@
*/
package com.atlauncher;
import com.atlauncher.managers.LogManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class ExceptionStrainer implements Thread.UncaughtExceptionHandler {
private static final Logger LOG = LogManager.getLogger(ExceptionStrainer.class);
@Override
public void uncaughtException(Thread t, Throwable e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}

View file

@ -25,13 +25,16 @@ import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import com.atlauncher.constants.Constants;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.FileUtils;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class FileSystem {
public final class FileSystem{
private static final Logger LOG = LogManager.getLogger(FileSystem.class);
private static Path CACHED_USER_DOWNLOADS = null;
public static final Path BASE_DIR = FileSystem.getCoreGracefully();
public static final Path LOGS = BASE_DIR.resolve("logs");
public static final Path BACKUPS = BASE_DIR.resolve("backups");
@ -112,8 +115,7 @@ public final class FileSystem {
try {
return Paths.get(App.settings.customDownloadsPath);
} catch (Exception e) {
LogManager.logStackTrace(
"Problem when reading custom downloads path, defaulting to user downloads folder.", e);
LOG.error("Problem when reading custom downloads path, defaulting to user downloads folder.", e);
}
}
@ -140,7 +142,7 @@ public final class FileSystem {
}
}
} catch (Exception e) {
LogManager.logStackTrace("Problem when reading in registry", e);
LOG.error("Problem when reading in registry", e);
}
CACHED_USER_DOWNLOADS = Paths.get(System.getProperty("user.home"), "Downloads");
@ -196,7 +198,7 @@ public final class FileSystem {
Files.move(intermediaryPath, to, StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException e) {
LogManager.logStackTrace("Error renaming directory", e, false);
LOG.error("Error renaming directory:", e);//don't send
}
}

View file

@ -48,7 +48,6 @@ import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.CurseForgeUpdateManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.managers.ModpacksChUpdateManager;
import com.atlauncher.managers.ModrinthModpackUpdateManager;
@ -59,18 +58,23 @@ import com.atlauncher.managers.ServerManager;
import com.atlauncher.managers.TechnicModpackUpdateManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.network.DownloadPool;
import com.atlauncher.network.ErrorReporting;
import com.atlauncher.utils.Java;
import com.atlauncher.utils.OS;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import net.arikia.dev.drpc.DiscordRPC;
import okhttp3.OkHttpClient;
public class Launcher {
private static final Logger LOG = LogManager.getLogger(Launcher.class);
// Holding update data
private LauncherVersion latestLauncherVersion; // Latest Launcher version
private List<DownloadableFile> launcherFiles; // Files the Launcher needs to download
@ -121,7 +125,7 @@ public class Launcher {
PackManager.removeUnusedImages(); // remove unused pack images
if (OS.isWindows() && !Java.is64Bit() && OS.is64Bit()) {
LogManager.warn("You're using 32 bit Java on a 64 bit Windows install!");
LOG.warn("You're using 32 bit Java on a 64 bit Windows install!");
int ret = DialogManager.yesNoDialog().setTitle(GetText.tr("Running 32 Bit Java on 64 Bit Windows"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
@ -148,7 +152,7 @@ public class Launcher {
this.latestLauncherVersion = Gsons.DEFAULT
.fromJson(new FileReader(FileSystem.JSON.resolve("version.json").toFile()), LauncherVersion.class);
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e) {
LogManager.logStackTrace("Exception when loading latest launcher version!", e);
LOG.error("Exception when loading latest launcher version!", e);
}
return this.latestLauncherVersion != null && Constants.VERSION.needsUpdate(this.latestLauncherVersion);
@ -167,7 +171,7 @@ public class Launcher {
toget = "jar";
}
File newFile = FileSystem.TEMP.resolve(saveAs).toFile();
LogManager.info("Downloading Launcher Update");
LOG.info("Downloading Launcher Update");
Analytics.sendEvent("Update", "Launcher");
ProgressDialog<Boolean> progressDialog = new ProgressDialog<>(GetText.tr("Downloading Launcher Update"), 1,
@ -182,7 +186,7 @@ public class Launcher {
try {
download.downloadFile();
} catch (IOException e) {
LogManager.logStackTrace("Failed to download update", e);
LOG.error("Failed to download update", e);
progressDialog.setReturnValue(false);
progressDialog.close();
return;
@ -198,7 +202,7 @@ public class Launcher {
runUpdate(path, newFile.getAbsolutePath());
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("Error downloading update", e);
}
}
@ -222,12 +226,12 @@ public class Launcher {
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.command(arguments);
LogManager.info("Running launcher update with command " + arguments);
LOG.info("Running launcher update with command " + arguments);
try {
processBuilder.start();
} catch (IOException e) {
LogManager.logStackTrace(e);
} catch (IOException e){
LOG.error("failed to start the launcher:", e);
}
System.exit(0);
@ -246,7 +250,7 @@ public class Launcher {
this.launcherFiles = com.atlauncher.network.Download.build().cached()
.setUrl(String.format("%s/launcher/json/files.json", Constants.DOWNLOAD_SERVER)).asType(type);
} catch (Exception e) {
LogManager.logStackTrace("Error loading in file hashes!", e);
LOG.error("Error loading in file hashes!", e);
return null;
}
}
@ -278,7 +282,7 @@ public class Launcher {
}));
progressDialog.start();
LogManager.info("Finished downloading updated files!");
LOG.info("Finished downloading updated files!");
}
public boolean checkForUpdatedFiles() {
@ -296,7 +300,7 @@ public class Launcher {
* differ from what the user has
*/
public boolean hasUpdatedFiles() {
LogManager.info("Checking for updated files!");
LOG.info("Checking for updated files!");
List<com.atlauncher.network.Download> downloads = getLauncherFiles();
if (downloads == null) {
@ -374,7 +378,7 @@ public class Launcher {
private void checkForLauncherUpdate() {
PerformanceManager.start();
LogManager.debug("Checking for launcher update");
LOG.debug("Checking for launcher update");
if (launcherHasUpdate()) {
if (App.noLauncherUpdate) {
int ret = DialogManager.okDialog().setTitle("Launcher Update Available")
@ -404,7 +408,8 @@ public class Launcher {
System.exit(0);
}
}
LogManager.debug("Finished checking for launcher update");
LOG.debug("Finished checking for launcher update");
PerformanceManager.end();
}
@ -511,7 +516,7 @@ public class Launcher {
public void killMinecraft() {
if (this.minecraftProcess != null) {
LogManager.error("Killing Minecraft");
LOG.error("Killing Minecraft");
if (App.discordInitialized) {
DiscordRPC.discordClearPresence();
@ -520,7 +525,7 @@ public class Launcher {
this.minecraftProcess.destroy();
this.minecraftProcess = null;
} else {
LogManager.error("Cannot kill Minecraft as there is no instance open!");
LOG.error("Cannot kill Minecraft as there is no instance open!");
}
}
}

View file

@ -34,18 +34,21 @@ import com.atlauncher.gui.tabs.InstancesTab;
import com.atlauncher.gui.tabs.ServersTab;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Download;
import com.atlauncher.utils.SkinUtils;
import com.atlauncher.utils.Utils;
import com.mojang.util.UUIDTypeAdapter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
/**
* This class deals with the Accounts in the launcher.
*/
public abstract class AbstractAccount implements Serializable {
public abstract class AbstractAccount implements Serializable{
private static final Logger LOG = LogManager.getLogger(AbstractAccount.class);
/**
* Auto generated serial.
*/
@ -115,8 +118,11 @@ public abstract class AbstractAccount implements Serializable {
}
if (!currentUsername.equals(this.minecraftUsername)) {
LogManager.info("The username for account with UUID of " + this.getUUIDNoDashes() + " changed from "
+ this.minecraftUsername + " to " + currentUsername);
LOG.info("The username for account with UUID of {} changed from {} to {}",
this.getUUIDNoDashes(),
this.minecraftUsername,
currentUsername);
this.minecraftUsername = currentUsername;
dialog.setReturnValue(true);
}
@ -151,7 +157,8 @@ public abstract class AbstractAccount implements Serializable {
if (!this.skinUpdating) {
this.skinUpdating = true;
final File file = FileSystem.SKINS.resolve(this.getUUIDNoDashes() + ".png").toFile();
LogManager.info("Downloading skin for " + this.minecraftUsername);
LOG.info("Downloading skin for " + this.minecraftUsername);
final ProgressDialog<Boolean> dialog = new ProgressDialog<>(GetText.tr("Downloading Skin"), 0,
GetText.tr("Downloading Skin For {0}", this.minecraftUsername),
"Aborting downloading Minecraft skin for " + this.minecraftUsername);
@ -160,7 +167,7 @@ public abstract class AbstractAccount implements Serializable {
dialog.setReturnValue(false);
String skinURL = getSkinUrl();
if (skinURL == null) {
LogManager.warn("Couldn't download skin because the url found was NULL. Using default skin");
LOG.warn("Couldn't download skin because the url found was NULL. Using default skin");
if (!file.exists()) {
String skinFilename = "default.png";
@ -174,7 +181,7 @@ public abstract class AbstractAccount implements Serializable {
java.nio.file.Files.copy(
Utils.getResourceInputStream("/assets/image/skins/" + skinFilename), file.toPath());
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error copying skin", e);
}
dialog.setReturnValue(true);
@ -203,14 +210,14 @@ public abstract class AbstractAccount implements Serializable {
Utils.getResourceInputStream("/assets/image/skins/" + skinFilename),
file.toPath());
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error updating skin", e);
}
dialog.setReturnValue(true);
}
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error updating skin", e);
}
com.atlauncher.evnt.manager.AccountManager.post();
}

View file

@ -24,8 +24,9 @@ import java.util.List;
import java.util.Map;
import com.atlauncher.gui.tabs.InstancesTab;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* This class deals with the Accounts in the launcher.
@ -34,6 +35,8 @@ import com.atlauncher.utils.Utils;
* and MojangAccount and MicrosoftAccount
*/
public class Account implements Serializable {
private static final Logger LOG = LogManager.getLogger(Account.class);
/**
* Auto generated serial.
*/
@ -117,7 +120,7 @@ public class Account implements Serializable {
} else {
this.password = Utils.decrypt(this.encryptedPassword);
if (this.password == null) {
LogManager.error("Error reading in saved password from file!");
LOG.error("Error reading in saved password from file!");
this.password = "";
this.remember = false;
}

View file

@ -39,7 +39,6 @@ import com.atlauncher.exceptions.InvalidMinecraftVersion;
import com.atlauncher.gui.dialogs.CurseForgeProjectFileSelectorDialog;
import com.atlauncher.gui.dialogs.ModrinthVersionSelectorDialog;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.CurseForgeApi;
@ -48,8 +47,14 @@ import com.atlauncher.utils.Pair;
import com.atlauncher.utils.Utils;
import com.google.gson.annotations.SerializedName;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SuppressWarnings("serial")
public class DisableableMod implements Serializable {
public class DisableableMod implements Serializable{
private static final Logger LOG = LogManager.getLogger(DisableableMod.class);
public String name;
public String version;
public boolean optional;
@ -315,12 +320,12 @@ public class DisableableMod implements Serializable {
}
break;
default:
LogManager.warn("Unsupported mod for enabling/disabling " + this.name);
LOG.warn("Unsupported mod for enabling/disabling {}", this.name);
break;
}
}
if (dir == null) {
LogManager.warn("null path returned for mod " + this.name);
LOG.warn("null path returned for mod " + this.name);
return null;
}
return new File(dir, file);
@ -368,7 +373,7 @@ public class DisableableMod implements Serializable {
file -> file.gameVersions.stream()
.anyMatch(gv -> minecraftVersionsToSearch.contains(gv)));
} catch (InvalidMinecraftVersion e) {
LogManager.logStackTrace(e);
LOG.error(e);
}
}

View file

@ -17,59 +17,8 @@
*/
package com.atlauncher.data;
import java.awt.BorderLayout;
import java.awt.Dialog.ModalityType;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;
import java.util.UUID;
import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.filechooser.FileNameExtensionFilter;
import org.mini2Dx.gettext.GetText;
import com.atlauncher.App;
import com.atlauncher.Data;
import com.atlauncher.FileSystem;
import com.atlauncher.Gsons;
import com.atlauncher.Network;
import com.atlauncher.*;
import com.atlauncher.annot.Json;
import com.atlauncher.builders.HTMLBuilder;
import com.atlauncher.constants.Constants;
@ -82,17 +31,8 @@ import com.atlauncher.data.curseforge.pack.CurseForgeMinecraft;
import com.atlauncher.data.curseforge.pack.CurseForgeModLoader;
import com.atlauncher.data.installables.Installable;
import com.atlauncher.data.installables.VanillaInstallable;
import com.atlauncher.data.minecraft.AssetIndex;
import com.atlauncher.data.minecraft.JavaRuntime;
import com.atlauncher.data.minecraft.JavaRuntimeManifest;
import com.atlauncher.data.minecraft.JavaRuntimeManifestFileType;
import com.atlauncher.data.minecraft.JavaRuntimes;
import com.atlauncher.data.minecraft.Library;
import com.atlauncher.data.minecraft.LoggingFile;
import com.atlauncher.data.minecraft.MinecraftVersion;
import com.atlauncher.data.minecraft.MojangAssetIndex;
import com.atlauncher.data.minecraft.VersionManifestVersion;
import com.atlauncher.data.minecraft.VersionManifestVersionType;
import com.atlauncher.data.minecraft.*;
import com.atlauncher.data.minecraft.loaders.LoaderType;
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.data.minecraft.loaders.fabric.FabricLoader;
@ -117,41 +57,46 @@ import com.atlauncher.exceptions.InvalidPack;
import com.atlauncher.gui.dialogs.InstanceInstallerDialog;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.gui.dialogs.RenameInstanceDialog;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.CurseForgeUpdateManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.managers.ModpacksChUpdateManager;
import com.atlauncher.managers.ModrinthModpackUpdateManager;
import com.atlauncher.managers.PackManager;
import com.atlauncher.managers.PerformanceManager;
import com.atlauncher.managers.TechnicModpackUpdateManager;
import com.atlauncher.managers.*;
import com.atlauncher.mclauncher.MCLauncher;
import com.atlauncher.network.Analytics;
import com.atlauncher.network.DownloadPool;
import com.atlauncher.utils.ArchiveUtils;
import com.atlauncher.utils.ComboItem;
import com.atlauncher.utils.CommandExecutor;
import com.atlauncher.utils.CurseForgeApi;
import com.atlauncher.utils.FileUtils;
import com.atlauncher.utils.Hashing;
import com.atlauncher.utils.Java;
import com.atlauncher.utils.ModrinthApi;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import com.atlauncher.utils.ZipNameMapper;
import com.atlauncher.utils.*;
import com.google.gson.JsonIOException;
import net.arikia.dev.drpc.DiscordRPC;
import net.arikia.dev.drpc.DiscordRichPresence;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.MarkerManager;
import org.mini2Dx.gettext.GetText;
import javax.imageio.ImageIO;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
import java.awt.*;
import java.awt.Dialog.ModalityType;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.time.Instant;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
@Json
public class Instance extends MinecraftVersion {
public class Instance extends MinecraftVersion{
private static final Logger LOG = LogManager.getLogger(Instance.class);
public String inheritsFrom;
public InstanceLauncher launcher;
@ -336,9 +281,7 @@ public class Instance extends MinecraftVersion {
return new ImageIcon(img.getScaledInstance(300, 150, Image.SCALE_SMOOTH));
} catch (Exception e) {
LogManager.logStackTrace(
"Error creating scaled image from the custom image of instance " + this.launcher.name, e,
false);
LOG.error("Error creating scaled image from the custom image of instance {}:", this.launcher.name, e);//don't send
}
}
@ -490,8 +433,8 @@ public class Instance extends MinecraftVersion {
}
progressDialog.doneTask();
} catch (IOException e) {
LogManager.logStackTrace(e);
} catch (IOException e){
LOG.error("Error downloading minecraft", e);
PerformanceManager.end("Downloading Minecraft");
PerformanceManager.end();
return false;
@ -517,7 +460,7 @@ public class Instance extends MinecraftVersion {
progressDialog.doneTask();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error(e);
PerformanceManager.end("Downloading Logging Config");
PerformanceManager.end();
return false;
@ -629,7 +572,7 @@ public class Instance extends MinecraftVersion {
// Files.write(runtimeSystemDirectory.resolve(javaVersion.component
// + ".sha1"), runtimeToDownload.version.name.getBytes(StandardCharsets.UTF_8));
} catch (IOException e) {
LogManager.logStackTrace("Failed to download Java runtime", e);
LOG.error("Failed to download Java runtime", e);
}
}
}
@ -728,7 +671,7 @@ public class Instance extends MinecraftVersion {
if (!Utils.combineJars(getMinecraftJar(), getRoot().resolve("bin/modpack.jar").toFile(),
getCustomMinecraftJar())) {
LogManager.error("Failed to combine jars into custom minecraft.jar");
LOG.error("Failed to combine jars into custom minecraft.jar");
PerformanceManager.end("Creating custom minecraft.jar");
PerformanceManager.end();
return false;
@ -763,7 +706,7 @@ public class Instance extends MinecraftVersion {
// if Microsoft account must login again, then make sure to do that
if (!offline && account instanceof MicrosoftAccount && ((MicrosoftAccount) account).mustLogin) {
if (!((MicrosoftAccount) account).ensureAccountIsLoggedIn()) {
LogManager.info("You must login to your account before continuing.");
LOG.info("You must login to your account before continuing.");
return false;
}
}
@ -775,7 +718,7 @@ public class Instance extends MinecraftVersion {
.setContent(GetText.tr("Choose your offline player name:")).showInput(playerName);
if (playerName == null || playerName.isEmpty()) {
LogManager.info("No player name provided for offline launch, so cancelling launch.");
LOG.info("No player name provided for offline launch, so cancelling launch.");
return false;
}
}
@ -793,7 +736,7 @@ public class Instance extends MinecraftVersion {
.setType(DialogManager.ERROR).show();
if (ret != 0) {
LogManager.warn("Launching of instance cancelled due to user cancelling memory warning!");
LOG.warn("Launching of instance cancelled due to user cancelling memory warning!");
App.launcher.setMinecraftLaunched(false);
return false;
}
@ -806,7 +749,7 @@ public class Instance extends MinecraftVersion {
this.launcher.requiredPermGen)).build())
.setType(DialogManager.ERROR).show();
if (ret != 0) {
LogManager.warn("Launching of instance cancelled due to user cancelling permgen warning!");
LOG.warn("Launching of instance cancelled due to user cancelling permgen warning!");
App.launcher.setMinecraftLaunched(false);
return false;
}
@ -817,21 +760,20 @@ public class Instance extends MinecraftVersion {
try {
Files.createDirectory(nativesTempDir);
} catch (IOException e2) {
LogManager.logStackTrace(e2, false);
LOG.error(MarkerManager.getMarker("NoReporting"), "Couldn't create natives temp directory", e2);
}
ProgressDialog<Boolean> prepareDialog = new ProgressDialog<>(GetText.tr("Preparing For Launch"), 7,
GetText.tr("Preparing For Launch"));
prepareDialog.addThread(new Thread(() -> {
LogManager.info("Preparing for launch!");
LOG.info("Preparing for launch!");
prepareDialog.setReturnValue(prepareForLaunch(prepareDialog, nativesTempDir));
prepareDialog.close();
}));
prepareDialog.start();
if (prepareDialog.getReturnValue() == null || !prepareDialog.getReturnValue()) {
LogManager.error(
"Failed to prepare instance " + this.launcher.name + " for launch. Check the logs and try again.");
LOG.error("Failed to prepare instance {} for launch. Check the logs and try again.", this.launcher.name);
return false;
}
@ -845,8 +787,7 @@ public class Instance extends MinecraftVersion {
App.launcher.getParent().setVisible(false);
}
LogManager.info("Launching pack " + this.launcher.pack + " " + this.launcher.version + " for "
+ "Minecraft " + this.id);
LOG.info("Launching pack {} {} for Minecraft {}", this.launcher.pack, this.launcher.version, this.id);
Process process = null;
@ -870,7 +811,7 @@ public class Instance extends MinecraftVersion {
session = new LoginResponse(mojangAccount.username);
session.setOffline();
} else {
LogManager.info("Logging into Minecraft!");
LOG.info("Logging into Minecraft!");
ProgressDialog<LoginResponse> loginDialog = new ProgressDialog<>(
GetText.tr("Logging Into Minecraft"), 0, GetText.tr("Logging Into Minecraft"),
"Aborted login to Minecraft!");
@ -893,7 +834,7 @@ public class Instance extends MinecraftVersion {
if (enableCommands && preLaunchCommand != null) {
if (!executeCommand(preLaunchCommand)) {
LogManager.error("Failed to execute pre-launch command");
LOG.error("Failed to execute pre-launch command");
App.launcher.setMinecraftLaunched(false);
@ -910,7 +851,7 @@ public class Instance extends MinecraftVersion {
MicrosoftAccount microsoftAccount = (MicrosoftAccount) account;
if (!offline) {
LogManager.info("Logging into Minecraft!");
LOG.info("Logging into Minecraft!");
ProgressDialog<Boolean> loginDialog = new ProgressDialog<>(GetText.tr("Logging Into Minecraft"),
0, GetText.tr("Logging Into Minecraft"), "Aborted login to Minecraft!");
loginDialog.addThread(new Thread(() -> {
@ -920,7 +861,7 @@ public class Instance extends MinecraftVersion {
loginDialog.start();
if (!(Boolean) loginDialog.getReturnValue()) {
LogManager.error("Failed to login");
LOG.error("Failed to login");
App.launcher.setMinecraftLaunched(false);
if (App.launcher.getParent() != null) {
App.launcher.getParent().setVisible(true);
@ -934,7 +875,7 @@ public class Instance extends MinecraftVersion {
if (enableCommands && preLaunchCommand != null) {
if (!executeCommand(preLaunchCommand)) {
LogManager.error("Failed to execute pre-launch command");
LOG.error("Failed to execute pre-launch command");
App.launcher.setMinecraftLaunched(false);
@ -950,7 +891,7 @@ public class Instance extends MinecraftVersion {
}
if (process == null) {
LogManager.error("Failed to get process for Minecraft");
LOG.error("Failed to get process for Minecraft");
App.launcher.setMinecraftLaunched(false);
if (App.launcher.getParent() != null) {
App.launcher.getParent().setVisible(true);
@ -1022,7 +963,7 @@ public class Instance extends MinecraftVersion {
detectedError = MinecraftError.USING_NEWER_JAVA_THAN_8;
}
if (!LogManager.showDebug) {
if (!LOG.isDebugEnabled()) {
line = line.replace(account.minecraftUsername, "**MINECRAFTUSERNAME**");
line = line.replace(account.username, "**MINECRAFTUSERNAME**");
line = line.replace(account.uuid, "**UUID**");
@ -1044,7 +985,7 @@ public class Instance extends MinecraftVersion {
// end of the xml object so parse it
if (line.contains("</log4j:Event>")) {
LogManager.minecraftLog4j(sb.toString());
LOG.error(MarkerManager.getMarker("minecraft"), sb);
sb.setLength(0);
}
@ -1054,7 +995,7 @@ public class Instance extends MinecraftVersion {
}
}
LogManager.minecraft(line);
LoggingUtils.minecraft(line);
}
App.launcher.hideKillMinecraft();
if (App.launcher.getParent() != null && App.settings.keepLauncherOpen) {
@ -1075,14 +1016,12 @@ public class Instance extends MinecraftVersion {
}
if (exitValue != 0) {
LogManager.error(
"Oh no. Minecraft crashed. Please check the logs for any errors and provide these logs when asking for support.");
LOG.error("Oh noes. Minecraft crashed. Please check the logs for any errors and provide these logs when asking for support.");
if (this.getPack() != null && !this.getPack().system) {
LogManager.info("Checking for modifications to the pack since installation.");
LOG.info("Checking for modifications to the pack since installation.");
this.launcher.mods.forEach(mod -> {
if (!mod.userAdded && mod.wasSelected && mod.disabled) {
LogManager.warn("The mod " + mod.name + " (" + mod.file + ") has been disabled.");
LOG.warn("The mod {} ({}) has been disabled.", mod.name, mod.file);
}
});
@ -1093,7 +1032,7 @@ public class Instance extends MinecraftVersion {
.noneMatch(m -> m.type == Type.mods && !m.userAdded
&& m.getFile(this).toPath().equals(file)))
.forEach(newMod -> {
LogManager.warn("The mod " + newMod.getFileName().toString() + " has been added.");
LOG.warn("The mod {} has been added.", newMod.getFileName());
});
}
@ -1110,7 +1049,7 @@ public class Instance extends MinecraftVersion {
if (enableCommands && postExitCommand != null) {
if (!executeCommand(postExitCommand)) {
LogManager.error("Failed to execute post-exit command");
LOG.error("Failed to execute post-exit command");
}
}
@ -1140,8 +1079,9 @@ public class Instance extends MinecraftVersion {
if (!App.settings.keepLauncherOpen) {
System.exit(0);
}
} catch (Exception e1) {
LogManager.logStackTrace(e1);
} catch (Exception e1){
LOG.error("error launching minecraft", e1);
App.launcher.setMinecraftLaunched(false);
if (App.launcher.getParent() != null) {
App.launcher.getParent().setVisible(true);
@ -1182,16 +1122,16 @@ public class Instance extends MinecraftVersion {
if (reportsDir.exists()) {
for (String filename : reportsDir.list(Utils.getOpenEyePendingReportsFileFilter())) {
File report = new File(reportsDir, filename);
LogManager.info("OpenEye: Sending pending crash report located at '" + report.getAbsolutePath() + "'");
LOG.info("OpenEye: Sending pending crash report located at '{}'", report.getAbsolutePath());
OpenEyeReportResponse response = Utils.sendOpenEyePendingReport(report);
if (response == null) {
// Pending report was never sent due to an issue. Won't delete the file in case
// it's
// a temporary issue and can be sent again later.
LogManager.error("OpenEye: Couldn't send pending crash report!");
LOG.error("OpenEye: Couldn't send pending crash report!");
} else {
// OpenEye returned a response to the report, display that to user if needed.
LogManager.info("OpenEye: Pending crash report sent! URL: " + response.getURL());
LOG.info("OpenEye: Pending crash report sent! URL: {}", response.getURL());
if (response.hasNote()) {
int ret = DialogManager.optionDialog().setTitle(GetText.tr("About Your Crash"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
@ -1221,7 +1161,7 @@ public class Instance extends MinecraftVersion {
try {
return Utils.sendAPICall("pack/" + this.getPack().getSafeName() + "/play", request);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error(e);
}
return "Play Not Added!";
}
@ -1235,7 +1175,7 @@ public class Instance extends MinecraftVersion {
try {
return Utils.sendAPICall("pack/" + this.getPack().getSafeName() + "/timeplayed/", request);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("Error adding time played", e);
}
return "Leaderboard Time Not Added!";
}
@ -1373,7 +1313,7 @@ public class Instance extends MinecraftVersion {
try {
download.downloadFile();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error(e);
DialogManager.okDialog().setType(DialogManager.ERROR).setTitle("Failed to download")
.setContent("Failed to download " + file.fileName + ". Please try again later.").show();
return;
@ -1440,7 +1380,7 @@ public class Instance extends MinecraftVersion {
try {
download.downloadFile();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error downloading file", e);
DialogManager.okDialog().setType(DialogManager.ERROR).setTitle("Failed to download")
.setContent("Failed to download " + fileToDownload.filename + ". Please try again later.")
.show();
@ -1526,7 +1466,7 @@ public class Instance extends MinecraftVersion {
public boolean canBeExported() {
if (launcher.loaderVersion == null) {
LogManager.debug("Instance " + launcher.name + " cannot be exported due to: No loader");
LOG.debug("Instance {} cannot be exported due to: No loader", launcher.name);
return false;
}
@ -1683,9 +1623,8 @@ public class Instance extends MinecraftVersion {
// create mmc-pack.json
try (FileWriter fileWriter = new FileWriter(tempDir.resolve("mmc-pack.json").toFile())) {
Gsons.MINECRAFT.toJson(manifest, fileWriter);
} catch (JsonIOException | IOException e) {
LogManager.logStackTrace("Failed to save mmc-pack.json", e);
} catch (JsonIOException | IOException e){
LOG.error("Failed to save mmc-pack.json", e);
FileUtils.deleteDirectory(tempDir);
return false;
@ -1755,7 +1694,7 @@ public class Instance extends MinecraftVersion {
try (OutputStream outputStream = Files.newOutputStream(instanceCfgPath)) {
instanceCfg.store(outputStream, "Exported by ATLauncher");
} catch (JsonIOException | IOException e) {
LogManager.logStackTrace("Failed to save mmc-pack.json", e);
LOG.error("Failed to save mmc-pack.json", e);
FileUtils.deleteDirectory(tempDir);
@ -1810,7 +1749,7 @@ public class Instance extends MinecraftVersion {
long hash = Hashing.murmur(dm.getFile(this.ROOT, this.id).toPath());
murmurHashes.put(hash, dm);
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error(t);
}
});
@ -1846,7 +1785,7 @@ public class Instance extends MinecraftVersion {
dm.curseForgeProject = curseForgeProject;
}
LogManager.debug("Found matching mod from CurseForge called "
LOG.debug("Found matching mod from CurseForge called "
+ dm.curseForgeFile.displayName);
});
}
@ -1895,8 +1834,7 @@ public class Instance extends MinecraftVersion {
try (FileWriter fileWriter = new FileWriter(tempDir.resolve("manifest.json").toFile())) {
Gsons.MINECRAFT.toJson(manifest, fileWriter);
} catch (JsonIOException | IOException e) {
LogManager.logStackTrace("Failed to save manifest.json", e);
LOG.error("Failed to save manifest.json", e);
FileUtils.deleteDirectory(tempDir);
return false;
@ -1916,8 +1854,8 @@ public class Instance extends MinecraftVersion {
try (FileWriter fileWriter = new FileWriter(tempDir.resolve("modlist.html").toFile())) {
fileWriter.write(sb.toString());
} catch (JsonIOException | IOException e) {
LogManager.logStackTrace("Failed to save modlist.html", e);
} catch (JsonIOException | IOException e){
LOG.error("Failed to save modlist.html", e);
FileUtils.deleteDirectory(tempDir);
@ -1998,7 +1936,7 @@ public class Instance extends MinecraftVersion {
mod.modrinthVersion = modrinthVersion;
LogManager.debug("Found matching version from Modrinth called " + mod.modrinthVersion.name);
LOG.debug("Found matching version from Modrinth called " + mod.modrinthVersion.name);
if (modrinthProjects.containsKey(modrinthVersions.get(hash).projectId)) {
mod.modrinthProject = modrinthProjects.get(modrinthVersion.projectId);
@ -2065,7 +2003,7 @@ public class Instance extends MinecraftVersion {
try (FileWriter fileWriter = new FileWriter(tempDir.resolve("modrinth.index.json").toFile())) {
Gsons.MINECRAFT.toJson(manifest, fileWriter);
} catch (JsonIOException | IOException e) {
LogManager.logStackTrace("Failed to save modrinth.index.json", e);
LOG.error("Failed to save modrinth.index.json", e);
FileUtils.deleteDirectory(tempDir);
@ -2135,8 +2073,8 @@ public class Instance extends MinecraftVersion {
public void save() {
try (FileWriter fileWriter = new FileWriter(this.getRoot().resolve("instance.json").toFile())) {
Gsons.MINECRAFT.toJson(this, fileWriter);
} catch (JsonIOException | IOException e) {
LogManager.logStackTrace(e);
} catch (JsonIOException | IOException e){
LOG.error("failed to save instance", e);
}
}
@ -2464,14 +2402,14 @@ public class Instance extends MinecraftVersion {
}));
dialog.start();
} else if (clonedName == null || clonedName.equals("")) {
LogManager.error("Error Occurred While Cloning Instance! Dialog Closed/Cancelled!");
LOG.error("Error Occurred While Cloning Instance! Dialog Closed/Cancelled!");
DialogManager.okDialog().setTitle(GetText.tr("Error"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
"An error occurred while cloning the instance.<br/><br/>Please check the console and try again."))
.build())
.setType(DialogManager.ERROR).show();
} else if (clonedName.replaceAll("[^A-Za-z0-9]", "").length() == 0) {
LogManager.error("Error Occurred While Cloning Instance! Invalid Name!");
LOG.error("Error Occurred While Cloning Instance! Invalid Name!");
DialogManager.okDialog().setTitle(GetText.tr("Error"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
"An error occurred while cloning the instance.<br/><br/>Please check the console and try again."))
@ -2479,7 +2417,7 @@ public class Instance extends MinecraftVersion {
.setType(DialogManager.ERROR).show();
} else if (Files
.exists(FileSystem.INSTANCES.resolve(clonedName.replaceAll("[^A-Za-z0-9]", "")))) {
LogManager.error(
LOG.error(
"Error Occurred While Cloning Instance! Folder Already Exists Rename It And Try Again!");
DialogManager.okDialog().setTitle(GetText.tr("Error"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
@ -2487,7 +2425,7 @@ public class Instance extends MinecraftVersion {
.build())
.setType(DialogManager.ERROR).show();
} else {
LogManager.error(
LOG.error(
"Error Occurred While Cloning Instance! Instance With That Name Already Exists!");
DialogManager.okDialog().setTitle(GetText.tr("Error"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
@ -2528,7 +2466,7 @@ public class Instance extends MinecraftVersion {
Utils.safeCopy(img, getRoot().resolve("instance.png").toFile());
save();
} catch (IOException ex) {
LogManager.logStackTrace("Failed to set instance image", ex);
LOG.error("Failed to set instance image", ex);
}
}
}
@ -2558,7 +2496,7 @@ public class Instance extends MinecraftVersion {
success = installable.startInstall();
} catch (InvalidMinecraftVersion e) {
LogManager.logStackTrace(e);
LOG.error("error changing loader version", e);
}
if (success) {
@ -2602,8 +2540,8 @@ public class Instance extends MinecraftVersion {
installable.saveMods = true;
success = installable.startInstall();
} catch (InvalidMinecraftVersion e) {
LogManager.logStackTrace(e);
} catch (InvalidMinecraftVersion e){
LOG.error("error adding loader {}", loaderType, e);
}
if (success) {
@ -2737,7 +2675,7 @@ public class Instance extends MinecraftVersion {
success = installable.startInstall();
} catch (InvalidMinecraftVersion e) {
LogManager.logStackTrace(e);
LOG.error("error removing loader", e);
}
if (success) {
@ -2798,7 +2736,7 @@ public class Instance extends MinecraftVersion {
if (Files.isDirectory(runtimeDirectory)) {
javaPath = runtimeDirectory.toAbsolutePath().toString();
LogManager.debug(String.format("Using Java runtime %s (major version %d) at path %s",
LOG.debug(String.format("Using Java runtime %s (major version %d) at path %s",
javaVersion.component, javaVersion.majorVersion, javaPath));
}
}

View file

@ -26,12 +26,15 @@ import java.util.Map;
import com.atlauncher.App;
import com.atlauncher.evnt.manager.RelocalizationManager;
import com.atlauncher.managers.LogManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.mini2Dx.gettext.PoFile;
public class Language {
private static final Logger LOG = LogManager.getLogger(Language.class);
public final static List<Locale> locales = new ArrayList<>();
public final static Map<String, Locale> languages = new HashMap<>();
public static String selected = Locale.ENGLISH.getDisplayName();
@ -46,7 +49,7 @@ public class Language {
if (App.class.getResourceAsStream("/assets/lang/" + locale.toString() + ".po") != null) {
System.out.println(locale.toString());
languages.put(locale.getDisplayName(), locale);
LogManager.debug("Loaded language " + locale.getDisplayName() + " with key of " + locale);
LOG.debug("Loaded language " + locale.getDisplayName() + " with key of " + locale);
}
}
}
@ -59,11 +62,11 @@ public class Language {
Locale locale;
if (isLanguageByName(language)) {
LogManager.info("Language set to " + language);
LOG.info("Language set to " + language);
locale = languages.get(language);
selected = language;
} else {
LogManager.info("Unknown language " + language + ". Defaulting to " + Locale.ENGLISH.getDisplayName());
LOG.info("Unknown language " + language + ". Defaulting to " + Locale.ENGLISH.getDisplayName());
locale = Locale.ENGLISH;
selected = Locale.ENGLISH.getDisplayName();
}
@ -73,7 +76,7 @@ public class Language {
GetText.add(
new PoFile(locale, App.class.getResourceAsStream("/assets/lang/" + locale.toString() + ".po")));
} catch (IOException e) {
LogManager.logStackTrace("Failed loading language po file for " + language, e);
LOG.error("Failed loading language po file for " + language, e);
locale = Locale.ENGLISH;
selected = Locale.ENGLISH.getDisplayName();
}

View file

@ -30,13 +30,16 @@ import com.atlauncher.data.microsoft.XboxLiveAuthResponse;
import com.atlauncher.gui.dialogs.LoginWithMicrosoftDialog;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.DownloadException;
import com.atlauncher.utils.MicrosoftAuthAPI;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
public class MicrosoftAccount extends AbstractAccount {
private static final Logger LOG = LogManager.getLogger(MicrosoftAccount.class);
/**
* Auto generated serial.
*/
@ -109,12 +112,12 @@ public class MicrosoftAccount extends AbstractAccount {
try {
profile = MicrosoftAuthAPI.getMcProfile(accessToken);
} catch (Exception e) {
LogManager.error("Error getting Minecraft profile");
LOG.error("Error getting Minecraft profile");
return null;
}
if (profile == null) {
LogManager.error("Error getting Minecraft profile");
LOG.error("Error getting Minecraft profile");
return null;
}
@ -133,12 +136,12 @@ public class MicrosoftAccount extends AbstractAccount {
try {
profile = MicrosoftAuthAPI.getMcProfile(accessToken);
} catch (Exception e) {
LogManager.error("Error getting Minecraft profile");
LOG.error("Error getting Minecraft profile");
return null;
}
if (profile == null) {
LogManager.error("Error getting Minecraft profile");
LOG.error("Error getting Minecraft profile");
return null;
}
@ -153,13 +156,13 @@ public class MicrosoftAccount extends AbstractAccount {
public boolean refreshAccessToken(boolean force) {
try {
if (force || new Date().after(this.oauthToken.expiresAt)) {
LogManager.info("Oauth token expired. Attempting to refresh");
LOG.info("Oauth token expired. Attempting to refresh");
OauthTokenResponse oauthTokenResponse = MicrosoftAuthAPI.refreshAccessToken(oauthToken.refreshToken);
if (oauthTokenResponse == null) {
mustLogin = true;
AccountManager.saveAccounts();
LogManager.error("Failed to refresh accessToken");
LOG.error("Failed to refresh accessToken");
return false;
}
@ -169,14 +172,14 @@ public class MicrosoftAccount extends AbstractAccount {
}
if (force || new Date().after(this.xstsAuth.notAfter)) {
LogManager.info("xsts auth expired. Attempting to get new auth");
LOG.info("xsts auth expired. Attempting to get new auth");
XboxLiveAuthResponse xboxLiveAuthResponse = MicrosoftAuthAPI.getXBLToken(this.oauthToken.accessToken);
this.xstsAuth = MicrosoftAuthAPI.getXstsToken(xboxLiveAuthResponse.token);
if (xstsAuth == null) {
mustLogin = true;
AccountManager.saveAccounts();
LogManager.error("Failed to get XBLToken");
LOG.error("Failed to get XBLToken");
return false;
}
@ -189,7 +192,7 @@ public class MicrosoftAccount extends AbstractAccount {
if (loginResponse == null) {
mustLogin = true;
AccountManager.saveAccounts();
LogManager.error("Failed to login to Minecraft");
LOG.error("Failed to login to Minecraft");
return false;
}
@ -197,7 +200,7 @@ public class MicrosoftAccount extends AbstractAccount {
if (!(entitlements.items.stream().anyMatch(i -> i.name.equalsIgnoreCase("product_minecraft"))
&& entitlements.items.stream().anyMatch(i -> i.name.equalsIgnoreCase("game_minecraft")))) {
LogManager.error("This account doesn't have a valid purchase of Minecraft");
LOG.error("This account doesn't have a valid purchase of Minecraft");
return false;
}
@ -223,7 +226,7 @@ public class MicrosoftAccount extends AbstractAccount {
mustLogin = true;
AccountManager.saveAccounts();
LogManager.logStackTrace("Exception refreshing accessToken", e);
LOG.error("Exception refreshing accessToken", e);
return false;
}
@ -246,7 +249,7 @@ public class MicrosoftAccount extends AbstractAccount {
try {
profile = MicrosoftAuthAPI.getMcProfile(accessToken);
} catch (DownloadException e) {
LogManager.error("Minecraft Profile not found");
LOG.error("Minecraft Profile not found");
DialogManager.okDialog().setTitle(GetText.tr("Minecraft Profile Not Found"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
"No Minecraft profiles were found for this account. Have you purchased Minecraft?<br/><br/>Please make sure you've bought the Java edition of Minecraft and then try again.<br/><br/>If you're an Xbox Game Pass subscriber, make sure to login and play through the Minecraft<br/>Launcher once in order to create your Minecraft profile, then try logging in again."))
@ -254,12 +257,12 @@ public class MicrosoftAccount extends AbstractAccount {
.setType(DialogManager.ERROR).show();
return false;
} catch (Exception e) {
LogManager.logStackTrace("Failed to get Minecraft profile", e);
LOG.error("Failed to get Minecraft profile", e);
return false;
}
if (profile == null) {
LogManager.error("Failed to get Minecraft profile");
LOG.error("Failed to get Minecraft profile");
return false;
}
@ -304,12 +307,12 @@ public class MicrosoftAccount extends AbstractAccount {
return true;
}
LogManager.info("Access Token has expired. Attempting to refresh it.");
LOG.info("Access Token has expired. Attempting to refresh it.");
try {
return refreshAccessToken();
} catch (Exception e) {
LogManager.logStackTrace("Exception while attempting to refresh access token", e);
LOG.error("Exception while attempting to refresh access token", e);
}
return false;

View file

@ -36,14 +36,17 @@ import com.atlauncher.data.mojang.api.MinecraftProfileResponse;
import com.atlauncher.data.mojang.api.ProfileTexture;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Authentication;
import com.atlauncher.utils.MojangAPIUtils;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
public class MojangAccount extends AbstractAccount {
public class MojangAccount extends AbstractAccount{
private static final Logger LOG = LogManager.getLogger(MojangAccount.class);
/**
* Auto generated serial.
*/
@ -131,7 +134,7 @@ public class MojangAccount extends AbstractAccount {
@Override
public String getCurrentUsername() {
if (this.uuid == null) {
LogManager.error("The account " + this.minecraftUsername + " has no UUID associated with it !");
LOG.error("The account {} has no UUID associated with it !", this.minecraftUsername);
return null;
}
@ -175,7 +178,7 @@ public class MojangAccount extends AbstractAccount {
}
reader.close();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
response = null;
}
@ -212,12 +215,12 @@ public class MojangAccount extends AbstractAccount {
LoginResponse response = null;
if (this.getAccessToken() != null) {
LogManager.info("Trying to login with access token!");
LOG.info("Trying to login with access token!");
response = Authentication.login(this, false);
}
if (response == null || (response.hasError() && !response.isOffline())) {
LogManager.error("Access token is NOT valid! Will attempt to get another one!");
LOG.error("Access token is NOT valid! Will attempt to get another one!");
if (!this.remember) {
JPanel panel = new JPanel();
@ -232,14 +235,14 @@ public class MojangAccount extends AbstractAccount {
if (ret == DialogManager.OK_OPTION) {
if (passwordField.getPassword().length == 0) {
LogManager.error("Aborting login for " + this.minecraftUsername + ", no password entered");
LOG.error("Aborting login for {}, no password entered", this.minecraftUsername);
App.launcher.setMinecraftLaunched(false);
return null;
}
this.setPassword(new String(passwordField.getPassword()));
} else {
LogManager.error("Aborting login for " + this.minecraftUsername);
LOG.error("Aborting login for {}", this.minecraftUsername);
App.launcher.setMinecraftLaunched(false);
return null;
}
@ -249,7 +252,7 @@ public class MojangAccount extends AbstractAccount {
}
if (response.hasError() && !response.isOffline()) {
LogManager.error(response.getErrorMessage());
LOG.error("error: {}", response.getErrorMessage());
DialogManager
.okDialog().setTitle(

View file

@ -23,14 +23,17 @@ import java.text.SimpleDateFormat;
import com.atlauncher.App;
import com.atlauncher.annot.Json;
import com.atlauncher.managers.LogManager;
import com.google.gson.annotations.SerializedName;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* News class contains a single news article.
*/
@Json
public class News {
private static final Logger LOG = LogManager.getLogger(News.class);
/**
* The title of this news article.
*/
@ -54,7 +57,7 @@ public class News {
try {
return formatter.format(iso8601Format.parse(this.createdAt));
} catch (ParseException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return null;
}
}

View file

@ -35,11 +35,14 @@ import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
import com.atlauncher.data.modrinth.ModrinthProject;
import com.atlauncher.data.technic.TechnicModpack;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.PackManager;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Pack {
private static final Logger LOG = LogManager.getLogger(Pack.class);
public int id;
public int externalId;
public boolean vanillaInstance = false;
@ -316,7 +319,7 @@ public class Pack {
try {
return Utils.sendAPICall("pack/" + getSafeName() + "/installed/", request);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return "Install Not Added!";
}
@ -329,7 +332,7 @@ public class Pack {
try {
return Utils.sendAPICall("pack/" + getSafeName() + "/serverinstalled/", request);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return "Install Not Added!";
}
@ -342,7 +345,7 @@ public class Pack {
try {
return Utils.sendAPICall("pack/" + getSafeName() + "/updated/", request);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return "Install Not Added!";
}

View file

@ -20,15 +20,18 @@ package com.atlauncher.data;
import java.lang.reflect.Type;
import com.atlauncher.exceptions.InvalidMinecraftVersion;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class PackVersionTypeAdapter implements JsonDeserializer<PackVersion> {
private static final Logger LOG = LogManager.getLogger(PackVersionTypeAdapter.class);
@Override
public PackVersion deserialize(JsonElement json, Type type, JsonDeserializationContext context)
throws JsonParseException {
@ -50,7 +53,7 @@ public class PackVersionTypeAdapter implements JsonDeserializer<PackVersion> {
packVersion.minecraftVersion = MinecraftManager
.getMinecraftVersion(rootJsonObject.get("minecraft").getAsString());
} catch (InvalidMinecraftVersion e) {
LogManager.error(e.getMessage());
LOG.error("error:", e);
}
}

View file

@ -43,7 +43,6 @@ import com.atlauncher.data.minecraft.JavaVersion;
import com.atlauncher.exceptions.InvalidPack;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.PackManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.ArchiveUtils;
@ -51,10 +50,14 @@ import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import com.google.gson.JsonIOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
@Json
public class Server {
public class Server{
private static final Logger LOG = LogManager.getLogger(Server.class);
public String name;
public String pack;
public Integer packId;
@ -115,7 +118,7 @@ public class Server {
serverScript += ".sh";
}
LogManager.info("Starting server " + name);
LOG.info("Starting server " + name);
List<String> arguments = new ArrayList<>();
String javaPath = null;
@ -125,7 +128,7 @@ public class Server {
if (Files.isDirectory(runtimeDirectory)) {
javaPath = runtimeDirectory.toAbsolutePath().toString();
LogManager.debug(String.format("Using Java runtime %s (major version %d) at path %s",
LOG.debug(String.format("Using Java runtime %s (major version %d) at path %s",
javaVersion.component, javaVersion.majorVersion, javaPath));
}
}
@ -203,7 +206,7 @@ public class Server {
StandardOpenOption.TRUNCATE_EXISTING);
tempLaunchFile.toFile().setExecutable(true);
LogManager.info(String.format("Running \"%s\" from \".launcherrun.sh\"",
LOG.info(String.format("Running \"%s\" from \".launcherrun.sh\"",
String.join(" ", launchScript)));
launchCommand = "./.launcherrun.sh";
@ -215,7 +218,7 @@ public class Server {
arguments.add(launchCommand);
}
LogManager.info("Launching server with the following arguments: " + arguments.toString());
LOG.info("Launching server with the following arguments: {}", arguments);
ProcessBuilder processBuilder = new ProcessBuilder();
processBuilder.directory(getRoot().toFile());
processBuilder.command(arguments);
@ -231,7 +234,7 @@ public class Server {
System.exit(0);
}
} catch (IOException e) {
LogManager.logStackTrace("Failed to launch server", e);
LOG.error("Failed to launch server", e);
}
}
@ -254,7 +257,7 @@ public class Server {
if (progressDialog.getReturnValue()) {
App.TOASTER.pop(GetText.tr("Backup is complete"));
LogManager.info(String.format("Backup complete and stored at %s", backupZip.toString()));
LOG.info("Backup complete and stored at {}", backupZip);
} else {
App.TOASTER.popError(GetText.tr("Error making backup"));
}
@ -320,7 +323,7 @@ public class Server {
Image dimg = img.getScaledInstance(300, 150, Image.SCALE_SMOOTH);
return new ImageIcon(dimg);
} catch (IOException e) {
LogManager.logStackTrace("Error creating scaled image from the custom image of server " + this.name, e);
LOG.error("Error creating scaled image from the custom image of server " + this.name, e);
}
}
@ -338,7 +341,7 @@ public class Server {
try (FileWriter fileWriter = new FileWriter(this.getRoot().resolve("server.json").toFile())) {
Gsons.MINECRAFT.toJson(this, fileWriter);
} catch (JsonIOException | IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
}

View file

@ -35,13 +35,18 @@ import java.util.UUID;
import com.atlauncher.FileSystem;
import com.atlauncher.Gsons;
import com.atlauncher.constants.Constants;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Timestamper;
import com.atlauncher.utils.Utils;
import com.atlauncher.utils.sort.InstanceSortingStrategies;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Settings {
private static final Logger LOG = LogManager.getLogger(Settings.class);
// Launcher things
public String lastAccount;
public boolean usingCustomJavaPath = false;
@ -384,7 +389,7 @@ public class Settings {
// now validate the java path actually exists
if (!new File(javaPath, "bin" + File.separator + "java" + (OS.isWindows() ? ".exe" : "")).exists()) {
LogManager.warn("Custom Java Path Is Incorrect! Defaulting to valid value!");
LOG.warn("Custom Java Path Is Incorrect! Defaulting to valid value!");
javaPath = OS.getDefaultJavaPath();
}
}
@ -394,19 +399,19 @@ public class Settings {
int systemMemory = OS.getMaximumRam();
if (systemMemory != 0 && initialMemory > systemMemory) {
LogManager.warn("Tried to allocate " + initialMemory + "MB for initial memory but only " + systemMemory
LOG.warn("Tried to allocate " + initialMemory + "MB for initial memory but only " + systemMemory
+ "MB is available to use!");
initialMemory = 512;
needToSave = true;
} else if (initialMemory > maximumMemory) {
LogManager.warn("Tried to allocate " + initialMemory + "MB for initial memory which is more than "
LOG.warn("Tried to allocate " + initialMemory + "MB for initial memory which is more than "
+ maximumMemory + "MB set for the maximum memory!");
initialMemory = 512;
needToSave = true;
}
if (systemMemory != 0 && maximumMemory > systemMemory) {
LogManager.warn("Tried to allocate " + maximumMemory + "MB of maximum memory but only " + systemMemory
LOG.warn("Tried to allocate " + maximumMemory + "MB of maximum memory but only " + systemMemory
+ "MB is available to use!");
if (OS.is64Bit()) {
@ -426,7 +431,7 @@ public class Settings {
private void validateWindowSize() {
int systemWindowWidth = OS.getMaximumWindowWidth();
if (windowWidth > systemWindowWidth) {
LogManager.warn("Tried to set window width to " + windowWidth + "px but the maximum is " + systemWindowWidth
LOG.warn("Tried to set window width to " + windowWidth + "px but the maximum is " + systemWindowWidth
+ "px!");
windowWidth = systemWindowWidth;
@ -434,7 +439,7 @@ public class Settings {
int systemWindowHeight = OS.getMaximumWindowHeight();
if (windowHeight > systemWindowHeight) {
LogManager.warn("Tried to set window height to " + windowHeight + "px but the maximum is "
LOG.warn("Tried to set window height to " + windowHeight + "px but the maximum is "
+ systemWindowHeight + "px!");
windowHeight = systemWindowHeight;
@ -444,14 +449,14 @@ public class Settings {
private void validateProxy() {
if (enableProxy) {
if (proxyPort <= 0 || proxyPort > 65535) {
LogManager.warn("Tried to set proxy port to " + proxyPort
LOG.warn("Tried to set proxy port to " + proxyPort
+ " which is not a valid port! Proxy support disabled!");
enableProxy = false;
proxyPort = 8080;
}
if (!proxyType.equals("SOCKS") && !proxyType.equals("HTTP") && !proxyType.equals("DIRECT")) {
LogManager.warn(
LOG.warn(
"Tried to set proxy type to " + proxyType + " which is not valid! Proxy support disabled!");
enableProxy = false;
proxyType = "HTTP";
@ -481,7 +486,7 @@ public class Settings {
private void validateConcurrentConnections() {
if (concurrentConnections < 1) {
LogManager.warn("Tried to set the number of concurrent connections to " + concurrentConnections
LOG.warn("Tried to set the number of concurrent connections to " + concurrentConnections
+ " which is not valid! Must be 1 or more. Setting back to default of 8!");
concurrentConnections = 8;
}
@ -489,7 +494,7 @@ public class Settings {
private void validateDateFormat() {
if (!Arrays.asList(Constants.DATE_FORMATS).contains(dateFormat)) {
LogManager.warn("Tried to set the date format to " + dateFormat + " which is not valid! Setting "
LOG.warn("Tried to set the date format to " + dateFormat + " which is not valid! Setting "
+ "back to default of " + Constants.DATE_FORMATS[0] + "!");
dateFormat = Constants.DATE_FORMATS[0];
}
@ -497,8 +502,7 @@ public class Settings {
private void validateInstanceTitleFormat() {
if (!Arrays.asList(Constants.INSTANCE_TITLE_FORMATS).contains(instanceTitleFormat)) {
LogManager.warn(
"Tried to set the instance title format to " + instanceTitleFormat + " which is not valid! Setting "
LOG.warn("Tried to set the instance title format to " + instanceTitleFormat + " which is not valid! Setting "
+ "back to default of " + Constants.INSTANCE_TITLE_FORMATS[0] + "!");
instanceTitleFormat = Constants.INSTANCE_TITLE_FORMATS[0];
}
@ -519,13 +523,13 @@ public class Settings {
try (FileWriter writer = new FileWriter(FileSystem.SETTINGS.toFile())) {
Gsons.DEFAULT.toJson(this, writer);
} catch (IOException e) {
LogManager.logStackTrace("Error saving settings", e);
LOG.error("Error saving settings", e);
}
try {
Timestamper.updateDateFormat(dateFormat);
} catch (Exception e) {
LogManager.logStackTrace("Error updating date format to " + dateFormat, e);
LOG.error("Error updating date format to " + dateFormat, e);
}
}
}

View file

@ -47,14 +47,18 @@ import com.atlauncher.data.multimc.MultiMCManifest;
import com.atlauncher.data.technic.TechnicModpack;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.ServerManager;
import com.atlauncher.utils.FileUtils;
import com.atlauncher.workers.InstanceInstaller;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
public abstract class Installable {
private static final Logger LOG = LogManager.getLogger(Installable.class);
public String instanceName;
public boolean isServer = false;
public boolean isUpdate = false;
@ -207,7 +211,7 @@ public abstract class Installable {
Thread.currentThread().interrupt();
return;
} catch (ExecutionException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
if (success) {

View file

@ -25,11 +25,14 @@ import java.util.Map;
import com.atlauncher.annot.Json;
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.managers.LogManager;
import com.atlauncher.workers.InstanceInstaller;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Json
public class Loader {
private static final Logger LOG = LogManager.getLogger(Loader.class);
public String type;
public boolean choose = false;
public Map<String, Object> metadata;
@ -83,7 +86,7 @@ public class Loader {
return (List<LoaderVersion>) method.invoke(null, minecraft);
} catch (NoSuchMethodException | SecurityException | ClassNotFoundException | IllegalAccessException
| IllegalArgumentException | InvocationTargetException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return null;

View file

@ -33,15 +33,19 @@ import com.atlauncher.data.curseforge.CurseForgeProject;
import com.atlauncher.data.modrinth.ModrinthProject;
import com.atlauncher.data.modrinth.ModrinthVersion;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Hashing;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import com.atlauncher.workers.InstanceInstaller;
import com.google.gson.annotations.SerializedName;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Json
public class Mod {
private static final Logger LOG = LogManager.getLogger(Mod.class);
public String name;
public String version;
public String url;
@ -461,7 +465,7 @@ public class Mod {
} else if (retValue == 0) {
OS.openFileExplorer(FileSystem.DOWNLOADS);
} else if (retValue == 2) {
LogManager.warn(String.format("Skipping browser download of mod %s", name));
LOG.warn(String.format("Skipping browser download of mod %s", name));
return false;
}
} while (retValue != 1);
@ -527,7 +531,7 @@ public class Mod {
Utils.delete(fileLocation); // MD5 hash doesn't match, delete it
return downloadClient(installer, ++attempt); // download again
} else {
LogManager.error("Cannot download " + fileLocation.getAbsolutePath() + ". Aborting install!");
LOG.error("Cannot download {}. Aborting install!", fileLocation.getAbsolutePath());
installer.cancel(true);
return false;
}
@ -663,7 +667,7 @@ public class Mod {
Utils.delete(fileLocation); // MD5 hash doesn't match, delete it
return downloadServer(installer, ++attempt); // download again
} else {
LogManager.error("Cannot download " + fileLocation.getAbsolutePath() + ". Aborting install!");
LOG.error("Cannot download {}. Aborting install!", fileLocation.getAbsolutePath());
installer.cancel(true);
return false;
}
@ -810,7 +814,7 @@ public class Mod {
Utils.copyDirectory(folder, installer.root.toFile());
break;
default:
LogManager.error("No known way to extract mod " + this.name + " with type " + this.extractTo);
LOG.error("No known way to extract mod {} with type {}", this.name, this.extractTo);
break;
}
Utils.delete(tempDirExtract);
@ -858,17 +862,17 @@ public class Mod {
}
break;
default:
LogManager
.error("No known way to decomp mod " + this.name + " with type " + this.decompType);
LOG.error("No known way to decomp mod {} with type {}", this.name, this.decompType);
break;
}
} else {
LogManager.error("Couldn't find decomp file " + this.decompFile + " for mod " + this.name);
LOG.error("Couldn't find decomp file {} for mod {}", this.decompFile, this.name);
}
Utils.delete(tempDirDecomp);
break;
default:
LogManager.error("No known way to install mod " + this.name + " with type " + thisType);
LOG.error("No known way to install mod {} with type {}", this.name, thisType);
break;
}
}
@ -924,7 +928,7 @@ public class Mod {
base = installer.root.resolve("shaderpacks").toFile();
break;
default:
LogManager.error("No known way to find installed mod " + this.name + " with type " + thisType);
LOG.error("No known way to find installed mod {} with type {}", this.name, thisType);
break;
}
if (path != null) {

View file

@ -27,16 +27,19 @@ import java.util.stream.Collectors;
import com.atlauncher.annot.Json;
import com.atlauncher.data.DisableableMod;
import com.atlauncher.managers.LogManager;
import com.atlauncher.workers.InstanceInstaller;
import com.google.gson.annotations.SerializedName;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* This class contains information about a pack's version. This is a singular
* version and contains all the information necessary to install the pack.
*/
@Json
public class Version {
public class Version{
private static final Logger LOG = LogManager.getLogger(Version.class);
/**
* The version this pack's version is.
*/
@ -355,16 +358,16 @@ public class Version {
if (key == null) {
return null;
}
if (!this.isColour(key)) {
LogManager.warn("Colour with key " + key + " not found!");
if (!this.isColour(key)){
LOG.warn("Colour with key {} not found!", key);
return null;
}
String colour = this.colours.get(key);
if (colour.charAt(0) == '#') {
colour = colour.replace("#", "");
}
if (!colour.matches("[0-9A-Fa-f]{6}")) {
LogManager.warn("Colour with key " + key + " has invalid value of " + colour + "!");
if (!colour.matches("[0-9A-Fa-f]{6}")){
LOG.warn("Colour with key {} has invalid value of {}!", key, colour);
return null;
}
int r, g, b;
@ -373,8 +376,8 @@ public class Version {
g = Integer.parseInt(colour.substring(2, 4), 16);
b = Integer.parseInt(colour.substring(4, 6), 16);
return new Color(r, g, b);
} catch (NumberFormatException e) {
LogManager.warn("Colour with key " + key + " failed to create object with value of " + colour + "!");
} catch (NumberFormatException e){
LOG.warn("Colour with key {} failed to create object with value of {}!", key, colour);
return null;
}
}

View file

@ -42,13 +42,16 @@ import com.atlauncher.data.minecraft.Library;
import com.atlauncher.data.minecraft.loaders.Loader;
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Download;
import com.atlauncher.utils.Utils;
import com.atlauncher.workers.InstanceInstaller;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class FabricLoader implements Loader {
private static final Logger LOG = LogManager.getLogger(FabricLoader.class);
protected String minecraft;
protected FabricMetaVersion version;
protected File tempDir;
@ -67,7 +70,7 @@ public class FabricLoader implements Loader {
} else if (metadata.containsKey("loader")) {
this.version = this.getVersion((String) metadata.get("loader"));
} else if ((boolean) metadata.get("latest")) {
LogManager.debug("Downloading latest Fabric version");
LOG.debug("Downloading latest Fabric version");
this.version = this.getLatestVersion();
}
}
@ -204,7 +207,7 @@ public class FabricLoader implements Loader {
.getBytes(StandardCharsets.UTF_8));
propertiesOutputStream.close();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}

View file

@ -30,12 +30,16 @@ import com.atlauncher.Gsons;
import com.atlauncher.data.minecraft.ArgumentRule;
import com.atlauncher.data.minecraft.Arguments;
import com.atlauncher.data.minecraft.Library;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.FileUtils;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class Forge113Loader extends ForgeLoader {
private static final Logger LOG = LogManager.getLogger(Forge113Loader.class);
@Override
public ForgeInstallProfile getInstallProfile() {
ForgeInstallProfile installProfile = super.getInstallProfile();
@ -81,7 +85,7 @@ public class Forge113Loader extends ForgeLoader {
try {
version = Gsons.MINECRAFT.fromJson(new FileReader(new File(this.tempDir, "version.json")), Version.class);
} catch (JsonSyntaxException | JsonIOException | FileNotFoundException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return version;
@ -95,8 +99,7 @@ public class Forge113Loader extends ForgeLoader {
try {
processor.process(installProfile, this.tempDir, instanceInstaller);
} catch (IOException e) {
LogManager.logStackTrace(e);
LogManager.error("Failed to process processor with jar " + processor.getJar());
LOG.error("Failed to process processor with jar {}", processor.getJar(), e);
instanceInstaller.cancel(true);
}
}

View file

@ -28,7 +28,6 @@ import com.atlauncher.Network;
import com.atlauncher.constants.Constants;
import com.atlauncher.data.minecraft.Download;
import com.atlauncher.data.minecraft.Downloads;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Hashing;
import com.atlauncher.utils.Utils;
import com.google.gson.Gson;
@ -41,8 +40,13 @@ import com.google.gson.reflect.TypeToken;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class ForgeLibraryTypeAdapter implements JsonDeserializer<ForgeLibrary> {
private static final Logger LOG = LogManager.getLogger(ForgeLibraryTypeAdapter.class);
@Override
public ForgeLibrary deserialize(JsonElement json, Type type, JsonDeserializationContext context)
throws JsonParseException {
@ -135,7 +139,7 @@ public class ForgeLibraryTypeAdapter implements JsonDeserializer<ForgeLibrary> {
artifact.sha1 = Hashing.sha1(downloadedLibrary).toString();
}
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error("error", t);
}
}

View file

@ -38,15 +38,19 @@ import com.atlauncher.data.minecraft.Library;
import com.atlauncher.data.minecraft.loaders.Loader;
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Download;
import com.atlauncher.utils.FileUtils;
import com.atlauncher.workers.InstanceInstaller;
import com.google.gson.reflect.TypeToken;
import okhttp3.OkHttpClient;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class ForgeLoader implements Loader {
private static final Logger LOG = LogManager.getLogger(ForgeLoader.class);
protected String installerUrl;
protected String version;
protected String rawVersion;
@ -83,10 +87,10 @@ public class ForgeLoader implements Loader {
this.rawVersion = (String) metadata.get("rawVersion");
}
} else if ((boolean) metadata.get("latest")) {
LogManager.debug("Downloading latest Forge version");
LOG.debug("Downloading latest Forge version");
this.version = this.getLatestVersion();
} else if ((boolean) metadata.get("recommended")) {
LogManager.debug("Downloading recommended Forge version");
LOG.debug("Downloading recommended Forge version");
this.version = getRecommendedVersion(this.minecraft);
}
@ -204,7 +208,7 @@ public class ForgeLoader implements Loader {
installProfile = Gsons.MINECRAFT.fromJson(new FileReader(new File(this.tempDir, "install_profile.json")),
ForgeInstallProfile.class);
} catch (Throwable e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return installProfile;
@ -221,7 +225,7 @@ public class ForgeLoader implements Loader {
versionInfo = Gsons.MINECRAFT.fromJson(new FileReader(new File(this.tempDir, "version.json")),
ForgeInstallProfile.class);
} catch (Throwable e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return versionInfo;

View file

@ -32,13 +32,17 @@ import java.util.jar.JarFile;
import com.atlauncher.FileSystem;
import com.atlauncher.annot.Json;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Hashing;
import com.atlauncher.utils.Utils;
import com.atlauncher.workers.InstanceInstaller;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
@Json
public class Processor {
private static final Logger LOG = LogManager.getLogger(Processor.class);
public String jar;
public List<String> sides;
public List<String> classpath;
@ -76,9 +80,9 @@ public class Processor {
: FileSystem.LIBRARIES.toFile();
File jarPath = Utils.convertMavenIdentifierToFile(this.jar, librariesDirectory);
LogManager.debug("Jar path is " + jarPath);
LOG.debug("Jar path is " + jarPath);
if (!jarPath.exists() || !jarPath.isFile()) {
LogManager.error("Failed to process processor with jar " + this.jar + " as the jar doesn't exist");
LOG.error("Failed to process processor with jar " + this.jar + " as the jar doesn't exist");
instanceInstaller.cancel(true);
return;
}
@ -86,10 +90,10 @@ public class Processor {
JarFile jarFile = new JarFile(jarPath);
String mainClass = jarFile.getManifest().getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
jarFile.close();
LogManager.debug("Found mainclass of " + mainClass);
LOG.debug("Found mainclass of " + mainClass);
if (mainClass == null || mainClass.isEmpty()) {
LogManager.error("Failed to process processor with jar " + this.jar + " as the mainclass wasn't found");
LOG.error("Failed to process processor with jar " + this.jar + " as the mainclass wasn't found");
instanceInstaller.cancel(true);
return;
}
@ -98,11 +102,11 @@ public class Processor {
classpath.add(jarPath.toURI().toURL());
for (String classpathItem : this.getClasspath()) {
LogManager.debug("Adding classpath " + classpathItem);
LOG.debug("Adding classpath " + classpathItem);
File classpathFile = Utils.convertMavenIdentifierToFile(classpathItem, FileSystem.LIBRARIES.toFile());
if (!classpathFile.exists() || !classpathFile.isFile()) {
LogManager.error("Failed to process processor with jar " + this.jar
LOG.error("Failed to process processor with jar " + this.jar
+ " as the classpath item with file " + classpathFile.getAbsolutePath() + " doesn't exist");
instanceInstaller.cancel(true);
return;
@ -119,23 +123,23 @@ public class Processor {
installProfile.data.get("ROOT").getValue(!instanceInstaller.isServer, librariesDirectory));
}
LogManager.debug("Processing argument " + arg);
LOG.debug("Processing argument " + arg);
char start = arg.charAt(0);
char end = arg.charAt(arg.length() - 1);
if (start == '{' && end == '}') {
String key = arg.substring(1, arg.length() - 1);
LogManager.debug("Getting data with key of " + key);
LOG.debug("Getting data with key of " + key);
String value = installProfile.data.get(key).getValue(!instanceInstaller.isServer, librariesDirectory);
if (value == null || value.isEmpty()) {
LogManager.error("Failed to process processor with jar " + this.jar + " as the argument with name "
LOG.error("Failed to process processor with jar " + this.jar + " as the argument with name "
+ arg + " as the data item with key " + key + " was empty or null");
instanceInstaller.cancel(true);
return;
}
LogManager.debug("Got value of " + value);
LOG.debug("Got value of " + value);
// checking for local file paths returned "/data/client.lzma" and then makes
// sure we localise it to the libraries folder if it's indeed local
if (value.charAt(0) == '/') {
@ -145,10 +149,10 @@ public class Processor {
args.add(value);
} else {
File localFile = new File(extractedDir, value);
LogManager.debug("Got argument with local file of " + localFile.getAbsolutePath());
LOG.debug("Got argument with local file of " + localFile.getAbsolutePath());
if (!localFile.exists() || !localFile.isFile()) {
LogManager.error("Failed to process argument with value of " + value + " as the local file "
LOG.error("Failed to process argument with value of " + value + " as the local file "
+ localFile.getAbsolutePath() + " doesn't exist");
instanceInstaller.cancel(true);
return;
@ -162,10 +166,10 @@ public class Processor {
} else if (start == '[' && end == ']') {
String artifact = arg.substring(1, arg.length() - 1);
File artifactFile = Utils.convertMavenIdentifierToFile(artifact, FileSystem.LIBRARIES.toFile());
LogManager.debug("Got argument with file of " + artifactFile.getAbsolutePath());
LOG.debug("Got argument with file of " + artifactFile.getAbsolutePath());
if (!artifactFile.exists() || !artifactFile.isFile()) {
LogManager.error("Failed to process argument with value of " + arg + " as the file "
LOG.error("Failed to process argument with value of " + arg + " as the file "
+ artifactFile.getAbsolutePath() + " doesn't exist");
instanceInstaller.cancel(true);
return;
@ -198,20 +202,16 @@ public class Processor {
currentThread.setContextClassLoader(cl);
try {
LogManager.debug("Running processor with args \"" + String.join(" ", args) + "\"");
LOG.debug("Running processor with args \"" + String.join(" ", args) + "\"");
Class<?> cls = Class.forName(mainClass, true, cl);
Method main = cls.getDeclaredMethod("main", String[].class);
main.invoke(null, (Object) args.toArray(new String[args.size()]));
} catch (InvocationTargetException ite) {
Throwable e = ite.getCause();
LogManager.logStackTrace(e);
LogManager.error(
"Failed to process processor with jar " + this.jar + " as there was an error invoking the jar");
LOG.error("Failed to process processor with jar " + this.jar + " as there was an error invoking the jar", e);
instanceInstaller.cancel(true);
} catch (Throwable e) {
LogManager.logStackTrace(e);
LogManager.error(
"Failed to process processor with jar " + this.jar + " as there was an error invoking the jar");
LOG.error("Failed to process processor with jar " + this.jar + " as there was an error invoking the jar", e);
instanceInstaller.cancel(true);
} finally {
currentThread.setContextClassLoader(threadClassloader);
@ -221,7 +221,7 @@ public class Processor {
public boolean needToRun(ForgeInstallProfile installProfile, File extractedDir,
InstanceInstaller instanceInstaller) {
if (this.sides != null && !this.sides.contains(instanceInstaller.isServer ? "server" : "client")) {
LogManager.debug("No need to run processor " + this.jar + " since it's not needed for this side");
LOG.debug("No need to run processor " + this.jar + " since it's not needed for this side");
return false;
}
@ -234,17 +234,17 @@ public class Processor {
for (Entry<String, String> entry : this.outputs.entrySet()) {
String key = entry.getKey();
LogManager.debug("Processing output for " + key);
LOG.debug("Processing output for " + key);
char start = key.charAt(0);
char end = key.charAt(key.length() - 1);
if (start == '{' && end == '}') {
LogManager.debug("Getting data with key of " + key.substring(1, key.length() - 1));
LOG.debug("Getting data with key of " + key.substring(1, key.length() - 1));
String dataItem = installProfile.data.get(key.substring(1, key.length() - 1))
.getValue(!instanceInstaller.isServer, librariesDirectory);
if (dataItem == null || dataItem.isEmpty()) {
LogManager.error("Failed to process processor with jar " + this.jar + " as the output with key "
LOG.error("Failed to process processor with jar " + this.jar + " as the output with key "
+ key + " doesn't have a corresponding data entry");
instanceInstaller.cancel(true);
return true;
@ -261,11 +261,11 @@ public class Processor {
char valueEnd = value.charAt(value.length() - 1);
if (valueStart == '{' && valueEnd == '}') {
LogManager.debug("Getting data with key of " + value.substring(1, value.length() - 1));
LOG.debug("Getting data with key of " + value.substring(1, value.length() - 1));
String valueDataItem = installProfile.data.get(value.substring(1, value.length() - 1))
.getValue(!instanceInstaller.isServer, librariesDirectory);
if (dataItem == null || dataItem.isEmpty()) {
LogManager.error("Failed to process processor with jar " + this.jar
LOG.error("Failed to process processor with jar " + this.jar
+ " as the output with value " + value + " doesn't have a corresponding data entry");
instanceInstaller.cancel(true);
return true;
@ -276,7 +276,7 @@ public class Processor {
? valueDataItem.substring(1, valueDataItem.length() - 1)
: valueDataItem;
LogManager.debug("Expecting " + sha1Hash + " to equal " + sha1Hash);
LOG.debug("Expecting " + sha1Hash + " to equal " + sha1Hash);
if (!sha1Hash.equals(expectedHash)) {
Utils.delete(outputFile);
return true;
@ -285,7 +285,7 @@ public class Processor {
}
}
LogManager.debug("No need to run processor " + this.jar + " since outputs all match hashes");
LOG.debug("No need to run processor " + this.jar + " since outputs all match hashes");
return false;
}

View file

@ -42,13 +42,17 @@ import com.atlauncher.data.minecraft.Library;
import com.atlauncher.data.minecraft.loaders.Loader;
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Download;
import com.atlauncher.utils.Utils;
import com.atlauncher.workers.InstanceInstaller;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class QuiltLoader implements Loader {
private static final Logger LOG = LogManager.getLogger(QuiltLoader.class);
protected String minecraft;
protected QuiltMetaVersion version;
protected File tempDir;
@ -66,7 +70,7 @@ public class QuiltLoader implements Loader {
} else if (metadata.containsKey("loader")) {
this.version = this.getVersion((String) metadata.get("loader"));
} else if ((boolean) metadata.get("latest")) {
LogManager.debug("Downloading latest Quilt version");
LOG.debug("Downloading latest Quilt version");
this.version = this.getLatestVersion();
}
}
@ -209,7 +213,7 @@ public class QuiltLoader implements Loader {
.getBytes(StandardCharsets.UTF_8));
propertiesOutputStream.close();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}

View file

@ -21,10 +21,14 @@ import java.io.IOException;
import java.util.List;
import com.atlauncher.annot.Json;
import com.atlauncher.managers.LogManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
@Json
public class MinecraftProfileResponse {
private static final Logger LOG = LogManager.getLogger(MinecraftProfileResponse.class);
private String id;
private String name;
private List<UserPropertyRaw> properties;
@ -47,7 +51,7 @@ public class MinecraftProfileResponse {
try {
return property.parse();
} catch (IOException e) {
LogManager.logStackTrace("Error parsing user property " + name + " for username " + name, e);
LOG.error("Error parsing user property " + name + " for username " + name, e);
}
}
}

View file

@ -20,10 +20,14 @@ package com.atlauncher.data.mojang.api;
import java.util.Map;
import com.atlauncher.annot.Json;
import com.atlauncher.managers.LogManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
@Json
public class UserProperty {
private static final Logger LOG = LogManager.getLogger(UserProperty.class);
private long timestamp;
private String profileId;
private String profileName;
@ -48,7 +52,7 @@ public class UserProperty {
public ProfileTexture getTexture(String name) {
if (!textures.containsKey(name)) {
LogManager.error("No texture " + name + " for account " + this.profileName);
LOG.error("No texture " + name + " for account " + this.profileName);
return null;
}

View file

@ -27,8 +27,8 @@ import java.util.UUID;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.TransferQueue;
import com.atlauncher.managers.LogManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.freedesktop.dbus.DBusMap;
import org.freedesktop.dbus.DBusMatchRule;
import org.freedesktop.dbus.connections.impl.DBusConnection;
@ -38,6 +38,8 @@ import org.freedesktop.dbus.types.UInt32;
import org.freedesktop.dbus.types.Variant;
public class DBusUtils {
private static final Logger LOG = LogManager.getLogger(DBusUtils.class);
public static File[] selectFiles() {
try {
DBusConnection bus = DBusConnection.getConnection(DBusConnection.DBusBusType.SESSION);
@ -94,7 +96,7 @@ public class DBusUtils {
}).toArray(size -> new File[selectedFiles.get().length]);
}
} catch (Throwable t) {
LogManager.logStackTrace("Error selecting files using DBus", t);
LOG.error("Error selecting files using DBus", t);
}
return new File[0];

View file

@ -1,114 +0,0 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2022 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.evnt;
import java.awt.Color;
import javax.swing.UIManager;
import com.atlauncher.App;
import com.atlauncher.FileSystem;
import com.atlauncher.gui.components.Console;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Timestamper;
import org.apache.logging.log4j.Logger;
public final class LogEvent {
public static final int CONSOLE = 0xA;
public static final int LOG4J = 0xB;
public final LogType type;
public final String body;
public final int meta;
public LogEvent(LogType type, String body) {
this(type, body, CONSOLE | LOG4J);
}
public LogEvent(LogType type, String body, int meta) {
this.type = type;
if (App.settings != null && !LogManager.showDebug) {
body = body.replace(FileSystem.BASE_DIR.toAbsolutePath().toString(), "**USERSDIR**");
}
this.body = (!body.endsWith("\n") ? body + "\n" : body);
this.meta = meta;
}
public void post(Logger logger) {
if ((this.meta & CONSOLE) == CONSOLE) {
Console c = App.console.console;
c.setColor(this.type.color()).setBold(true).write("[" + Timestamper.now() + "] ");
c.setColor(UIManager.getColor("EditorPane.foreground")).setBold(false).write(this.body);
}
if ((this.meta & LOG4J) == LOG4J) {
switch (type) {
case WARN: {
logger.warn(body);
break;
}
case ERROR: {
logger.error(body);
break;
}
case DEBUG: {
logger.debug(body);
break;
}
case INFO:
default: {
logger.info(body);
break;
}
}
}
}
@Override
public String toString() {
return "[" + Timestamper.now() + "] [" + this.type.name() + "]" + this.body;
}
public enum LogType {
INFO, WARN, ERROR, DEBUG;
public Color color() {
switch (this) {
case INFO: {
return UIManager.getColor("Console.LogType.info");
}
case WARN: {
return UIManager.getColor("Console.LogType.warn");
}
case ERROR: {
return UIManager.getColor("Console.LogType.error");
}
case DEBUG: {
return UIManager.getColor("Console.LogType.debug");
}
default: {
return UIManager.getColor("Console.LogType.default");
}
}
}
}
}

View file

@ -41,12 +41,15 @@ import com.atlauncher.evnt.manager.ConsoleOpenManager;
import com.atlauncher.evnt.manager.RelocalizationManager;
import com.atlauncher.gui.components.Console;
import com.atlauncher.gui.components.ConsoleBottomBar;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
public class LauncherConsole extends JFrame implements RelocalizationListener {
public class LauncherConsole extends JFrame implements RelocalizationListener{
private static final Logger LOG = LogManager.getLogger(LauncherConsole.class);
private static final long serialVersionUID = -3538990021922025818L;
public Console console;
@ -70,7 +73,7 @@ public class LauncherConsole extends JFrame implements RelocalizationListener {
App.settings.consoleSize.width, App.settings.consoleSize.height);
}
} catch (Exception e) {
LogManager.logStackTrace("Error setting custom remembered window size settings", e);
LOG.error("Error setting custom remembered window size settings", e);
}
console = new Console();
@ -156,10 +159,10 @@ public class LauncherConsole extends JFrame implements RelocalizationListener {
}
public void setupLanguage() {
LogManager.debug("Setting up language for console");
LOG.debug("Setting up language for console");
copy.setText(GetText.tr("Copy"));
bottomBar.setupLanguage();
LogManager.debug("Finished setting up language for console");
LOG.debug("Finished setting up language for console");
}
public void clearConsole() {

View file

@ -52,22 +52,26 @@ import com.atlauncher.gui.tabs.Tab;
import com.atlauncher.gui.tabs.ToolsTab;
import com.atlauncher.gui.tabs.VanillaPacksTab;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.PackManager;
import com.atlauncher.managers.PerformanceManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public final class LauncherFrame extends JFrame implements RelocalizationListener {
private static final Logger LOG = LogManager.getLogger(LauncherFrame.class);
private JTabbedPane tabbedPane;
private List<Tab> tabs;
public LauncherFrame(boolean show) {
LogManager.info("Launcher opening");
LogManager.info("Made By Bob*");
LogManager.info("*(Not Actually)");
LOG.info("Launcher opening");
LOG.info("Made By Bob*");
LOG.info("*(Not Actually)");
App.launcher.setParentFrame(this);
setTitle(Constants.LAUNCHER_NAME);
@ -88,22 +92,22 @@ public final class LauncherFrame extends JFrame implements RelocalizationListene
setLocation(App.settings.launcherPosition);
}
} catch (Exception e) {
LogManager.logStackTrace("Error setting custom remembered window size settings", e);
LOG.error("Error setting custom remembered window size settings", e);
}
LogManager.info("Setting up Bottom Bar");
LOG.info("Setting up Bottom Bar");
LauncherBottomBar bottomBar = new LauncherBottomBar();
LogManager.info("Finished Setting up Bottom Bar");
LOG.info("Finished Setting up Bottom Bar");
LogManager.info("Setting up Tabs");
LOG.info("Setting up Tabs");
setupTabs(); // Setup the JTabbedPane
LogManager.info("Finished Setting up Tabs");
LOG.info("Finished Setting up Tabs");
this.add(tabbedPane, BorderLayout.CENTER);
this.add(bottomBar, BorderLayout.SOUTH);
if (show) {
LogManager.info("Showing Launcher");
LOG.info("Showing Launcher");
setVisible(true);
addWindowListener(new WindowAdapter() {
@ -125,11 +129,11 @@ public final class LauncherFrame extends JFrame implements RelocalizationListene
Pack pack = PackManager.getPackBySafeName(App.packToInstall);
if (pack != null && pack.isSemiPublic() && !PackManager.canViewSemiPublicPackByCode(pack.getCode())) {
LogManager.error("Error automatically installing " + pack.getName() + " as you don't have the "
LOG.error("Error automatically installing " + pack.getName() + " as you don't have the "
+ "pack added to the launcher!");
} else {
if (AccountManager.getSelectedAccount() == null || pack == null) {
LogManager
LOG
.error("Error automatically installing " + (pack == null ? "pack" : pack.getName()) + "!");
} else {
new InstanceInstallerDialog(pack);
@ -139,21 +143,21 @@ public final class LauncherFrame extends JFrame implements RelocalizationListene
String[] parts = App.packShareCodeToInstall.split("\\|\\|\\|");
if (parts.length != 4) {
LogManager.error("Error automatically installing pack from share code!");
LOG.error("Error automatically installing pack from share code!");
} else {
Pack pack = PackManager.getPackBySafeName(parts[0]);
if (pack != null && pack.isSemiPublic() && !PackManager.canViewSemiPublicPackByCode(pack.getCode())) {
LogManager.error("Error automatically installing " + pack.getName() + " as you don't have the "
LOG.error("Error automatically installing " + pack.getName() + " as you don't have the "
+ "pack added to the launcher!");
} else {
if (pack == null) {
LogManager.error("Error automatically installing pack from share code!");
LOG.error("Error automatically installing pack from share code!");
} else {
PackVersion version = pack.getVersionByName(parts[1]);
if (version == null) {
LogManager.error("Error automatically installing " + pack.getName() + " from share code!");
LOG.error("Error automatically installing " + pack.getName() + " from share code!");
} else {
new InstanceInstallerDialog(pack, version, parts[2], Boolean.parseBoolean(parts[3]));
}

View file

@ -60,20 +60,24 @@ import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
/**
* <p/>
* Class for displaying instances in the Instance Tab
*/
@SuppressWarnings("serial")
public class InstanceCard extends CollapsiblePanel implements RelocalizationListener {
public class InstanceCard extends CollapsiblePanel implements RelocalizationListener{
private static final Logger LOG = LogManager.getLogger(InstanceCard.class);
private final Instance instance;
private final JTextArea descArea = new JTextArea();
private final ImagePanel image;
@ -587,10 +591,10 @@ public class InstanceCard extends CollapsiblePanel implements RelocalizationList
clipboard.setContents(text, null);
App.TOASTER.pop(GetText.tr("Share code copied to clipboard"));
LogManager.info("Share code copied to clipboard");
LOG.info("Share code copied to clipboard");
}
} catch (IOException ex) {
LogManager.logStackTrace("API call failed", ex);
LOG.error("API call failed", ex);
}
});
shareCodeItem.setVisible((instance.getPack() != null && !instance.getPack().system)

View file

@ -45,16 +45,20 @@ import com.atlauncher.gui.components.CollapsiblePanel;
import com.atlauncher.gui.components.ImagePanel;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.ServerManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public class ServerCard extends CollapsiblePanel implements RelocalizationListener {
private static final Logger LOG = LogManager.getLogger(ServerCard.class);
private final Server server;
private final ImagePanel image;
private final JButton launchButton = new JButton(GetText.tr("Launch"));
@ -182,7 +186,7 @@ public class ServerCard extends CollapsiblePanel implements RelocalizationListen
image.setImage(server.getImage().getImage());
server.save();
} catch (IOException ex) {
LogManager.logStackTrace("Failed to set server image", ex);
LOG.error("Failed to set server image", ex);
}
}
}

View file

@ -28,10 +28,14 @@ import javax.swing.UIManager;
import com.atlauncher.evnt.listener.ThemeListener;
import com.atlauncher.evnt.manager.ThemeManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.OS;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class BottomBar extends JPanel implements ThemeListener{
private static final Logger LOG = LogManager.getLogger(BottomBar.class);
public abstract class BottomBar extends JPanel implements ThemeListener {
private static final long serialVersionUID = -7488195680365431776L;
protected final JButton nodeCraftIcon = new SMButton("/assets/image/social/nodecraft.png",
@ -63,27 +67,27 @@ public abstract class BottomBar extends JPanel implements ThemeListener {
private void setupSocialButtonListeners() {
nodeCraftIcon.addActionListener(e -> {
LogManager.info("Opening Up Nodecraft");
LOG.info("Opening Up Nodecraft");
OS.openWebBrowser("https://atl.pw/nodecraft-from-launcher");
});
discordIcon.addActionListener(e -> {
LogManager.info("Opening Up ATLauncher Discord");
LOG.info("Opening Up ATLauncher Discord");
OS.openWebBrowser("https://atl.pw/discord");
});
facebookIcon.addActionListener(e -> {
LogManager.info("Opening Up ATLauncher Facebook Page");
facebookIcon.addActionListener(e ->{
LOG.info("Opening up ATLauncher Facebook Page");
OS.openWebBrowser("https://atl.pw/facebook");
});
githubIcon.addActionListener(e -> {
LogManager.info("Opening Up ATLauncher GitHub Page");
githubIcon.addActionListener(e ->{
LOG.info("Opening Up ATLauncher GitHub Page");
OS.openWebBrowser("https://atl.pw/github-launcher-3");
});
redditIcon.addActionListener(e -> {
LogManager.info("Opening Up ATLauncher Reddit Page");
LOG.info("Opening Up ATLauncher Reddit Page");
OS.openWebBrowser("https://atl.pw/reddit");
});
twitterIcon.addActionListener(e -> {
LogManager.info("Opening Up ATLauncher Twitter Page");
LOG.info("Opening Up ATLauncher Twitter Page");
OS.openWebBrowser("https://atl.pw/twitter");
});
}

View file

@ -34,14 +34,17 @@ import com.atlauncher.evnt.listener.RelocalizationListener;
import com.atlauncher.evnt.manager.RelocalizationManager;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.thread.PasteUpload;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public class ConsoleBottomBar extends BottomBar implements RelocalizationListener {
public class ConsoleBottomBar extends BottomBar implements RelocalizationListener{
private static final Logger LOG = LogManager.getLogger(ConsoleBottomBar.class);
private final JButton clearButton = new JButton(GetText.tr("Clear"));
private final JButton copyLogButton = new JButton(GetText.tr("Copy Log"));
@ -70,12 +73,12 @@ public class ConsoleBottomBar extends BottomBar implements RelocalizationListene
private void addActionListeners() {
clearButton.addActionListener(e -> {
App.console.clearConsole();
LogManager.info("Console Cleared");
LOG.info("Console Cleared");
});
copyLogButton.addActionListener(e -> {
Analytics.sendEvent("CopyLog", "Launcher");
App.TOASTER.pop("Copied Log to clipboard");
LogManager.info("Copied Log to clipboard");
LOG.info("Copied Log to clipboard");
StringSelection text = new StringSelection(App.console.getLog());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(text, null);
@ -92,7 +95,7 @@ public class ConsoleBottomBar extends BottomBar implements RelocalizationListene
Thread.currentThread().interrupt();
dialog.setReturnValue(null);
} catch (ExecutionException ex) {
LogManager.logStackTrace("Exception while uploading paste", ex);
LOG.error("Exception while uploading paste", ex);
dialog.setReturnValue(null);
}
@ -105,13 +108,13 @@ public class ConsoleBottomBar extends BottomBar implements RelocalizationListene
if (result != null && result.contains(Constants.PASTE_CHECK_URL)) {
Analytics.sendEvent("UploadLog", "Launcher");
App.TOASTER.pop("Log uploaded and link copied to clipboard");
LogManager.info("Log uploaded and link copied to clipboard: " + result);
LOG.info("Log uploaded and link copied to clipboard: {}", result);
StringSelection text = new StringSelection(result);
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(text, null);
} else {
App.TOASTER.popError("Log failed to upload!");
LogManager.error("Log failed to upload: " + result);
LOG.error("Log failed to upload: {}", result);
}
});
killMinecraftButton.addActionListener(arg0 -> {

View file

@ -58,16 +58,21 @@ import com.atlauncher.gui.panels.LoadingPanel;
import com.atlauncher.gui.panels.NoCurseModsPanel;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.ComboItem;
import com.atlauncher.utils.CurseForgeApi;
import com.atlauncher.utils.ModrinthApi;
import com.formdev.flatlaf.icons.FlatSearchIcon;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SuppressWarnings("serial")
public final class AddModsDialog extends JDialog {
private static final Logger LOG = LogManager.getLogger(AddModsDialog.class);
private final Instance instance;
private boolean updating = false;
@ -482,7 +487,7 @@ public final class AddModsDialog extends JDialog {
versionsToSearchFor.addAll(MinecraftManager.getMajorMinecraftVersions(this.instance.id).stream()
.map(mv -> mv.id).collect(Collectors.toList()));
} catch (InvalidMinecraftVersion e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
versionsToSearchFor = null;
}
} else if (App.settings.addModRestriction == AddModRestriction.NONE) {

View file

@ -49,14 +49,18 @@ import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.exceptions.InvalidMinecraftVersion;
import com.atlauncher.gui.card.CurseForgeFileDependencyCard;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.CurseForgeApi;
import com.atlauncher.utils.OS;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SuppressWarnings("serial")
public class CurseForgeProjectFileSelectorDialog extends JDialog {
private static final Logger LOG = LogManager.getLogger(CurseForgeProjectFileSelectorDialog.class);
private int filesLength = 0;
private final CurseForgeProject mod;
private final Instance instance;
@ -280,7 +284,7 @@ public class CurseForgeProjectFileSelectorDialog extends JDialog {
.filter(v -> v.gameVersions.stream()
.anyMatch(gv -> minecraftVersionsToSearch.contains(gv)));
} catch (InvalidMinecraftVersion e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}

View file

@ -68,7 +68,6 @@ import com.atlauncher.gui.handlers.ModsJCheckBoxTransferHandler;
import com.atlauncher.gui.layouts.WrapLayout;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.PerformanceManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.CurseForgeApi;
@ -77,7 +76,11 @@ import com.atlauncher.utils.Hashing;
import com.atlauncher.utils.ModrinthApi;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class EditModsDialog extends JDialog {
private static final Logger LOG = LogManager.getLogger(EditModsDialog.class);
private static final long serialVersionUID = 7004414192679481818L;
public Instance instance;
@ -347,7 +350,6 @@ public class EditModsDialog extends JDialog {
mod.description = Optional.ofNullable(fabricMod.description).orElse(null);
}
}
return mod;
}
@ -367,7 +369,7 @@ public class EditModsDialog extends JDialog {
&& mod.file.equals(file.getFileName().toString())))
.collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace("Error scanning missing mods", e);
LOG.error("Error scanning missing mods", e);
}
}
@ -394,7 +396,7 @@ public class EditModsDialog extends JDialog {
.getFile(instance.ROOT, instance.id).toPath());
murmurHashes.put(hash, dm);
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error(t);
}
});
@ -432,7 +434,7 @@ public class EditModsDialog extends JDialog {
dm.description = curseForgeProject.summary;
}
LogManager.debug("Found matching mod from CurseForge called "
LOG.debug("Found matching mod from CurseForge called "
+ dm.curseForgeFile.displayName);
});
}
@ -454,7 +456,7 @@ public class EditModsDialog extends JDialog {
.getFile(instance.ROOT, instance.id).toPath())
.toString(), dm);
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error(t);
}
});
@ -489,8 +491,7 @@ public class EditModsDialog extends JDialog {
dm.description = project.description;
}
LogManager
.debug(String.format(
LOG.debug(String.format(
"Found matching mod from Modrinth called %s with file %s",
project.title, version.name));
}
@ -501,7 +502,7 @@ public class EditModsDialog extends JDialog {
}
}
mods.forEach(mod -> LogManager.info("Found extra mod with name of " + mod.file));
mods.forEach(mod -> LOG.info("Found extra mod with name of " + mod.file));
instance.launcher.mods.addAll(mods);
instance.save();
progressDialog.close();
@ -526,7 +527,7 @@ public class EditModsDialog extends JDialog {
}).collect(Collectors.toList());
if (removedMods.size() != 0) {
removedMods.forEach(mod -> LogManager.info("Mod no longer in filesystem: " + mod.file));
removedMods.forEach(mod -> LOG.info("Mod no longer in filesystem: {}", mod.file));
instance.launcher.mods.removeAll(removedMods);
instance.save();
}

View file

@ -17,39 +17,6 @@
*/
package com.atlauncher.gui.dialogs;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import org.mini2Dx.gettext.GetText;
import com.atlauncher.App;
import com.atlauncher.Gsons;
import com.atlauncher.builders.HTMLBuilder;
@ -61,16 +28,7 @@ import com.atlauncher.data.PackVersion;
import com.atlauncher.data.curseforge.CurseForgeFile;
import com.atlauncher.data.curseforge.CurseForgeProject;
import com.atlauncher.data.curseforge.pack.CurseForgeManifest;
import com.atlauncher.data.installables.ATLauncherInstallable;
import com.atlauncher.data.installables.CurseForgeInstallable;
import com.atlauncher.data.installables.CurseForgeManifestInstallable;
import com.atlauncher.data.installables.Installable;
import com.atlauncher.data.installables.ModpacksChInstallable;
import com.atlauncher.data.installables.ModrinthInstallable;
import com.atlauncher.data.installables.ModrinthManifestInstallable;
import com.atlauncher.data.installables.MultiMCInstallable;
import com.atlauncher.data.installables.TechnicModpackInstallable;
import com.atlauncher.data.installables.VanillaInstallable;
import com.atlauncher.data.installables.*;
import com.atlauncher.data.json.Version;
import com.atlauncher.data.minecraft.VersionManifestVersion;
import com.atlauncher.data.minecraft.VersionManifestVersionType;
@ -94,18 +52,26 @@ import com.atlauncher.data.technic.TechnicSolderModpack;
import com.atlauncher.exceptions.InvalidMinecraftVersion;
import com.atlauncher.gui.components.JLabelWithHover;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.ComboItem;
import com.atlauncher.utils.CurseForgeApi;
import com.atlauncher.utils.ModrinthApi;
import com.atlauncher.utils.TechnicApi;
import com.atlauncher.utils.Utils;
import com.atlauncher.utils.*;
import okhttp3.CacheControl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.nio.file.Path;
import java.util.List;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
public class InstanceInstallerDialog extends JDialog {
private static final Logger LOG = LogManager.getLogger(InstanceInstallerDialog.class);
private static final long serialVersionUID = -6984886874482721558L;
private int versionLength = 0;
private int loaderVersionLength = 0;
@ -599,7 +565,7 @@ public class InstanceInstallerDialog extends JDialog {
packVersion.minecraftVersion = MinecraftManager
.getMinecraftVersion(version.gameVersions.get(0));
} catch (InvalidMinecraftVersion e) {
LogManager.error(e.getMessage());
LOG.error(e.getMessage());
packVersion.minecraftVersion = null;
}
@ -699,7 +665,7 @@ public class InstanceInstallerDialog extends JDialog {
try {
packVersion.minecraftVersion = MinecraftManager.getMinecraftVersion(curseForgeManifest.minecraft.version);
} catch (InvalidMinecraftVersion e) {
LogManager.error(e.getMessage());
LOG.error(e.getMessage());
return;
}
@ -726,7 +692,7 @@ public class InstanceInstallerDialog extends JDialog {
packVersion.minecraftVersion = MinecraftManager
.getMinecraftVersion(modrinthManifest.dependencies.get("minecraft"));
} catch (InvalidMinecraftVersion e) {
LogManager.error(e.getMessage());
LOG.error(e.getMessage());
return;
}
@ -756,14 +722,14 @@ public class InstanceInstallerDialog extends JDialog {
.filter(c -> c.uid.equalsIgnoreCase("net.minecraft")).findFirst();
if (!minecraftVersionComponent.isPresent()) {
LogManager.error("No net.minecraft component present in manifest");
LOG.error("No net.minecraft component present in manifest");
return;
}
packVersion.minecraftVersion = MinecraftManager
.getMinecraftVersion(minecraftVersionComponent.get().version);
} catch (InvalidMinecraftVersion e) {
LogManager.error(e.getMessage());
LOG.error(e.getMessage());
return;
}

View file

@ -47,18 +47,22 @@ import com.atlauncher.data.microsoft.XboxLiveAuthResponse;
import com.atlauncher.gui.panels.LoadingPanel;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.DownloadException;
import com.atlauncher.utils.MicrosoftAuthAPI;
import com.atlauncher.utils.OS;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import net.freeutils.httpserver.HTTPServer;
import net.freeutils.httpserver.HTTPServer.VirtualHost;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public final class LoginWithMicrosoftDialog extends JDialog {
private static final Logger LOG = LogManager.getLogger(LoginWithMicrosoftDialog.class);
private static final HTTPServer server = new HTTPServer(Constants.MICROSOFT_LOGIN_REDIRECT_PORT);
private static final VirtualHost host = server.getVirtualHost(null);
@ -113,7 +117,7 @@ public final class LoginWithMicrosoftDialog extends JDialog {
try {
startServer();
} catch (IOException e) {
LogManager.logStackTrace("Error starting web server for Microsoft login", e);
LOG.error("Error starting web server for Microsoft login", e);
close();
}
@ -133,7 +137,7 @@ public final class LoginWithMicrosoftDialog extends JDialog {
if (req.getParams().containsKey("error")) {
res.getHeaders().add("Content-Type", "text/plain");
res.send(500, GetText.tr("Error logging in. Check console for more information"));
LogManager.error("Error logging into Microsoft account: " + URLDecoder
LOG.error("Error logging into Microsoft account: {}", URLDecoder
.decode(req.getParams().get("error_description"), StandardCharsets.UTF_8.toString()));
close();
return 0;
@ -149,7 +153,7 @@ public final class LoginWithMicrosoftDialog extends JDialog {
try {
acquireAccessToken(req.getParams().get("code"));
} catch (Exception e) {
LogManager.logStackTrace("Error acquiring accessToken", e);
LOG.error("Error acquiring accessToken", e);
res.getHeaders().add("Content-Type", "text/html");
res.send(500, GetText.tr("Error logging in. Check console for more information"));
close();
@ -214,14 +218,14 @@ public final class LoginWithMicrosoftDialog extends JDialog {
xstsAuthResponse = MicrosoftAuthAPI.getXstsToken(xblToken);
} catch (DownloadException e) {
if (e.response != null) {
LogManager.debug(Gsons.DEFAULT.toJson(e.response));
LOG.debug(Gsons.DEFAULT.toJson(e.response));
XboxLiveAuthErrorResponse xboxLiveAuthErrorResponse = Gsons.DEFAULT.fromJson(e.response,
XboxLiveAuthErrorResponse.class);
String error = xboxLiveAuthErrorResponse.getErrorMessageForCode();
if (error != null) {
LogManager.warn(error);
LOG.warn(error);
DialogManager.okDialog().setTitle(GetText.tr("Error logging into Xbox Live"))
.setContent(new HTMLBuilder().center().text(error).build()).setType(DialogManager.ERROR)
.show();

View file

@ -37,6 +37,8 @@ import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import com.atlauncher.App;
@ -50,7 +52,6 @@ import com.atlauncher.data.modrinth.ModrinthVersion;
import com.atlauncher.exceptions.InvalidMinecraftVersion;
import com.atlauncher.gui.card.ModrinthProjectDependencyCard;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.ComboItem;
@ -59,7 +60,10 @@ import com.atlauncher.utils.OS;
@SuppressWarnings("serial")
public class ModrinthVersionSelectorDialog extends JDialog {
private static final Logger LOG = LogManager.getLogger(ModrinthVersionSelectorDialog.class);
private int versionsLength = 0;
private int filesLength = 0;
private final ModrinthProject mod;
private final Instance instance;
@ -348,7 +352,7 @@ public class ModrinthVersionSelectorDialog extends JDialog {
modrinthVersionsStream = modrinthVersionsStream.filter(
v -> v.gameVersions.stream().anyMatch(gv -> minecraftVersionsToSearch.contains(gv)));
} catch (InvalidMinecraftVersion e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}

View file

@ -40,17 +40,21 @@ import com.atlauncher.Gsons;
import com.atlauncher.data.json.Mod;
import com.atlauncher.gui.components.ModsJCheckBox;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.Utils;
import com.atlauncher.workers.InstanceInstaller;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import io.github.asyncronous.toast.Toaster;
import org.slf4j.LoggerFactory;
public class ModsChooser extends JDialog {
private static final Logger LOG = LogManager.getLogger(ModsChooser.class);
private static final long serialVersionUID = -5309108183485463434L;
private final InstanceInstaller installer;
private final JButton useShareCode;
@ -222,7 +226,7 @@ public class ModsChooser extends JDialog {
} else {
Mod linkedMod = installer.getModByName(mod.getLinked());
if (linkedMod == null) {
LogManager.error("The mod " + mod.getName() + " tried to reference a linked mod "
LOG.error("The mod " + mod.getName() + " tried to reference a linked mod "
+ mod.getLinked() + " which doesn't exist!");
installer.cancel(true);
return;
@ -412,7 +416,7 @@ public class ModsChooser extends JDialog {
}
}
} catch (Exception e) {
LogManager.error("Invalid share code!");
LOG.error("Invalid share code!");
Toaster.instance().popError(GetText.tr("Invalid Share Code"));
}
}
@ -451,7 +455,7 @@ public class ModsChooser extends JDialog {
for (Mod mod : linkedMods) {
for (ModsJCheckBox check : modCheckboxes) {
if (check.getMod() == mod) {
LogManager.debug("Selected " + a.getMod().getName() + " which is auto selecting "
LOG.debug("Selected " + a.getMod().getName() + " which is auto selecting "
+ check.getMod().getName() + " because it's a linked mod.");
check.setEnabled(true);
}
@ -462,7 +466,7 @@ public class ModsChooser extends JDialog {
for (Mod mod : groupMods) {
for (ModsJCheckBox check : modCheckboxes) {
if (check.getMod() == mod) {
LogManager.debug("Selected " + a.getMod().getName() + " which is auto deselecting "
LOG.debug("Selected " + a.getMod().getName() + " which is auto deselecting "
+ check.getMod().getName() + " because it's in the same group.");
check.setSelected(false);
}
@ -474,7 +478,7 @@ public class ModsChooser extends JDialog {
for (Mod mod : dependsMods) {
for (ModsJCheckBox check : modCheckboxes) {
if (check.getMod() == mod && !sortedOut.contains(check)) {
LogManager.debug("Selected " + a.getMod().getName() + " which is auto selecting "
LOG.debug("Selected " + a.getMod().getName() + " which is auto selecting "
+ check.getMod().getName() + " because it's a dependency.");
sortedOut.add(check);
check.setSelected(true);
@ -488,7 +492,7 @@ public class ModsChooser extends JDialog {
for (Mod mod : linkedMods) {
for (ModsJCheckBox check : modCheckboxes) {
if (check.getMod() == mod) {
LogManager.debug("Deselected " + a.getMod().getName() + " which is auto deselecting "
LOG.debug("Deselected " + a.getMod().getName() + " which is auto deselecting "
+ check.getMod().getName() + " because it's a linked mod.");
check.setEnabled(false);
check.setSelected(false);
@ -500,7 +504,7 @@ public class ModsChooser extends JDialog {
for (Mod mod : dependedMods) {
for (ModsJCheckBox check : modCheckboxes) {
if (check.getMod() == mod) {
LogManager.debug("Deselected " + a.getMod().getName() + " which is auto deselecting "
LOG.debug("Deselected " + a.getMod().getName() + " which is auto deselecting "
+ check.getMod().getName() + " because it's a dependant mod.");
check.setSelected(false);
}
@ -512,7 +516,7 @@ public class ModsChooser extends JDialog {
for (ModsJCheckBox check : modCheckboxes) {
if (check.getMod() == mod) {
if (check.getMod().isLibrary()) {
LogManager.debug("Deselected " + a.getMod().getName() + " which is auto deselecting "
LOG.debug("Deselected " + a.getMod().getName() + " which is auto deselecting "
+ check.getMod().getName() + " because it's a dependant library mod.");
check.setSelected(false);
}

View file

@ -30,13 +30,17 @@ import javax.swing.SwingConstants;
import com.atlauncher.App;
import com.atlauncher.interfaces.NetworkProgressable;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public class ProgressDialog<T> extends JDialog implements NetworkProgressable {
private static final Logger LOG = LogManager.getLogger(ProgressDialog.class);
private final String labelText; // The text to add to the JLabel
private final JProgressBar progressBar; // The Progress Bar
private final JProgressBar subProgressBar; // The Progress Bar
@ -86,7 +90,7 @@ public class ProgressDialog<T> extends JDialog implements NetworkProgressable {
public void windowClosing(WindowEvent e) {
wasClosed = true;
if (closedLogMessage != null) {
LogManager.error(closedLogMessage);
LOG.error(closedLogMessage);
}
if (thread != null) {
if (thread.isAlive()) {

View file

@ -37,14 +37,17 @@ import com.atlauncher.constants.UIConstants;
import com.atlauncher.data.Instance;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public class RenameInstanceDialog extends JDialog {
public class RenameInstanceDialog extends JDialog{
private static final Logger LOG = LogManager.getLogger(RenameInstanceDialog.class);
private JTextField instanceName;
@ -127,7 +130,7 @@ public class RenameInstanceDialog extends JDialog {
if (instance.rename(instanceName.getText())) {
App.launcher.reloadInstancesPanel();
} else {
LogManager.error("Unknown Error Occurred While Renaming Instance!");
LOG.error("Unknown Error Occurred While Renaming Instance!");
DialogManager.okDialog().setParent(RenameInstanceDialog.this).setTitle(GetText.tr("Error"))
.setContent(new HTMLBuilder().center().text(GetText.tr(
"An error occurred renaming the instance.<br/><br/>Please check the console and try again."))

View file

@ -48,14 +48,18 @@ import com.atlauncher.gui.dialogs.EditModsDialog;
import com.atlauncher.gui.dialogs.FileTypeDialog;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.CurseForgeApi;
import com.atlauncher.utils.Hashing;
import com.atlauncher.utils.ModrinthApi;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@SuppressWarnings("serial")
public class ModsJCheckBoxTransferHandler extends TransferHandler {
private static final Logger LOG = LogManager.getLogger(ModsJCheckBoxTransferHandler.class);
private final EditModsDialog dialog;
private final boolean disabled;
@ -191,7 +195,7 @@ public class ModsJCheckBoxTransferHandler extends TransferHandler {
.murmur(dm.getFile(dialog.instance.ROOT, dialog.instance.id).toPath());
murmurHashes.put(hash, dm);
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error(t);
}
});
@ -229,7 +233,7 @@ public class ModsJCheckBoxTransferHandler extends TransferHandler {
dm.description = curseForgeProject.summary;
}
LogManager.debug("Found matching mod from CurseForge called "
LOG.debug("Found matching mod from CurseForge called "
+ dm.curseForgeFile.displayName);
});
}
@ -251,7 +255,7 @@ public class ModsJCheckBoxTransferHandler extends TransferHandler {
.getFile(dialog.instance.ROOT, dialog.instance.id).toPath())
.toString(), dm);
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error(t);
}
});
@ -286,8 +290,7 @@ public class ModsJCheckBoxTransferHandler extends TransferHandler {
dm.description = project.description;
}
LogManager
.debug(String.format(
LOG.debug(String.format(
"Found matching mod from Modrinth called %s with file %s",
project.title, version.name));
}

View file

@ -28,6 +28,8 @@ import java.util.stream.Collectors;
import javax.swing.JPanel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import com.atlauncher.constants.Constants;
@ -42,11 +44,12 @@ import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.CurseForgeApi;
public class CurseForgePacksPanel extends PackBrowserPlatformPanel {
private static final Logger LOG = LogManager.getLogger(CurseForgePacksPanel.class);
GridBagConstraints gbc = new GridBagConstraints();
boolean hasMorePages = true;
@ -220,7 +223,7 @@ public class CurseForgePacksPanel extends PackBrowserPlatformPanel {
Matcher matcher = pattern.matcher(id);
if (!matcher.find() || matcher.groupCount() < 2) {
LogManager.error("Cannot install as the url was not a valid CurseForge modpack url");
LOG.error("Cannot install as the url was not a valid CurseForge modpack url");
progressDialog.doneTask();
progressDialog.close();
return;

View file

@ -29,6 +29,8 @@ import java.util.stream.Collectors;
import javax.swing.JPanel;
import org.apache.commons.text.WordUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import com.atlauncher.constants.UIConstants;
@ -44,11 +46,12 @@ import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.ModrinthApi;
public class ModrinthPacksPanel extends PackBrowserPlatformPanel {
private static final Logger LOG = LogManager.getLogger(ModrinthPacksPanel.class);
GridBagConstraints gbc = new GridBagConstraints();
boolean hasMorePages = true;
@ -205,7 +208,7 @@ public class ModrinthPacksPanel extends PackBrowserPlatformPanel {
Matcher matcher = pattern.matcher(id);
if (!matcher.find() || matcher.groupCount() < 1) {
LogManager.error("Cannot install as the url was not a valid Modrinth modpack url");
LOG.error("Cannot install as the url was not a valid Modrinth modpack url");
return;
}

View file

@ -54,16 +54,19 @@ import com.atlauncher.gui.dialogs.LoginWithMicrosoftDialog;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.AccountManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.Authentication;
import com.atlauncher.utils.ComboItem;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.SkinUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
public class AccountsTab extends JPanel implements Tab, RelocalizationListener {
public class AccountsTab extends JPanel implements Tab, RelocalizationListener{
private static final Logger LOG = LogManager.getLogger(AccountsTab.class);
private static final long serialVersionUID = 2493791137600123223L;
private JLabel userSkin;
@ -395,7 +398,7 @@ public class AccountsTab extends JPanel implements Tab, RelocalizationListener {
return;
}
LogManager.info("Logging into Minecraft!");
LOG.info("Logging into Minecraft!");
final ProgressDialog<LoginResponse> dialog = new ProgressDialog<>(GetText.tr("Logging Into Minecraft"), 0,
GetText.tr("Logging Into Minecraft"), "Aborting login for " + usernameField.getText());
dialog.setName("loginDialog");
@ -435,7 +438,7 @@ public class AccountsTab extends JPanel implements Tab, RelocalizationListener {
}
Analytics.sendEvent("Edit", "Account");
LogManager.info("Edited Account " + account);
LOG.info("Edited Account {}", account);
DialogManager.okDialog().setTitle(GetText.tr("Account Edited"))
.setContent(GetText.tr("Account edited successfully")).setType(DialogManager.INFO).show();
}
@ -446,7 +449,7 @@ public class AccountsTab extends JPanel implements Tab, RelocalizationListener {
}
accountsComboBox.setSelectedItem(account);
} else {
LogManager.error(response.getErrorMessage());
LOG.error("error response: {}", response);
DialogManager.okDialog().setTitle(GetText.tr("Account Not Added")).setContent(new HTMLBuilder().center()
// #. {0} is the error message from Mojang as to why we couldn't login
.text(GetText.tr("Account not added as login details were incorrect.<br/><br/>{0}",

View file

@ -64,12 +64,15 @@ import com.atlauncher.data.minecraft.loaders.forge.ForgeLoader;
import com.atlauncher.data.minecraft.loaders.quilt.QuiltLoader;
import com.atlauncher.exceptions.InvalidMinecraftVersion;
import com.atlauncher.managers.ConfigManager;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.utils.ComboItem;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
@ -77,6 +80,8 @@ import org.mini2Dx.gettext.GetText;
@SuppressWarnings("serial")
public final class VanillaPacksTab extends JPanel implements Tab {
private static final Logger LOG = LogManager.getLogger(VanillaPacksTab.class);
private final List<VersionManifestVersionType> minecraftVersionTypeFilters = new ArrayList<>(
Arrays.asList(VersionManifestVersionType.RELEASE));
private String selectedMinecraftVersion = null;
@ -718,7 +723,7 @@ public final class VanillaPacksTab extends JPanel implements Tab {
minecraftVersionTable.setRowSelectionInterval(0, 0);
}
} catch (InvalidMinecraftVersion e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}

View file

@ -23,14 +23,17 @@ import java.awt.event.MouseEvent;
import javax.swing.JLabel;
import com.atlauncher.builders.HTMLBuilder;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.OS;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public class DebugModePanel extends AbstractToolPanel {
private static final Logger LOG = LogManager.getLogger(DebugModePanel.class);
public DebugModePanel() {
super(GetText.tr("Debug Mode"));
@ -40,9 +43,9 @@ public class DebugModePanel extends AbstractToolPanel {
.build());
MIDDLE_PANEL.add(INFO_LABEL);
BOTTOM_PANEL.add(LAUNCH_BUTTON);
LAUNCH_BUTTON.setEnabled(!OS.isUsingFlatpak() && !LogManager.showDebug);
LAUNCH_BUTTON.setEnabled(!OS.isUsingFlatpak() && !LOG.isDebugEnabled());
if (!LogManager.showDebug) {
if (!LOG.isDebugEnabled()) {
LAUNCH_BUTTON.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {

View file

@ -34,15 +34,19 @@ import com.atlauncher.evnt.listener.SettingsListener;
import com.atlauncher.evnt.manager.SettingsManager;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.network.Download;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public class NetworkCheckerToolPanel extends AbstractToolPanel implements ActionListener, SettingsListener {
private static final Logger LOG = LogManager.getLogger(NetworkCheckerToolPanel.class);
private final String[] HOSTS = { "authserver.mojang.com", "session.minecraft.net", "libraries.minecraft.net",
"launchermeta.mojang.com", "launcher.mojang.com", Constants.API_HOST, Constants.PASTE_HOST,
@ -224,9 +228,9 @@ public class NetworkCheckerToolPanel extends AbstractToolPanel implements Action
String result = Utils.uploadPaste(Constants.LAUNCHER_NAME + " Network Test Log", results.toString());
if (result.contains(Constants.PASTE_CHECK_URL)) {
LogManager.info("Network Test has finished running, you can view the results at " + result);
LOG.info("Network Test has finished running, you can view the results at {}", result);
} else {
LogManager.error("Network Test failed to submit to " + Constants.LAUNCHER_NAME + "!");
LOG.error("Network Test failed to submit to {}!", Constants.LAUNCHER_NAME);
dialog.setReturnValue(false);
}
@ -236,9 +240,9 @@ public class NetworkCheckerToolPanel extends AbstractToolPanel implements Action
}));
dialog.start();
if (dialog.getReturnValue() == null || !dialog.getReturnValue()) {
LogManager.error("Network Test failed to run!");
LOG.error("Network Test failed to run!");
} else {
LogManager.info("Network Test ran and submitted to " + Constants.LAUNCHER_NAME + "!");
LOG.info("Network Test ran and submitted to {}!", Constants.LAUNCHER_NAME);
DialogManager.okDialog().setTitle(GetText.tr("Network Checker"))
.setContent(new HTMLBuilder().center().text(GetText.tr(

View file

@ -35,7 +35,6 @@ import com.atlauncher.data.Runtimes;
import com.atlauncher.gui.dialogs.ProgressDialog;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.network.Download;
import com.atlauncher.utils.ArchiveUtils;
@ -44,12 +43,17 @@ import com.atlauncher.utils.Java;
import com.atlauncher.utils.OS;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import okhttp3.OkHttpClient;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public class RuntimeDownloaderToolPanel extends AbstractToolPanel implements ActionListener {
private static final Logger LOG = LogManager.getLogger(RuntimeDownloaderToolPanel.class);
protected final JButton REMOVE_BUTTON = new JButton(GetText.tr("Remove"));
public RuntimeDownloaderToolPanel() {
@ -107,7 +111,7 @@ public class RuntimeDownloaderToolPanel extends AbstractToolPanel implements Act
i.save();
});
} else {
LogManager.error("Runtime removal failed!");
LOG.error("Runtime removal failed!");
DialogManager.okDialog().setTitle(GetText.tr("Runtime Downloader"))
.setContent(new HTMLBuilder().center()
.text(GetText.tr("An error occurred removing the runtime. Please check the logs.")).build())
@ -160,7 +164,7 @@ public class RuntimeDownloaderToolPanel extends AbstractToolPanel implements Act
try {
download.downloadFile();
} catch (IOException e1) {
LogManager.logStackTrace(e1);
LOG.error("error", e1);
dialog.setReturnValue(null);
}
@ -174,7 +178,7 @@ public class RuntimeDownloaderToolPanel extends AbstractToolPanel implements Act
try {
Utils.unXZFile(downloadFile, unpackedFile);
} catch (IOException e2) {
LogManager.logStackTrace(e2);
LOG.error("error", e2);
dialog.setReturnValue(null);
}
@ -190,14 +194,14 @@ public class RuntimeDownloaderToolPanel extends AbstractToolPanel implements Act
dialog.start();
if (dialog.getReturnValue() == null) {
LogManager.error("Runtime downloaded failed to run!");
LOG.error("Runtime downloaded failed to run!");
DialogManager.okDialog().setTitle(GetText.tr("Runtime Downloader"))
.setContent(new HTMLBuilder().center()
.text(GetText.tr("An error occurred downloading the runtime. Please check the logs."))
.build())
.setType(DialogManager.ERROR).show();
} else {
LogManager.info("Runtime downloaded!");
LOG.info("Runtime downloaded!");
String path = dialog.getReturnValue();

View file

@ -0,0 +1,95 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2022 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.logging;
import com.atlauncher.App;
import com.atlauncher.gui.components.Console;
import com.atlauncher.utils.Timestamper;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.core.Appender;
import org.apache.logging.log4j.core.Core;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.Layout;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.config.Property;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
import javax.swing.UIManager;
import java.awt.Color;
import java.io.Serializable;
import java.util.Optional;
@Plugin(name= LauncherConsoleAppender.PLUGIN_NAME,
category= LauncherConsoleAppender.PLUGIN_CATEGORY,
elementType=Appender.ELEMENT_TYPE,
printObject=true)
public final class LauncherConsoleAppender extends AbstractAppender{
public static final String PLUGIN_NAME = "LauncherConsole";
public static final String PLUGIN_CATEGORY = Core.CATEGORY_NAME;
public LauncherConsoleAppender(String name,
Filter filter,
Layout<? extends Serializable> layout,
boolean ignoreExceptions,
Property[] properties){
super(name, filter, layout, ignoreExceptions, properties);
}
private Optional<Console> getConsole(){
if(App.console == null)
return Optional.empty();
return Optional.ofNullable(App.console.console);
}
@Override
public void append(LogEvent e){
this.getConsole().ifPresent((console)->{
// write timestamp
console.setColor(getColor(e)).setBold(true).write("[" + Timestamper.now() + "]");
console.setColor(UIManager.getColor("EditorPane.foreground"))
.setBold(false)
.write(String.format("%s\n", e.getMessage().getFormattedMessage()));
});
//TODO: restore functionality
// if (App.settings != null && !LogManager.showDebug) {
// body = body.replace(FileSystem.BASE_DIR.toAbsolutePath().toString(), "**USERSDIR**");
// }
}
private static Color getColor(final LogEvent e){
if(e.getLevel().equals(Level.INFO)){
return UIManager.getColor("Console.LogType.info");
} else if(e.getLevel().equals(Level.WARN)){
return UIManager.getColor("Console.LogType.warn");
} else if(e.getLevel().equals(Level.ERROR)){
return UIManager.getColor("Console.LogType.error");
} else if(e.getLevel().equals(Level.DEBUG)){
return UIManager.getColor("Console.LogType.debug");
}
return UIManager.getColor("Console.LogType.default");
}
@PluginFactory
public static LauncherConsoleAppender createAppender(@PluginAttribute("name") String name){
return new LauncherConsoleAppender(name, null, null, false, null);
}
}

View file

@ -0,0 +1,56 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2022 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.logging;
import com.atlauncher.exceptions.LocalException;
import com.atlauncher.network.ErrorReporting;
import org.apache.logging.log4j.core.Core;
import org.apache.logging.log4j.core.Filter;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.appender.AbstractAppender;
import org.apache.logging.log4j.core.config.plugins.Plugin;
import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
import org.apache.logging.log4j.core.config.plugins.PluginElement;
import org.apache.logging.log4j.core.config.plugins.PluginFactory;
@Plugin(name=LauncherReportingAppender.PLUGIN_NAME,
category=LauncherReportingAppender.PLUGIN_CATEGORY,
elementType=LauncherReportingAppender.ELEMENT_TYPE,
printObject = true)
public final class LauncherReportingAppender extends AbstractAppender{
public static final String PLUGIN_NAME = "LauncherReporter";
public static final String PLUGIN_CATEGORY = Core.CATEGORY_NAME;
public LauncherReportingAppender(final String name, final Filter filter){
super(name, filter, null, false, null);
}
@Override
public void append(LogEvent event){
final Throwable th = event.getThrown();
if(!(th instanceof LocalException)){ // don't report LocalExceptions
// fallthrough
}
}
@PluginFactory
public static LauncherReportingAppender createAppender(@PluginAttribute("name") final String name,
@PluginElement("Filter") final Filter filter){
return new LauncherReportingAppender(name, filter);
}
}

View file

@ -41,10 +41,15 @@ import com.atlauncher.utils.Utils;
import com.google.gson.JsonIOException;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
@SuppressWarnings("deprecation")
public class AccountManager {
private static final Logger LOG = LogManager.getLogger(AccountManager.class);
private static final Type abstractAccountListType = new TypeToken<List<AbstractAccount>>() {
}.getType();
@ -61,10 +66,10 @@ public class AccountManager {
*/
public static void loadAccounts() {
PerformanceManager.start();
LogManager.debug("Loading accounts");
LOG.debug("Loading accounts");
if (Files.exists(FileSystem.USER_DATA)) {
LogManager.info("Converting old account format to new format.");
LOG.info("Converting old account format to new format.");
convertAccounts();
}
@ -72,7 +77,7 @@ public class AccountManager {
try (FileReader fileReader = new FileReader(FileSystem.ACCOUNTS.toFile())) {
Data.ACCOUNTS.addAll(Gsons.DEFAULT.fromJson(fileReader, abstractAccountListType));
} catch (Exception e) {
LogManager.logStackTrace("Exception loading accounts", e);
LOG.error("Exception loading accounts", e);
}
}
@ -90,7 +95,7 @@ public class AccountManager {
} else {
mojangAccount.password = Utils.decrypt(mojangAccount.encryptedPassword);
if (mojangAccount.password == null) {
LogManager.error("Error reading in saved password from file!");
LOG.error("Error reading in saved password from file!");
mojangAccount.password = "";
mojangAccount.remember = false;
}
@ -102,7 +107,7 @@ public class AccountManager {
Data.SELECTED_ACCOUNT = Data.ACCOUNTS.get(0);
}
LogManager.debug("Finished loading accounts");
LOG.debug("Finished loading accounts");
PerformanceManager.end();
}
@ -126,7 +131,7 @@ public class AccountManager {
} catch (EOFException e) {
// Don't log this, it always happens when it gets to the end of the file
} catch (IOException | ClassNotFoundException e) {
LogManager.logStackTrace("Exception while trying to convert accounts from file.", e);
LOG.error("Exception while trying to convert accounts from file.", e);
} finally {
try {
if (objIn != null) {
@ -136,7 +141,7 @@ public class AccountManager {
in.close();
}
} catch (IOException e) {
LogManager.logStackTrace(
LOG.error(
"Exception while trying to close FileInputStream/ObjectInputStream when reading in " + ""
+ "accounts.",
e);
@ -148,7 +153,7 @@ public class AccountManager {
try {
Files.delete(FileSystem.USER_DATA);
} catch (IOException e) {
LogManager.logStackTrace("Exception trying to remove old userdata file after conversion.", e);
LOG.error("Exception trying to remove old userdata file after conversion.", e);
}
}
@ -160,7 +165,7 @@ public class AccountManager {
try (FileWriter fileWriter = new FileWriter(FileSystem.ACCOUNTS.toFile())) {
Gsons.DEFAULT.toJson(accounts, abstractAccountListType, fileWriter);
} catch (JsonIOException | IOException e) {
LogManager.logStackTrace(e);
LOG.error("error:", e);
}
}
@ -168,7 +173,7 @@ public class AccountManager {
String accountType = account instanceof MicrosoftAccount ? "Microsoft" : "Mojang";
Analytics.sendEvent(accountType, "Add", "Account");
LogManager.info("Added " + accountType + " Account " + account);
LOG.info("Added " + accountType + " Account " + account);
Data.ACCOUNTS.add(account);
@ -212,11 +217,11 @@ public class AccountManager {
*/
public static void switchAccount(AbstractAccount account) {
if (account == null) {
LogManager.info("Logging out of account");
LOG.info("Logging out of account");
Data.SELECTED_ACCOUNT = null;
App.settings.lastAccount = null;
} else {
LogManager.info("Changed account to " + account);
LOG.info("Changed account to " + account);
Data.SELECTED_ACCOUNT = account;
App.settings.lastAccount = account.username;
}

View file

@ -34,8 +34,12 @@ import com.atlauncher.network.ErrorReporting;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class ConfigManager {
public class ConfigManager{
private static final Logger LOG = LogManager.getLogger(ConfigManager.class);
/**
* Gets a config item. Use dot notation to get an item from the config
@ -84,7 +88,7 @@ public class ConfigManager {
}
return thirdLevel.containsKey(keyParts[2]);
} catch (Throwable t) {
LogManager.logStackTrace(String.format("Error checking if config value for key '%s' exists", key), t);
LOG.error(String.format("Error checking if config value for key '%s' exists", key), t);
return false;
}
}
@ -121,7 +125,7 @@ public class ConfigManager {
return (T) thirdLevel.get(keyParts[2]);
} catch (Throwable t) {
LogManager.logStackTrace(String.format("Error loading config value for key '%s'", key), t);
LOG.error(String.format("Error loading config value for key '%s'", key), t);
return defaultValue;
}
}
@ -131,7 +135,7 @@ public class ConfigManager {
*/
public static void loadConfig() {
PerformanceManager.start();
LogManager.debug("Loading config");
LOG.debug("Loading config");
java.lang.reflect.Type type = new TypeToken<Map<String, Object>>() {
}.getType();
@ -144,20 +148,20 @@ public class ConfigManager {
Data.CONFIG = Gsons.DEFAULT.fromJson(in, type);
in.close();
} catch (JsonIOException | JsonSyntaxException | IOException e) {
LogManager.logStackTrace(e);
LOG.error("error: ", e);
}
if (App.configOverride != null) {
try {
Data.CONFIG_OVERRIDES = Gsons.DEFAULT.fromJson(App.configOverride, type);
} catch (JsonIOException | JsonSyntaxException e) {
LogManager.logStackTrace("Failed to read in config overrides", e);
LOG.error("Failed to read in config overrides", e);
}
}
afterConfigLoaded();
LogManager.debug("Finished loading config");
LOG.debug("Finished loading config");
PerformanceManager.end();
}

View file

@ -26,8 +26,13 @@ import com.atlauncher.data.Instance;
import com.atlauncher.data.curseforge.CurseForgeFile;
import com.atlauncher.data.curseforge.CurseForgeProject;
import com.atlauncher.utils.CurseForgeApi;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class CurseForgeUpdateManager {
private static final Logger LOG = LogManager.getLogger(CurseForgeUpdateManager.class);
public static CurseForgeFile getLatestVersion(Instance instance) {
return Data.CURSEFORGE_INSTANCE_LATEST_VERSION.get(instance);
}
@ -38,7 +43,7 @@ public class CurseForgeUpdateManager {
}
PerformanceManager.start();
LogManager.info("Checking for updates to CurseForge instances");
LOG.info("Checking for updates to CurseForge instances");
int[] projectIdsFound = Data.INSTANCES.parallelStream()
.filter(i -> i.isCurseForgePack() && i.hasCurseForgeProjectId())

View file

@ -17,6 +17,7 @@
*/
package com.atlauncher.managers;
import java.awt.Dialog;
import java.awt.Window;
import java.io.File;
import java.util.LinkedList;
@ -30,9 +31,17 @@ import javax.swing.JOptionPane;
import com.atlauncher.App;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
import org.slf4j.MarkerFactory;
public final class DialogManager {
private static final Logger LOG = LogManager.getLogger(DialogManager.class);
public static final int OPTION_TYPE = 0;
public static final int CONFIRM_TYPE = 1;
public static final int OK_TYPE = 1;
@ -189,7 +198,7 @@ public final class DialogManager {
return JOptionPane.showOptionDialog(this.getParent(), this.content, this.title, this.lookAndFeel, this.type,
this.icon, this.getOptions(), this.defaultOption);
} catch (Exception e) {
LogManager.logStackTrace(e, false);
LOG.error(MarkerManager.getMarker("NoReporting"), "Couldn't show dialog", e);
}
return -1;
@ -246,7 +255,7 @@ public final class DialogManager {
return CLOSED_OPTION;
} catch (Exception e) {
LogManager.logStackTrace(e, false);
LOG.error(e);
}
return -1;
@ -261,7 +270,7 @@ public final class DialogManager {
return (String) JOptionPane.showInputDialog(this.getParent(), this.content, this.title, this.type,
this.icon, null, defaultValue);
} catch (Exception e) {
LogManager.logStackTrace(e, false);
LOG.error(MarkerManager.getMarker("NoReporting"), "Couldn't show input dialog", e);
}
return null;

View file

@ -34,8 +34,13 @@ import com.atlauncher.utils.FileUtils;
import com.atlauncher.utils.Utils;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class InstanceManager {
private static final Logger LOG = LogManager.getLogger(InstanceManager.class);
public static List<Instance> getInstances() {
return Data.INSTANCES;
}
@ -51,7 +56,7 @@ public class InstanceManager {
*/
public static void loadInstances() {
PerformanceManager.start();
LogManager.debug("Loading instances");
LOG.debug("Loading instances");
Data.INSTANCES.clear();
for (String folder : Optional.of(FileSystem.INSTANCES.toFile().list(Utils.getInstanceFileFilter()))
@ -64,21 +69,21 @@ public class InstanceManager {
try (FileReader fileReader = new FileReader(new File(instanceDir, "instance.json"))) {
instance = Gsons.MINECRAFT.fromJson(fileReader, Instance.class);
instance.ROOT = instanceDir.toPath();
LogManager.debug("Loaded instance from " + instanceDir);
LOG.debug("Loaded instance from " + instanceDir);
if (instance.launcher == null) {
instance = null;
throw new JsonSyntaxException("Error parsing instance.json as Instance");
}
} catch (JsonIOException | JsonSyntaxException e) {
LogManager.logStackTrace("Failed to load instance in the folder " + instanceDir, e);
LOG.error("Failed to load instance in the folder " + instanceDir, e);
continue;
}
if (instance.launcher.curseForgeManifest != null
&& instance.launcher.curseForgeManifest.projectID != null
&& instance.launcher.curseForgeManifest.fileID != null) {
LogManager.info(String.format("Converting instance \"%s\" CurseForge information",
LOG.error(String.format("Converting instance \"%s\" CurseForge information",
instance.launcher.name));
instance.launcher.curseForgeProject = CurseForgeApi
.getProjectById(instance.launcher.curseForgeManifest.projectID);
@ -91,7 +96,7 @@ public class InstanceManager {
}
if (instance.launcher.numPlays == null) {
LogManager.info(String.format("Converting instance \"%s\" numPlays/lastPlayed",
LOG.info(String.format("Converting instance \"%s\" numPlays/lastPlayed",
instance.launcher.name));
instance.launcher.numPlays = instance.numPlays;
instance.launcher.lastPlayed = instance.lastPlayed;
@ -101,8 +106,7 @@ public class InstanceManager {
if (instance.launcher.account != null
&& !AccountManager.isAccountByName(instance.launcher.account)) {
LogManager.warn(
String.format("No account with name of %s, so setting instance account back to default",
LOG.warn(String.format("No account with name of %s, so setting instance account back to default",
instance.launcher.account));
instance.launcher.account = null;
instance.save();
@ -110,7 +114,7 @@ public class InstanceManager {
Data.INSTANCES.add(instance);
} catch (Exception e2) {
LogManager.logStackTrace("Failed to load instance in the folder " + instanceDir, e2);
LOG.error("Failed to load instance in the folder " + instanceDir, e2);
continue;
}
}
@ -126,7 +130,7 @@ public class InstanceManager {
}
});
LogManager.debug("Finished loading instances");
LOG.debug("Finished loading instances");
PerformanceManager.end();
}
@ -205,7 +209,7 @@ public class InstanceManager {
Instance clonedInstance = Gsons.MINECRAFT.fromJson(Gsons.MINECRAFT.toJson(instance), Instance.class);
if (clonedInstance == null) {
LogManager.error("Error Occurred While Cloning Instance! Instance Object Couldn't Be Cloned!");
LOG.error("Error Occurred While Cloning Instance! Instance Object Couldn't Be Cloned!");
} else {
clonedInstance.launcher.name = clonedName;
clonedInstance.ROOT = FileSystem.INSTANCES.resolve(clonedInstance.getSafeName());

View file

@ -1,259 +0,0 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2022 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.managers;
import java.io.CharArrayWriter;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.atlauncher.Gsons;
import com.atlauncher.evnt.LogEvent;
import com.atlauncher.evnt.LogEvent.LogType;
import com.atlauncher.exceptions.LocalException;
import com.atlauncher.network.Analytics;
import com.atlauncher.network.DownloadException;
import com.atlauncher.network.ErrorReporting;
import com.atlauncher.thread.LoggingThread;
import com.atlauncher.utils.SystemOutInterceptor;
public final class LogManager {
private static final BlockingQueue<LogEvent> queue = new ArrayBlockingQueue<>(128);
public static boolean showDebug = false;
private static final Pattern LOG4J_THREAD_REGEX = Pattern.compile("<log4j:Event.*?thread=\"(.*?)\".*?>");
private static final Pattern LOG4J_LEVEL_REGEX = Pattern.compile("<log4j:Event.*?level=\"(.*?)\".*?>");
private static final Pattern LOG4J_MESSAGE_REGEX = Pattern
.compile("<log4j:Message><!\\[CDATA\\[(.*?)\\]\\]></log4j:Message>");
public static void start() {
new LoggingThread(queue).start();
redirectSystemOutLogs();
}
private static void redirectSystemOutLogs() {
PrintStream origOut = System.out;
PrintStream origErr = System.err;
System.setOut(new SystemOutInterceptor(origOut, LogType.DEBUG));
System.setErr(new SystemOutInterceptor(origErr, LogType.ERROR));
}
/**
* The level of debug logs to show. 1 being lowest, 2 being meh, 3 being
* EXTREEEEEEEME and 5 being OMG WTF SO MUCH LOGS
*/
public static int debugLevel = 0;
public static void info(String message) {
queue.offer(new LogEvent(LogType.INFO, message));
}
public static void debug(String message) {
if (showDebug) {
queue.offer(new LogEvent(LogType.DEBUG, message));
}
}
public static void warn(String message) {
queue.offer(new LogEvent(LogType.WARN, message));
}
public static void error(String message) {
queue.offer(new LogEvent(LogType.ERROR, message));
}
public static void debugObject(Object object) {
debug(Gsons.DEFAULT.toJson(object));
}
public static void debug(String message, int level) {
if (debugLevel >= level) {
debug(message);
}
}
public static void minecraft(String message) {
Object[] value = prepareMessageForMinecraftLog(message);
queue.offer(new LogEvent((LogType) value[0], (String) value[1], LogEvent.CONSOLE));
}
public static void logStackTrace(Throwable t) {
logStackTrace(t, true);
}
public static void logStackTrace(Throwable t, boolean sendRemote) {
t.printStackTrace();
try (CharArrayWriter writer = new CharArrayWriter()) {
Analytics.sendException(t.getMessage());
if (!(t instanceof LocalException) && sendRemote) {
ErrorReporting.captureException(t);
}
t.printStackTrace(new PrintWriter(writer));
error(writer.toString());
}
if (t instanceof DownloadException) {
DownloadException exception = ((DownloadException) t);
try {
if (exception.download.response != null && exception.response != null
&& (exception.download.response.header("Content-Type").equalsIgnoreCase("application/json")
|| exception.download.response.header("Content-Type")
.equalsIgnoreCase("application/xml")
|| exception.download.response.header("Content-Type").startsWith("text/"))) {
debug(exception.response, 5);
}
} catch (Exception e) {
}
}
}
public static void logStackTrace(String message, Throwable t) {
logStackTrace(message, t, true);
}
public static void logStackTrace(String message, Throwable t, boolean sendRemote) {
error(message);
logStackTrace(t, sendRemote);
}
public static Object[] prepareMessageForMinecraftLog(String text) {
LogType type; // The log message type
String message; // The log message
if (text.contains("[INFO] [STDERR]")) {
message = text.substring(text.indexOf("[INFO] [STDERR]"));
type = LogType.WARN;
} else if (text.contains("[INFO]")) {
message = text.substring(text.indexOf("[INFO]"));
if (message.contains("CONFLICT")) {
type = LogType.ERROR;
} else if (message.contains("overwriting existing item")) {
type = LogType.WARN;
} else {
type = LogType.INFO;
}
} else if (text.contains("[WARNING]")) {
message = text.substring(text.indexOf("[WARNING]"));
type = LogType.WARN;
} else if (text.contains("WARNING:")) {
message = text.substring(text.indexOf("WARNING:"));
type = LogType.WARN;
} else if (text.contains("INFO:")) {
message = text.substring(text.indexOf("INFO:"));
type = LogType.INFO;
} else if (text.contains("Exception")) {
message = text;
type = LogType.ERROR;
} else if (text.contains("[SEVERE]")) {
message = text.substring(text.indexOf("[SEVERE]"));
type = LogType.ERROR;
} else if (text.contains("[Sound Library Loader/ERROR]")) {
message = text.substring(text.indexOf("[Sound Library Loader/ERROR]"));
type = LogType.ERROR;
} else if (text.contains("[Sound Library Loader/WARN]")) {
message = text.substring(text.indexOf("[Sound Library Loader/WARN]"));
type = LogType.WARN;
} else if (text.contains("[Sound Library Loader/INFO]")) {
message = text.substring(text.indexOf("[Sound Library Loader/INFO]"));
type = LogType.INFO;
} else if (text.contains("[MCO Availability Checker #1/ERROR]")) {
message = text.substring(text.indexOf("[MCO Availability Checker #1/ERROR]"));
type = LogType.ERROR;
} else if (text.contains("[MCO Availability Checker #1/WARN]")) {
message = text.substring(text.indexOf("[MCO Availability Checker #1/WARN]"));
type = LogType.WARN;
} else if (text.contains("[MCO Availability Checker #1/INFO]")) {
message = text.substring(text.indexOf("[MCO Availability Checker #1/INFO]"));
type = LogType.INFO;
} else if (text.contains("[Client thread/ERROR]")) {
message = text.substring(text.indexOf("[Client thread/ERROR]"));
type = LogType.ERROR;
} else if (text.contains("[Client thread/WARN]")) {
message = text.substring(text.indexOf("[Client thread/WARN]"));
type = LogType.WARN;
} else if (text.contains("[Client thread/INFO]")) {
message = text.substring(text.indexOf("[Client thread/INFO]"));
type = LogType.INFO;
} else if (text.contains("[Server thread/ERROR]")) {
message = text.substring(text.indexOf("[Server thread/ERROR]"));
type = LogType.ERROR;
} else if (text.contains("[Server thread/WARN]")) {
message = text.substring(text.indexOf("[Server thread/WARN]"));
type = LogType.WARN;
} else if (text.contains("[Server thread/INFO]")) {
message = text.substring(text.indexOf("[Server thread/INFO]"));
type = LogType.INFO;
} else if (text.contains("[main/ERROR]")) {
message = text.substring(text.indexOf("[main/ERROR]"));
type = LogType.ERROR;
} else if (text.contains("[main/WARN]")) {
message = text.substring(text.indexOf("[main/WARN]"));
type = LogType.WARN;
} else if (text.contains("[main/INFO]")) {
message = text.substring(text.indexOf("[main/INFO]"));
type = LogType.INFO;
} else {
message = text;
type = LogType.INFO;
}
return new Object[] { type, message };
}
public static void minecraftLog4j(String string) {
String thread = "";
String message = "";
String levelString = "";
LogType level = LogType.INFO;
Matcher threadMatcher = LOG4J_THREAD_REGEX.matcher(string);
if (threadMatcher.find()) {
thread = threadMatcher.group(1);
}
Matcher levelMatcher = LOG4J_LEVEL_REGEX.matcher(string);
if (levelMatcher.find()) {
levelString = levelMatcher.group(1);
if (levelString.equalsIgnoreCase("INFO")) {
level = LogType.INFO;
} else if (levelString.equalsIgnoreCase("ERROR") || levelString.equalsIgnoreCase("SEVERE")) {
level = LogType.ERROR;
} else if (levelString.equalsIgnoreCase("WARN")) {
level = LogType.WARN;
}
}
Matcher messageMatcher = LOG4J_MESSAGE_REGEX.matcher(string);
if (messageMatcher.find()) {
message = messageMatcher.group(1);
}
queue.offer(new LogEvent(level, String.format("[%s/%s] %s", thread, levelString, message),
LogEvent.CONSOLE));
}
}

View file

@ -41,19 +41,23 @@ import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.joda.time.format.ISODateTimeFormat;
import org.slf4j.LoggerFactory;
public class MinecraftManager {
private static final Logger LOG = LogManager.getLogger(MinecraftManager.class);
public static void loadMinecraftVersions() {
loadMinecraftVersions(false);
}
/**
* Loads info about the different Minecraft versions
*/
public static void loadMinecraftVersions(boolean force) {
PerformanceManager.start();
LogManager.debug("Loading Minecraft versions");
LOG.debug("Loading Minecraft versions");
Data.MINECRAFT.clear();
@ -70,14 +74,14 @@ public class MinecraftManager {
versionManifest = download.asClassWithThrow(VersionManifest.class);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error: ", e);
if (Files.exists(manifestPath)) {
try {
versionManifest = Gsons.DEFAULT.fromJson(new FileReader(manifestPath.toFile()),
VersionManifest.class);
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e1) {
LogManager.logStackTrace(e1);
LOG.error("error: ", e1);
}
}
}
@ -90,7 +94,7 @@ public class MinecraftManager {
loadAdditiveVersions();
LogManager.debug("Finished loading Minecraft versions");
LOG.debug("Finished loading Minecraft versions");
PerformanceManager.end();
}
@ -105,7 +109,7 @@ public class MinecraftManager {
try {
additiveVersionsManifest = Gsons.DEFAULT.fromJson(new FileReader(additiveManifestPath.toFile()), type);
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e1) {
LogManager.logStackTrace(e1);
LOG.error("error: ", e1);
}
}
@ -125,7 +129,7 @@ public class MinecraftManager {
*/
public static void loadJavaRuntimes(boolean force) {
PerformanceManager.start();
LogManager.debug("Loading Java runtimes");
LOG.debug("Loading Java runtimes");
try {
Download download = Download.build().setUrl(Constants.MINECRAFT_JAVA_RUNTIME_URL);
@ -137,10 +141,10 @@ public class MinecraftManager {
Data.JAVA_RUNTIMES = download.asClassWithThrow(JavaRuntimes.class);
} catch (IOException e) {
// safe to ignore, we'll just not use it
LogManager.logStackTrace(e);
LOG.error("error: ", e);
}
LogManager.debug("Finished loading Java runtimes");
LOG.debug("Finished loading Java runtimes");
PerformanceManager.end();
}

View file

@ -24,12 +24,18 @@ import com.atlauncher.App;
import com.atlauncher.Data;
import com.atlauncher.constants.Constants;
import com.atlauncher.data.Instance;
import com.atlauncher.data.json.Mod;
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
import com.atlauncher.data.modpacksch.ModpacksChPackVersion;
import okhttp3.CacheControl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class ModpacksChUpdateManager {
private static final Logger LOG = LogManager.getLogger(ModpacksChUpdateManager.class);
public static ModpacksChPackVersion getLatestVersion(Instance instance) {
return Data.MODPACKS_CH_INSTANCE_LATEST_VERSION.get(instance);
}
@ -40,7 +46,7 @@ public class ModpacksChUpdateManager {
}
PerformanceManager.start();
LogManager.info("Checking for updates to modpacks.ch instances");
LOG.info("Checking for updates to modpacks.ch instances");
boolean refreshInstancesPanel = Data.INSTANCES.parallelStream().filter(
i -> i.launcher.modpacksChPackManifest != null && i.launcher.modpacksChPackVersionManifest != null)

View file

@ -25,8 +25,12 @@ import com.atlauncher.Data;
import com.atlauncher.data.Instance;
import com.atlauncher.data.modrinth.ModrinthVersion;
import com.atlauncher.utils.ModrinthApi;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class ModrinthModpackUpdateManager {
private static final Logger LOG = LogManager.getLogger(ModrinthModpackUpdateManager.class);
public static ModrinthVersion getLatestVersion(Instance instance) {
return Data.MODRINTH_INSTANCE_LATEST_VERSION.get(instance);
}
@ -37,7 +41,7 @@ public class ModrinthModpackUpdateManager {
}
PerformanceManager.start();
LogManager.info("Checking for updates to Modrinth instances");
LOG.info("Checking for updates to Modrinth instances");
boolean refreshInstancesPanel = Data.INSTANCES.parallelStream()
.filter(i -> i.isModrinthPack()).map(i -> {

View file

@ -32,8 +32,12 @@ import com.atlauncher.data.News;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class NewsManager {
public class NewsManager{
private static final Logger LOG = LogManager.getLogger(NewsManager.class);
/**
* Get the News for the Launcher
@ -49,7 +53,7 @@ public class NewsManager {
*/
public static void loadNews() {
PerformanceManager.start();
LogManager.debug("Loading news");
LOG.debug("Loading news");
Data.NEWS.clear();
try {
java.lang.reflect.Type type = new TypeToken<List<News>>() {
@ -61,9 +65,9 @@ public class NewsManager {
Data.NEWS.addAll(Gsons.DEFAULT.fromJson(in, type));
in.close();
} catch (JsonIOException | JsonSyntaxException | IOException e) {
LogManager.logStackTrace(e);
LOG.error("error: ", e);
}
LogManager.debug("Finished loading news");
LOG.debug("Finished loading news");
PerformanceManager.end();
}

View file

@ -39,8 +39,13 @@ import com.atlauncher.utils.Hashing;
import com.google.gson.JsonIOException;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class PackManager {
private static final Logger LOG = LogManager.getLogger(PackManager.class);
public static List<Pack> getPacks() {
return Data.PACKS;
}
@ -50,7 +55,7 @@ public class PackManager {
*/
public static void loadPacks() {
PerformanceManager.start();
LogManager.debug("Loading packs");
LOG.debug("Loading packs");
Data.PACKS.clear();
try {
java.lang.reflect.Type type = new TypeToken<List<Pack>>() {
@ -58,9 +63,9 @@ public class PackManager {
Data.PACKS.addAll(Gsons.DEFAULT_ALT
.fromJson(new FileReader(FileSystem.JSON.resolve("packsnew.json").toFile()), type));
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e) {
LogManager.logStackTrace(e);
LOG.error("error: ", e);
}
LogManager.debug("Finished loading packs");
LOG.debug("Finished loading packs");
PerformanceManager.end();
}
@ -263,7 +268,7 @@ public class PackManager {
*/
public static void loadUsers() {
PerformanceManager.start();
LogManager.debug("Loading users");
LOG.debug("Loading users");
List<PackUsers> packUsers = new ArrayList<>();
try {
@ -272,14 +277,14 @@ public class PackManager {
packUsers.addAll(
Gsons.DEFAULT_ALT.fromJson(new FileReader(FileSystem.JSON.resolve("users.json").toFile()), type));
} catch (JsonSyntaxException | FileNotFoundException | JsonIOException e) {
LogManager.logStackTrace(e);
LOG.error("error: ", e);
}
for (PackUsers pu : packUsers) {
pu.addUsers();
}
LogManager.debug("Finished loading users");
LOG.debug("Finished loading users");
PerformanceManager.end();
}
@ -294,7 +299,7 @@ public class PackManager {
if (files != null) {
for (File file : files) {
if (file.isFile() && file.getName().endsWith(".png") && !packImageFilenames.contains(file.getName())) {
LogManager.info("Pack image no longer used, deleting file " + file.getName());
LOG.info("Pack image no longer used, deleting file " + file.getName());
file.delete();
}
}

View file

@ -17,12 +17,17 @@
*/
package com.atlauncher.managers;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Duration;
import java.time.Instant;
import java.util.HashMap;
import java.util.Map;
public final class PerformanceManager {
private static final Logger LOG = LogManager.getLogger(PerformanceManager.class);
private static final Map<String, Instant> times = new HashMap<>();
@ -31,7 +36,7 @@ public final class PerformanceManager {
}
public static void start(String name) {
if (LogManager.showDebug) {
if(LOG.isDebugEnabled()){
times.put(name, Instant.now());
}
}
@ -41,12 +46,12 @@ public final class PerformanceManager {
}
public static void end(String name) {
if (LogManager.showDebug && times.containsKey(name)) {
if (LOG.isDebugEnabled() && times.containsKey(name)) {
long timeElapsed = Duration.between(times.get(name), Instant.now()).toMillis();
times.remove(name);
LogManager.debug(name + " took " + timeElapsed + " ms", 5);
LOG.debug(name + " took " + timeElapsed + " ms", 5);
}
}
}

View file

@ -31,8 +31,13 @@ import com.atlauncher.Gsons;
import com.atlauncher.data.Server;
import com.atlauncher.utils.FileUtils;
import com.atlauncher.utils.Utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class ServerManager {
private static final Logger LOG = LogManager.getLogger(ServerManager.class);
public static List<Server> getServers() {
return Data.SERVERS;
}
@ -42,7 +47,7 @@ public class ServerManager {
*/
public static void loadServers() {
PerformanceManager.start();
LogManager.debug("Loading servers");
LOG.debug("Loading servers");
Data.SERVERS.clear();
for (String folder : Optional.of(FileSystem.SERVERS.toFile().list(Utils.getServerFileFilter()))
@ -53,21 +58,21 @@ public class ServerManager {
try (FileReader fileReader = new FileReader(new File(serverDir, "server.json"))) {
server = Gsons.MINECRAFT.fromJson(fileReader, Server.class);
LogManager.debug("Loaded server from " + serverDir);
LOG.debug("Loaded server from " + serverDir);
} catch (Exception e) {
LogManager.logStackTrace("Failed to load server in the folder " + serverDir, e);
LOG.error("Failed to load server in the folder " + serverDir, e);
continue;
}
if (server == null) {
LogManager.error("Failed to load server in the folder " + serverDir);
LOG.error("Failed to load server in the folder " + serverDir);
continue;
}
Data.SERVERS.add(server);
}
LogManager.debug("Finished loading servers");
LOG.debug("Finished loading servers");
PerformanceManager.end();
}

View file

@ -27,8 +27,13 @@ import com.atlauncher.data.technic.TechnicModpack;
import com.atlauncher.data.technic.TechnicSolderModpack;
import com.atlauncher.network.DownloadException;
import com.atlauncher.utils.TechnicApi;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class TechnicModpackUpdateManager {
private static final Logger LOG = LogManager.getLogger(TechnicModpackUpdateManager.class);
public static TechnicModpack getUpToDateModpack(Instance instance) {
return Data.TECHNIC_INSTANCE_LATEST_VERSION.get(instance);
}
@ -43,7 +48,7 @@ public class TechnicModpackUpdateManager {
}
PerformanceManager.start();
LogManager.info("Checking for updates to Technic Modpack instances");
LOG.info("Checking for updates to Technic Modpack instances");
boolean refreshInstancesPanel = Data.INSTANCES.parallelStream()
.filter(i -> i.isTechnicPack() && i.launcher.checkForUpdates).map(i -> {
@ -55,10 +60,10 @@ public class TechnicModpackUpdateManager {
technicModpack = TechnicApi.getModpackBySlugWithThrow(i.launcher.technicModpack.name);
} catch (DownloadException e) {
if (e.response != null) {
LogManager.debug(Gsons.DEFAULT.toJson(e.response));
LOG.debug(Gsons.DEFAULT.toJson(e.response));
if (e.statusCode == 404) {
LogManager.error(String.format(
LOG.error(String.format(
"Technic pack with name of %s no longer exists, disabling update checks.",
i.launcher.technicModpack.displayName));
i.launcher.checkForUpdates = false;
@ -66,7 +71,7 @@ public class TechnicModpackUpdateManager {
}
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error(e);
}
if (technicModpack == null) {

View file

@ -19,7 +19,6 @@ package com.atlauncher.mclauncher;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.nio.file.Files;
import java.nio.file.Path;
@ -41,7 +40,6 @@ import com.atlauncher.data.MojangAccount;
import com.atlauncher.data.minecraft.Library;
import com.atlauncher.data.minecraft.LoggingClient;
import com.atlauncher.data.minecraft.PropertyMapSerializer;
import com.atlauncher.managers.LogManager;
import com.atlauncher.mclauncher.legacy.LegacyMCLauncher;
import com.atlauncher.network.ErrorReporting;
import com.atlauncher.utils.Java;
@ -51,8 +49,12 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.util.UUIDTypeAdapter;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class MCLauncher {
private static final Logger LOG = LogManager.getLogger(MCLauncher.class);
public static final List<String> IGNORED_ARGUMENTS = new ArrayList<String>() {
{
// these seem to be tracking/telemetry things
@ -89,7 +91,7 @@ public class MCLauncher {
logInstanceInformation(instance);
LogManager.info("Launching Minecraft with the following arguments (user related stuff has been removed): "
LOG.info("Launching Minecraft with the following arguments (user related stuff has been removed): "
+ censorArguments(arguments, account, props, username));
ProcessBuilder processBuilder = new ProcessBuilder(arguments);
processBuilder.directory(instance.getRootDirectory());
@ -101,31 +103,31 @@ public class MCLauncher {
private static void logInstanceInformation(Instance instance) {
try {
if (instance.launcher.loaderVersion != null) {
LogManager.info(String.format("Loader: %s %s", instance.launcher.loaderVersion.type,
LOG.info(String.format("Loader: %s %s", instance.launcher.loaderVersion.type,
instance.launcher.loaderVersion.version));
}
if (instance.ROOT.resolve("mods").toFile().listFiles().length != 0) {
LogManager.info("Mods:");
LOG.info("Mods:");
Files.walk(instance.ROOT.resolve("mods"))
.filter(file -> Files.isRegularFile(file)
&& (file.toString().endsWith(".jar") || file.toString().endsWith(".zip")))
.forEach(file -> {
LogManager.info(
LOG.info(
" - " + file.toString().replace(instance.ROOT.resolve("mods").toString(), ""));
});
}
if (instance.launcher.mods.stream().anyMatch(m -> m.skipped)) {
instance.launcher.mods.stream().filter(m -> m.skipped).forEach(m -> {
LogManager.warn(String.format(
LOG.warn(String.format(
"Mod %s (%s) was skipped from downloading during instance installation", m.name, m.file));
});
}
if (instance.shouldUseLegacyLaunch() && Optional.ofNullable(instance.launcher.disableLegacyLaunching)
.orElse(App.settings.disableLegacyLaunching)) {
LogManager.warn(
LOG.warn(
"Legacy launching disabled. If you have issues with Minecraft, please enable this setting again");
}
} catch (IOException ignored) {
@ -176,7 +178,7 @@ public class MCLauncher {
String javaPath = instance.getJavaPath();
if (instance.isUsingJavaRuntime()) {
LogManager.debug(String.format("Using Java runtime %s (major version %d) at path %s",
LOG.debug(String.format("Using Java runtime %s (major version %d) at path %s",
instance.javaVersion.component, instance.javaVersion.majorVersion, javaPath));
}
@ -216,7 +218,7 @@ public class MCLauncher {
for (File file : libraryFiles) {
if (!file.getName().equalsIgnoreCase("minecraft.jar")
&& !file.getName().equalsIgnoreCase("modpack.jar")) {
LogManager.info("Added in custom library " + file.getName());
LOG.info("Added in custom library " + file.getName());
cpb.append(file);
cpb.append(File.pathSeparator);
@ -239,12 +241,9 @@ public class MCLauncher {
try {
pathh = thisFile.getCanonicalPath();
pathh = URLDecoder.decode(pathh, "UTF-8");
} catch (UnsupportedEncodingException e) {
pathh = System.getProperty("java.class.path");
LogManager.logStackTrace(e);
} catch (IOException e) {
pathh = System.getProperty("java.class.path");
LogManager.logStackTrace(e);
LOG.error("error: ", e);
}
cpb.append(pathh);
}
@ -326,7 +325,7 @@ public class MCLauncher {
for (String arg : javaArguments.split(" ")) {
if (!arg.isEmpty()) {
if (arguments.toString().contains(arg)) {
LogManager.error("Duplicate argument " + arg + " found and not added!");
LOG.error("Duplicate argument " + arg + " found and not added!");
continue;
}
@ -431,7 +430,7 @@ public class MCLauncher {
String username) {
String argsString = arguments.toString();
if (!LogManager.showDebug) {
if (!LOG.isDebugEnabled()) {
if (App.settings != null) {
argsString = argsString.replace(FileSystem.BASE_DIR.toAbsolutePath().toString(), "USERSDIR");
}

View file

@ -23,14 +23,18 @@ import com.atlauncher.App;
import com.atlauncher.Network;
import com.atlauncher.constants.Constants;
import com.atlauncher.evnt.listener.SettingsListener;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Java;
import com.atlauncher.utils.OS;
import com.brsanthu.googleanalytics.GoogleAnalytics;
import com.brsanthu.googleanalytics.GoogleAnalyticsConfig;
import com.brsanthu.googleanalytics.request.DefaultRequest;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public final class Analytics implements SettingsListener {
private static final Logger LOG = LogManager.getLogger(Analytics.class);
private static GoogleAnalytics ga;
public static void startSession() {
@ -106,7 +110,7 @@ public final class Analytics implements SettingsListener {
ga.screenView().sessionControl("end").send();
ga.close();
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}

View file

@ -20,18 +20,21 @@ package com.atlauncher.network;
import java.io.IOException;
import java.net.HttpURLConnection;
import com.atlauncher.managers.LogManager;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public final class DebugLoggingInterceptor implements Interceptor{
private static final Logger LOG = LogManager.getLogger(DebugLoggingInterceptor.class);
public final class DebugLoggingInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
LogManager.debug(String.format("Sending request %s", request.url()), 3);
LOG.debug("Sending request {}", request.url());
String debugLogMessage = request.toString();
if (request.header("Authorization") != null) {
@ -39,7 +42,8 @@ public final class DebugLoggingInterceptor implements Interceptor {
} else if (request.header("x-api-key") != null) {
debugLogMessage = debugLogMessage.replace(request.header("x-api-key"), "REDACTED");
}
LogManager.debug(debugLogMessage, 5);
LOG.debug(debugLogMessage);
long t1 = System.nanoTime();
Response response = chain.proceed(request);
@ -47,15 +51,14 @@ public final class DebugLoggingInterceptor implements Interceptor {
if (response.cacheResponse() != null && (response.networkResponse() == null
|| response.networkResponse().code() == HttpURLConnection.HTTP_NOT_MODIFIED)) {
LogManager.debug(String.format("Received cached response code %d for %s in %.1fms", response.code(),
LOG.debug(String.format("Received cached response code %d for %s in %.1fms", response.code(),
response.request().url(), (t2 - t1) / 1e6d), 3);
} else {
LogManager.debug(String.format("Received response code %d for %s in %.1fms", response.code(),
LOG.debug(String.format("Received response code %d for %s in %.1fms", response.code(),
response.request().url(), (t2 - t1) / 1e6d), 3);
}
LogManager.debug(response.toString(), 5);
LOG.debug("{}", response);
return response;
}
}

View file

@ -31,7 +31,6 @@ import java.util.Map;
import com.atlauncher.FileSystem;
import com.atlauncher.Gsons;
import com.atlauncher.Network;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.ArchiveUtils;
import com.atlauncher.utils.FileUtils;
import com.atlauncher.utils.Hashing;
@ -46,9 +45,14 @@ import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;
import okhttp3.Response;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
// TODO: fuck this file, it's shit, I hate it
public final class Download {
private static Logger LOG = LogManager.getLogger(Download.class);
public static final int MAX_ATTEMPTS = 3;
// pre request
@ -88,9 +92,14 @@ public final class Download {
}
return this.response.isSuccessful();
} catch(DownloadException exc){
LOG.error("error fetching download from {}", this.url, exc);
if(exc.hasResponse()){
LOG.error("response: {}", exc.getResponse());
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error fetching download from {}", this.url, e);
} finally{
if (this.response != null) {
this.response.close();
this.response = null;
@ -106,8 +115,7 @@ public final class Download {
return this.response.body().string();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
if (this.response != null) {
this.response.close();
this.response = null;
@ -137,8 +145,7 @@ public final class Download {
try {
return asClassWithThrow(tClass, gson);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
if (this.response != null) {
this.response.close();
this.response = null;
@ -175,9 +182,8 @@ public final class Download {
public <T> T asType(Type tClass, Gson gson) {
try {
return asTypeWithThrow(tClass, gson);
} catch (IOException e) {
LogManager.logStackTrace(e);
} catch (IOException e){
LOG.error("error", e);
if (this.response != null) {
this.response.close();
this.response = null;
@ -324,8 +330,7 @@ public final class Download {
}
return this.response.code();
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
if (this.response != null) {
this.response.close();
this.response = null;
@ -373,7 +378,7 @@ public final class Download {
try {
this.hash = this.getHashFromURL();
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
this.hash = "-";
}
}
@ -396,7 +401,7 @@ public final class Download {
}
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return -1;
}
@ -420,7 +425,7 @@ public final class Download {
return false;
}
} catch (IOException e) {
LogManager.error("Error getting murmur hash");
LOG.error("Error getting murmur hash", e);
return false;
}
} else if (this.md5() && Hashing.md5(this.to).equals(Hashing.toHashCode(this.getHash()))) {
@ -451,8 +456,8 @@ public final class Download {
try (FileChannel fc = FileChannel.open(this.to, Utils.WRITE);
ReadableByteChannel rbc = Channels.newChannel(this.response.body().byteStream())) {
fc.transferFrom(rbc, 0, Long.MAX_VALUE);
} catch (Exception e) {
LogManager.logStackTrace("Failed to download file " + this.to, e, false);
} catch (Exception e){
LOG.error("Failed to download file {}", this.to, e);//don't send
}
}
@ -462,7 +467,7 @@ public final class Download {
try {
return Hashing.murmur(this.to) == this.fingerprint;
} catch (IOException e) {
LogManager.error("Error getting murmur hash");
LOG.error("Error getting murmur hash", e);
return false;
}
} else if (this.md5()) {
@ -492,8 +497,7 @@ public final class Download {
try {
this.execute();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
if (this.response != null) {
this.response.close();
this.response = null;
@ -516,14 +520,13 @@ public final class Download {
// if hash doesn't match but we're ignoring failures, then pass it if not 0 in
// size and log a warning
if (this.ignoreFailures && this.to.toFile().length() != 0) {
LogManager
.warn(String.format("%s (of size %d) hash didn't match, but we're ignoring failures, so continuing",
LOG.warn(String.format("%s (of size %d) hash didn't match, but we're ignoring failures, so continuing",
this.to.getFileName(), this.to.toFile().length()));
return true;
}
// if the hash doesn't match, attempt again
LogManager.debug("Failed downloading " + this.url + " on attempt " + attempt);
LOG.debug("Failed downloading " + this.url + " on attempt " + attempt);
return this.downloadRec(attempt + 1);
}
@ -624,26 +627,27 @@ public final class Download {
if (!downloaded) {
if (this.response != null && this.response.header("content-type").contains("text/html")) {
LogManager.error(
"The response from this request was a HTML response. This is usually caused by an antivirus or firewall software intercepting and rewriting the response. The response is below.");
LogManager.error(new String(Files.readAllBytes(this.to)));
LOG.error("The response from this request was a HTML response. This is usually caused by an antivirus or firewall software intercepting and rewriting the response. The response is below.");
LOG.error(new String(Files.readAllBytes(this.to)));
}
FileUtils.copyFile(this.to, FileSystem.FAILED_DOWNLOADS);
if (fingerprint != null) {
LogManager.error("Error downloading " + this.to.getFileName() + " from " + this.url + ". Expected"
+ " fingerprint of " + fingerprint.toString() + " (with size of " + this.size + ") but got "
+ Hashing.murmur(this.to) + " (with size of "
+ (Files.exists(this.to) ? Files.size(this.to) : 0)
+ ") instead. Copied to FailedDownloads folder & cancelling install!");
LOG.error("Error downloading {} from {}. Expected fingerprint of {} (with size of {}) but got {} (with size of {}) instead. Copied to FailedDownloads folder & cancelling install!",
this.to.getFileName(),
this.url,
this.fingerprint,
this.size,
Hashing.murmur(this.to),
(Files.exists(this.to) ? Files.size(this.to) : 0));
} else {
LogManager.error("Error downloading " + this.to.getFileName() + " from " + this.url + ". Expected"
+ " hash of " + expected.toString() + " (with size of " + this.size + ") but got "
+ (this.md5() ? Hashing.md5(this.to)
: (this.sha512() ? Hashing.sha512(this.to) : Hashing.sha1(this.to)))
+ " (with size of " + (Files.exists(this.to) ? Files.size(this.to) : 0)
+ ") instead. Copied to FailedDownloads folder & cancelling install!");
LOG.error("Error downloading {} from {}. Expected hash of {} (with size of {}) but got {} (with size of {}) instead. Copied to FailedDownloads folder & cancelling install!",
this.to.getFileName(),
this.url,
expected,
this.size,
(this.md5() ? Hashing.md5(this.to) : (this.sha512() ? Hashing.sha512(this.to) : Hashing.sha1(this.to))),
(Files.exists(this.to) ? Files.size(this.to) : 0));
}
if (this.instanceInstaller != null) {
this.instanceInstaller.cancel(true);

View file

@ -39,4 +39,17 @@ public class DownloadException extends IOException {
}
}
}
public String getResponse(){
return this.response;
}
public boolean hasResponse(){
if(this.download.response == null || this.response == null)
return false;
final String contentType = this.download.response.header("Content-Type");
return contentType.equalsIgnoreCase("application/json")
|| contentType.equalsIgnoreCase("application/xml")
|| contentType.startsWith("text/");
}
}

View file

@ -25,11 +25,15 @@ import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import com.atlauncher.App;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public final class DownloadPool extends LinkedList<Download> {
private static final Logger LOG = LogManager.getLogger(DownloadPool.class);
private final boolean wait;
public DownloadPool(boolean wait) {
@ -125,7 +129,7 @@ public final class DownloadPool extends LinkedList<Download> {
this.dl.copy();
}
} catch (Exception e) {
LogManager.logStackTrace("Error trying to download " + this.dl.to.getFileName(), e);
LOG.error("Error trying to download " + this.dl.to.getFileName(), e);
}
}
}

View file

@ -17,20 +17,23 @@
*/
package com.atlauncher.network;
import java.util.ArrayList;
import java.util.List;
import com.atlauncher.constants.Constants;
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Java;
import com.atlauncher.utils.Utils;
import io.sentry.Breadcrumb;
import io.sentry.Sentry;
import io.sentry.SentryLevel;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.MarkerManager;
import java.util.ArrayList;
import java.util.List;
public final class ErrorReporting {
private static final Logger LOG = LogManager.getLogger(ErrorReporting.class);
public static List<String> sentEvents = new ArrayList<>();
public static List<String> ignoredMessages = new ArrayList<>();
public static boolean sentryInitialised = false;
@ -85,7 +88,7 @@ public final class ErrorReporting {
try {
Sentry.close();
} catch (Exception e) {
LogManager.logStackTrace("Error disabling error reporting", e);
LOG.error(MarkerManager.getMarker("NoReporting"), "Error disabling error reporting", e);
}
sentryInitialised = false;

View file

@ -23,16 +23,20 @@ import java.util.ArrayList;
import java.util.List;
import com.atlauncher.App;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.Resources;
import com.formdev.flatlaf.FlatDarculaLaf;
import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatIntelliJLaf;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.FlatLightLaf;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
@SuppressWarnings("serial")
public class ATLauncherLaf extends FlatLaf {
private static final Logger LOG = LogManager.getLogger(ATLauncherLaf.class);
public static ATLauncherLaf instance;
private final String defaultFontName = "OpenSans-Regular";
@ -97,7 +101,7 @@ public class ATLauncherLaf extends FlatLaf {
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(Resources.makeFont(consoleFontName));
GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(Resources.makeFont(tabFontName));
} catch (Throwable t) {
LogManager.logStackTrace("Error registering fonts", t);
LOG.error("Error registering fonts", t);
}
}

View file

@ -1,51 +0,0 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2022 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.thread;
import java.util.concurrent.BlockingQueue;
import com.atlauncher.evnt.LogEvent;
import org.apache.logging.log4j.Logger;
public final class LoggingThread extends Thread {
private final BlockingQueue<LogEvent> queue;
private static final Logger logger = org.apache.logging.log4j.LogManager.getLogger(LoggingThread.class);
public LoggingThread(BlockingQueue<LogEvent> queue) {
this.queue = queue;
this.setName("ATL-Logging-Thread");
}
@Override
public void run() {
while (true) {
LogEvent next;
try {
next = this.queue.take();
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
return;
}
if (next != null) {
next.post(logger);
}
}
}
}

View file

@ -31,9 +31,13 @@ import java.util.concurrent.Callable;
import com.atlauncher.App;
import com.atlauncher.Network;
import com.atlauncher.constants.Constants;
import com.atlauncher.managers.LogManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public final class PasteUpload implements Callable<String> {
private static final Logger LOG = LogManager.getLogger(PasteUpload.class);
@Override
public String call() {
String log = App.console.getLog().replace(System.getProperty("line.separator"), "\n");
@ -44,17 +48,17 @@ public final class PasteUpload implements Callable<String> {
urlParameters += "private=" + URLEncoder.encode("1", "UTF-8") + "&";
urlParameters += "text=" + URLEncoder.encode(log, "UTF-8");
} catch (UnsupportedEncodingException e) {
LogManager.logStackTrace("Unsupported encoding", e);
LOG.error("Unsupported encoding", e);
return "Unsupported encoding";
}
HttpURLConnection conn;
try {
conn = (HttpURLConnection) new URL(Constants.PASTE_API_URL).openConnection();
} catch (MalformedURLException e) {
LogManager.logStackTrace("Malformed paste API URL", e);
LOG.error("Malformed paste API URL", e);
return "Malformed paste API URL";
} catch (IOException e) {
LogManager.logStackTrace("Failed to connect to paste API", e);
LOG.error("Failed to connect to paste API", e);
return "Failed to connect to paste API";
}
conn.setDoOutput(true);
@ -65,7 +69,7 @@ public final class PasteUpload implements Callable<String> {
conn.getOutputStream().flush();
conn.getOutputStream().close();
} catch (IOException e) {
LogManager.logStackTrace("Failed to send data to paste API", e);
LOG.error("Failed to send data to paste API", e);
return "Failed to send data to paste API";
}
@ -74,10 +78,10 @@ public final class PasteUpload implements Callable<String> {
try {
stream = conn.getInputStream();
} catch (IOException e) {
LogManager.logStackTrace("Failed to receive response from paste API", e);
LOG.error("Failed to receive response from paste API", e);
stream = conn.getErrorStream();
if (stream == null) {
LogManager.error("No error message returned from paste API");
LOG.error("No error message returned from paste API");
return "No error message returned from paste API";
}
}
@ -88,12 +92,12 @@ public final class PasteUpload implements Callable<String> {
builder.append(line);
}
} catch (IOException e) {
LogManager.logStackTrace("Failed to read error data", e);
LOG.error("Failed to read error data", e);
} finally {
try {
reader.close();
} catch (IOException e) {
LogManager.logStackTrace("Failed to close error reader", e);
LOG.error("Failed to close error reader", e);
}
}
return builder.toString();

View file

@ -29,26 +29,28 @@ import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import javax.annotation.Nullable;
import com.atlauncher.managers.LogManager;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.zeroturnaround.zip.NameMapper;
import org.zeroturnaround.zip.ZipUtil;
import javax.annotation.Nullable;
public class ArchiveUtils {
private static final Logger LOG = LogManager.getLogger(ArchiveUtils.class);
public static boolean archiveContainsFile(Path archivePath, String file) {
try {
return ZipUtil.containsEntry(archivePath.toFile(), file);
} catch (Throwable t) {
// allow this to fail as we can fallback to Apache Commons library
LogManager.error("Failed to check if archive contains file in " + archivePath.toAbsolutePath());
LOG.error("Failed to check if archive contains file in {}", archivePath.toAbsolutePath());
}
boolean found = false;
@ -67,7 +69,7 @@ public class ArchiveUtils {
}
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return found;
@ -90,7 +92,7 @@ public class ArchiveUtils {
is = Files.newInputStream(archivePath);
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error(e);
}
return is;
@ -101,8 +103,7 @@ public class ArchiveUtils {
return new String(ZipUtil.unpackEntry(createStream(archivePath), file));
} catch (Throwable t) {
// allow this to fail as we can fallback to Apache Commons library
LogManager.debug(
"Failed to get contents of file in " + archivePath.toAbsolutePath() + ". Trying fallback method");
LOG.debug("Failed to get contents of file in " + archivePath.toAbsolutePath() + ". Trying fallback method");
}
String contents = null;
@ -123,10 +124,10 @@ public class ArchiveUtils {
}
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error(e);
}
} catch (Exception e) {
LogManager.logStackTrace(e);
} catch (Exception e){
LOG.error("error", e);
}
return contents;
@ -142,7 +143,7 @@ public class ArchiveUtils {
return true;
} catch (Throwable t) {
// allow this to fail as we can fallback to Apache Commons library
LogManager.error("Failed to extract " + archivePath.toAbsolutePath());
LOG.error("Failed to extract {}", archivePath.toAbsolutePath());
}
try (InputStream is = Files.newInputStream(archivePath);
@ -164,9 +165,7 @@ public class ArchiveUtils {
outputPath = extractToPath.resolve(fileName);
} catch (InvalidPathException e) {
String newFilename = fileName.replaceAll("[:*\\?\"<>|]", "");
LogManager
.warn(String.format("InvalidPath when extracting file with name of '%s'. Renaming to '%s'",
fileName, newFilename));
LOG.warn("Invalid path when extracting file with name of '{}'. Renaming to '{}'", fileName, newFilename);
outputPath = extractToPath.resolve(newFilename);
}
@ -186,7 +185,7 @@ public class ArchiveUtils {
}
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return false;
}
@ -203,8 +202,9 @@ public class ArchiveUtils {
return true;
} catch (Throwable t) {
// allow this to fail as we can fallback to Apache Commons library
LogManager.error("Failed to create zip " + archivePath.toAbsolutePath() + " from "
+ pathToCompress.toAbsolutePath());
LOG.error("Failed to create zip {} from {}",
archivePath.toAbsolutePath(),
pathToCompress.toAbsolutePath());
}
try (OutputStream os = Files.newOutputStream(archivePath);
@ -232,7 +232,7 @@ public class ArchiveUtils {
aos.closeArchiveEntry();
} catch (IOException e) {
LogManager.logStackTrace(String.format("Unable to add %s to zip", file), e);
LOG.error(String.format("Unable to add %s to zip", file), e);
}
return FileVisitResult.CONTINUE;
@ -240,13 +240,13 @@ public class ArchiveUtils {
@Override
public FileVisitResult visitFileFailed(Path file, IOException e) {
LogManager.logStackTrace(String.format("Unable to add %s to zip", file), e);
LOG.error(String.format("Unable to add %s to zip", file), e);
return FileVisitResult.CONTINUE;
}
});
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return false;
}

View file

@ -20,7 +20,6 @@ package com.atlauncher.utils;
import com.atlauncher.App;
import com.atlauncher.data.LoginResponse;
import com.atlauncher.data.MojangAccount;
import com.atlauncher.managers.LogManager;
import com.mojang.authlib.Agent;
import com.mojang.authlib.UserAuthentication;
import com.mojang.authlib.exceptions.AuthenticationException;
@ -28,9 +27,14 @@ import com.mojang.authlib.exceptions.AuthenticationUnavailableException;
import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.mini2Dx.gettext.GetText;
import org.slf4j.LoggerFactory;
public class Authentication {
private static final Logger LOG = LogManager.getLogger(Authentication.class);
public static LoginResponse checkAccount(String username, String password, String clientToken) {
YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(
App.settings.proxy, clientToken).createUserAuthentication(Agent.MINECRAFT);
@ -52,7 +56,7 @@ public class Authentication {
response.setErrorMessage(e.getMessage());
}
LogManager.error("Authentication failed");
LOG.error("Authentication failed");
}
}
@ -82,7 +86,7 @@ public class Authentication {
} catch (AuthenticationUnavailableException e) {
response.setErrorMessage(e.getMessage());
response.setOffline();
LogManager.error("Authentication servers unavailable");
LOG.error("Authentication servers unavailable");
} catch (AuthenticationException e) {
if (e.getMessage().contains("410")) {
response.setErrorMessage(GetText.tr(
@ -91,7 +95,7 @@ public class Authentication {
response.setErrorMessage(e.getMessage());
}
LogManager.error("Authentication failed");
LOG.error("Authentication failed");
}
}

View file

@ -36,9 +36,13 @@ import com.atlauncher.FileSystem;
import com.atlauncher.data.Instance;
import com.atlauncher.data.minecraft.JavaRuntimes;
import com.atlauncher.exceptions.CommandException;
import com.atlauncher.managers.LogManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class CommandExecutor {
private static final Logger LOG = LogManager.getLogger(CommandExecutor.class);
/**
* Runs the specified {@code command} in the system command line. Substitutes
* <br/>
@ -62,7 +66,7 @@ public class CommandExecutor {
try {
command = replaceArgumentTokensForCommand(getCommandArgumentTokensForInstance(instance), command);
LogManager.info("Running command: \"" + command + "\"");
LOG.info("Running command: \"{}\"", command);
Process process;
@ -84,7 +88,7 @@ public class CommandExecutor {
throw new CommandException();
}
} catch (IOException | InterruptedException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
throw new CommandException(e);
}
}
@ -96,10 +100,10 @@ public class CommandExecutor {
String line;
while ((line = reader.readLine()) != null) {
LogManager.info(line);
LOG.info(line);
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
// throw new RuntimeException(e);
}
}
@ -121,10 +125,9 @@ public class CommandExecutor {
}
}
LogManager.error(message.toString());
LOG.error("error: {}", message);
} catch (Exception e) {
LogManager.logStackTrace(e);
// throw new RuntimeException(e);
LOG.error("error", e);
}
}
@ -180,8 +183,10 @@ public class CommandExecutor {
if (Files.isDirectory(runtimeDirectory)) {
javaPath = runtimeDirectory.toAbsolutePath().toString();
LogManager.debug(String.format("Using Java runtime %s (major version %d) at path %s",
instance.javaVersion.component, instance.javaVersion.majorVersion, javaPath));
LOG.debug("Using Java runtime {} (major version {}) at path {}",
instance.javaVersion.component,
instance.javaVersion.majorVersion,
javaPath);
}
}

View file

@ -35,18 +35,22 @@ import com.atlauncher.data.curseforge.CurseForgeCoreApiResponse;
import com.atlauncher.data.curseforge.CurseForgeFile;
import com.atlauncher.data.curseforge.CurseForgeFingerprint;
import com.atlauncher.data.curseforge.CurseForgeProject;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Download;
import com.google.gson.reflect.TypeToken;
import okhttp3.CacheControl;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Various utility methods for interacting with the CurseForge API.
*/
public class CurseForgeApi {
private static final Logger LOG = LogManager.getLogger(CurseForgeApi.class);
public static List<CurseForgeProject> searchCurseForge(int sectionId, String query, int page, int modLoaderType,
String sort) {
return searchCurseForge(null, sectionId, query, page, modLoaderType, sort);
@ -93,7 +97,7 @@ public class CurseForgeApi {
return response.data;
}
} catch (UnsupportedEncodingException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return null;
@ -224,7 +228,7 @@ public class CurseForgeApi {
return projects.stream().distinct().collect(Collectors.toMap(p -> p.id, p -> p));
}
} catch (Throwable t) {
LogManager.logStackTrace("Error trying to get CurseForge projects as map", t);
LOG.error("Error trying to get CurseForge projects as map", t);
}
return null;

View file

@ -25,22 +25,25 @@ import java.nio.file.StandardCopyOption;
import java.util.stream.Stream;
import com.atlauncher.App;
import com.atlauncher.managers.LogManager;
import com.atlauncher.utils.walker.DeleteDirVisitor;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class FileUtils {
private static final Logger LOG = LogManager.getLogger(FileUtils.class);
public static boolean delete(Path path) {
return delete(path, false);
}
public static boolean delete(Path path, boolean recycle) {
if (!Files.exists(path)) {
LogManager.error("Couldn't delete " + path + " as it doesn't exist!");
LOG.error("Couldn't delete {} as it doesn't exist!", path);
return false;
}
if (Files.isSymbolicLink(path)) {
LogManager.error("Not deleting " + path + " as it's a symlink!");
LOG.error("Not deleting {} as it's a symlink!", path);
return false;
}
@ -54,8 +57,8 @@ public class FileUtils {
try {
Files.delete(path);
} catch (IOException e) {
LogManager.logStackTrace("Path " + path + " couldn't be deleted!", e, false);
} catch (IOException e){
LOG.error("Path {} couldn't be deleted:", path, e);//don't send
return false;
}
@ -64,7 +67,7 @@ public class FileUtils {
private static boolean recycle(Path path) {
if (!Files.exists(path)) {
LogManager.error("Cannot recycle " + path + " as it doesn't exist.");
LOG.error("Cannot recycle " + path + " as it doesn't exist.");
return false;
}
@ -83,14 +86,14 @@ public class FileUtils {
public static boolean deleteDirectory(Path dir) {
if (!Files.exists(dir) || !Files.isDirectory(dir)) {
LogManager.error("Cannot delete directory " + dir + " as it doesn't exist or isn't a directory!");
LOG.error("Cannot delete directory {} as it doesn't exist or isn't a directory!", dir);
return false;
}
try {
Files.walkFileTree(dir, new DeleteDirVisitor());
} catch (IOException e) {
LogManager.logStackTrace("Error trying to delete the directory " + dir, e, false);
} catch (IOException e){
LOG.error("Error trying to delete the directory {}", dir, e);//don't send
return false;
}
@ -117,8 +120,8 @@ public class FileUtils {
try {
Files.createDirectory(directory);
return true;
} catch (IOException e) {
LogManager.logStackTrace("Error creating directory " + directory, e, false);
} catch (IOException e){
LOG.error("Error creating directory {}", directory, e);//don't send
}
return false;
@ -129,14 +132,14 @@ public class FileUtils {
}
public static boolean copyFile(Path from, Path to, boolean withFilename) {
LogManager.debug("Copying file from " + from + " to " + to);
LOG.debug("Copying file from {} to {}", from, to);
if (!Files.isRegularFile(from)) {
LogManager.error("File " + from + " cannot be copied to " + to + " as it isn't a file!");
LOG.error("File {} cannot be copied to {} as it isn't a file!", from, to);
return false;
}
if (!Files.exists(from)) {
LogManager.error("File " + from + " cannot be copied to " + to + " as it doesn't exist!");
LOG.error("File {} cannot be copied to {} as it doesn't exist!", from, to);
return false;
}
@ -156,14 +159,14 @@ public class FileUtils {
return from.toFile().renameTo(to.toFile());
}
} catch (IOException e) {
LogManager.logStackTrace("Failed to copy file " + from + " to " + to, e);
LOG.error("Failed to copy file " + from + " to " + to, e);
return false;
}
try {
Files.copy(from, to, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
} catch (IOException e) {
LogManager.logStackTrace("Failed to copy file " + from + " to " + to, e);
LOG.error("Failed to copy file " + from + " to " + to, e);
return false;
}
@ -183,11 +186,11 @@ public class FileUtils {
FileUtils.delete(from);
}
} catch (IOException e) {
LogManager.logStackTrace("Couldn't delete file " + from + " while renaming to " + to, e);
LOG.error("Couldn't delete file " + from + " while renaming to " + to, e);
}
return true;
} else {
LogManager.error("Couldn't move file " + from + " to " + to);
LOG.error("Couldn't move file {} to {}", from, to);
return false;
}
}

View file

@ -22,13 +22,16 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import com.atlauncher.managers.LogManager;
import com.google.common.hash.HashCode;
import com.sangupta.murmur.Murmur2;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public final class Hashing {
private static final Logger LOG = LogManager.getLogger(Hashing.class);
public static final HashCode EMPTY_HASH_CODE = HashCode.fromBytes(new byte[1]);
public static HashCode md5(String str) {
@ -47,7 +50,7 @@ public final class Hashing {
try {
return com.google.common.io.Files.asByteSource(file.toFile()).hash(com.google.common.hash.Hashing.md5());
} catch (IOException e) {
LogManager.logStackTrace("Error hashing (MD5) file " + file.toAbsolutePath().toString(), e);
LOG.error("Error hashing (MD5) file " + file.toAbsolutePath().toString(), e);
return EMPTY_HASH_CODE;
}
}
@ -60,7 +63,7 @@ public final class Hashing {
try {
return com.google.common.io.Files.asByteSource(file.toFile()).hash(com.google.common.hash.Hashing.sha1());
} catch (IOException e) {
LogManager.logStackTrace("Error hashing (SHA1) file " + file.toAbsolutePath().toString(), e);
LOG.error("Error hashing (SHA1) file " + file.toAbsolutePath().toString(), e);
return EMPTY_HASH_CODE;
}
}
@ -73,7 +76,7 @@ public final class Hashing {
try {
return com.google.common.io.Files.asByteSource(file.toFile()).hash(com.google.common.hash.Hashing.sha512());
} catch (IOException e) {
LogManager.logStackTrace("Error hashing (SHA512) file " + file.toAbsolutePath().toString(), e);
LOG.error("Error hashing (SHA512) file " + file.toAbsolutePath().toString(), e);
return EMPTY_HASH_CODE;
}
}
@ -81,10 +84,10 @@ public final class Hashing {
// TODO: this is really not efficient or good on memory
public static long murmur(Path to) throws IOException {
byte[] bytes = ArrayUtils
.removeAllOccurrences(ArrayUtils.removeAllOccurrences(
ArrayUtils.removeAllOccurrences(
ArrayUtils.removeAllOccurrences(Files.readAllBytes(to), (byte) 9), (byte) 10),
(byte) 13), (byte) 32);
.removeAllOccurrences(ArrayUtils.removeAllOccurrences(
ArrayUtils.removeAllOccurrences(
ArrayUtils.removeAllOccurrences(Files.readAllBytes(to), (byte) 9), (byte) 10),
(byte) 13), (byte) 32);
return Murmur2.hash(bytes, bytes.length, 1L);
}
@ -96,4 +99,4 @@ public final class Hashing {
return HashCode.fromString(hash);
}
}
}

View file

@ -17,33 +17,36 @@
*/
package com.atlauncher.utils;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import com.atlauncher.FileSystem;
import com.atlauncher.Gsons;
import com.atlauncher.data.curseforge.CurseForgeFile;
import com.atlauncher.data.curseforge.pack.CurseForgeManifest;
import com.atlauncher.data.modrinth.pack.ModrinthModpackManifest;
import com.atlauncher.data.multimc.MultiMCInstanceConfig;
import com.atlauncher.data.multimc.MultiMCManifest;
import com.atlauncher.data.nickymoe.SlugResponse;
import com.atlauncher.gui.dialogs.InstanceInstallerDialog;
import com.atlauncher.network.Download;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.*;
import java.nio.file.Path;
import java.util.Optional;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.atlauncher.FileSystem;
import com.atlauncher.Gsons;
import com.atlauncher.data.curseforge.CurseForgeFile;
import com.atlauncher.data.curseforge.CurseForgeFileHash;
import com.atlauncher.data.curseforge.CurseForgeProject;
import com.atlauncher.data.curseforge.pack.CurseForgeManifest;
import com.atlauncher.data.modrinth.ModrinthProject;
import com.atlauncher.data.modrinth.ModrinthVersion;
import com.atlauncher.data.modrinth.pack.ModrinthModpackManifest;
import com.atlauncher.data.multimc.MultiMCInstanceConfig;
import com.atlauncher.data.multimc.MultiMCManifest;
import com.atlauncher.gui.dialogs.InstanceInstallerDialog;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Download;
public class ImportPackUtils {
private static final Logger LOG = LogManager.getLogger(ImportPackUtils.class);
public static boolean loadFromUrl(String url) {
if (url.startsWith("https://www.curseforge.com/minecraft/modpacks")) {
return loadFromCurseForgeUrl(url);
@ -60,14 +63,14 @@ public class ImportPackUtils {
return loadFromFile(saveTo.toFile());
} catch (IOException e) {
LogManager.error("Failed to download modpack file");
LOG.error("Failed to download modpack file");
return false;
}
}
public static boolean loadFromCurseForgeUrl(String url) {
if (!url.startsWith("https://www.curseforge.com/minecraft/modpacks")) {
LogManager.error("Cannot install as the url was not a CurseForge modpack url");
LOG.error("Cannot install as the url was not a CurseForge modpack url");
return false;
}
@ -76,7 +79,7 @@ public class ImportPackUtils {
Matcher matcher = pattern.matcher(url);
if (!matcher.find() || matcher.groupCount() < 2) {
LogManager.error("Cannot install as the url was not a valid CurseForge modpack url");
LOG.error("Cannot install as the url was not a valid CurseForge modpack url");
return false;
}
@ -84,25 +87,25 @@ public class ImportPackUtils {
Integer projectId = null;
Integer fileId = null;
LogManager.debug(matcher.groupCount() + "");
LOG.debug("{}",matcher.groupCount());
if (matcher.groupCount() == 2 && matcher.group(2) != null) {
fileId = Integer.parseInt(matcher.group(2));
}
LogManager.debug("Found pack with slug " + packSlug + " and file id of " + fileId);
LOG.debug("Found pack with slug " + packSlug + " and file id of " + fileId);
CurseForgeProject project = CurseForgeApi.getModPackBySlug(packSlug);
projectId = project.id;
fileId = project.mainFileId;
if (projectId == null || fileId == null) {
LogManager.error(
"Cannot install as the id's couldn't be found. Try using a specific files install link instead.");
LOG.error("Cannot install as the id's couldn't be found. Try using a specific files install link instead.");
return false;
}
LogManager.debug("Resolved to project id " + projectId + " and file id of " + fileId);
LOG.debug("Resolved to project id {} and file id of {}", projectId, fileId);
CurseForgeFile curseFile = CurseForgeApi.getFileForProject(projectId, fileId);
Path tempZip = FileSystem.TEMP.resolve(curseFile.fileName);
@ -126,7 +129,7 @@ public class ImportPackUtils {
download.downloadFile();
} catch (IOException e) {
LogManager.error("Failed to download modpack file from CurseForge");
LOG.error("Failed to download modpack file from CurseForge");
return false;
}
@ -135,7 +138,7 @@ public class ImportPackUtils {
public static boolean loadFromModrinthUrl(String url) {
if (!url.startsWith("https://modrinth.com/modpack")) {
LogManager.error("Cannot install as the url was not a Modrinth modpack url");
LOG.error("Cannot install as the url was not a Modrinth modpack url");
return false;
}
@ -144,25 +147,25 @@ public class ImportPackUtils {
Matcher matcher = pattern.matcher(url);
if (!matcher.find() || matcher.groupCount() < 1) {
LogManager.error("Cannot install as the url was not a valid Modrinth modpack url");
LOG.error("Cannot install as the url was not a valid Modrinth modpack url");
return false;
}
String packSlug = matcher.group(1);
LogManager.debug("Found pack with slug " + packSlug);
LOG.debug("Found pack with slug " + packSlug);
try {
ModrinthProject modrinthProject = ModrinthApi.getProject(packSlug);
if (modrinthProject == null) {
LogManager.info("Failed to get pack from Modrinth");
LOG.info("Failed to get pack from Modrinth");
return false;
}
new InstanceInstallerDialog(modrinthProject);
} catch (Exception e) {
LogManager.logStackTrace("Failed to install Modrinth pack from URL", e);
LOG.error("Failed to install Modrinth pack from URL", e);
return false;
}
@ -194,9 +197,9 @@ public class ImportPackUtils {
FileUtils.deleteDirectory(tmpDir);
LogManager.error("Unknown format for importing");
LOG.error("Unknown format for importing");
} catch (Throwable t) {
LogManager.logStackTrace("Error in zip file for import", t);
LOG.error("Error in zip file for import", t);
}
return false;
@ -204,7 +207,7 @@ public class ImportPackUtils {
public static boolean loadCurseForgeFormat(File file, Integer projectId, Integer fileId) {
if (!file.getName().endsWith(".zip")) {
LogManager.error("Cannot install as the file was not a zip file");
LOG.error("Cannot install as the file was not a zip file");
return false;
}
@ -223,19 +226,19 @@ public class ImportPackUtils {
}
if (!manifest.manifestType.equals("minecraftModpack")) {
LogManager.error("Cannot install as the manifest is not a Minecraft Modpack");
LOG.error("Cannot install as the manifest is not a Minecraft Modpack");
return false;
}
if (manifest.manifestVersion != 1) {
LogManager.warn("Manifest is version " + manifest.manifestVersion + " which may be an issue!");
LOG.warn("Manifest is version {} which may be an issue!", manifest.manifestVersion);
}
ArchiveUtils.extract(file.toPath(), tmpDir);
new InstanceInstallerDialog(manifest, tmpDir);
} catch (Exception e) {
LogManager.logStackTrace("Failed to install CurseForge pack", e);
LOG.error("Failed to install CurseForge pack", e);
FileUtils.deleteDirectory(tmpDir);
return false;
}
@ -245,7 +248,7 @@ public class ImportPackUtils {
public static boolean loadModrinthFormat(File file) {
if (!file.getName().endsWith(".mrpack")) {
LogManager.error("Cannot install as the file was not a mrpack file");
LOG.error("Cannot install as the file was not a mrpack file");
return false;
}
@ -256,7 +259,7 @@ public class ImportPackUtils {
new InstanceInstallerDialog(project, version);
} catch (Exception e) {
LogManager.logStackTrace("Failed to install Modrinth pack", e);
LOG.error("Failed to install Modrinth pack", e);
return false;
}
@ -271,25 +274,24 @@ public class ImportPackUtils {
ModrinthModpackManifest.class);
if (!manifest.game.equals("minecraft")) {
LogManager.error(
"Cannot install as the manifest is for game " + manifest.game + " and not for Minecraft");
LOG.error("Cannot install as the manifest is for game {} and not for Minecraft", manifest.game);
return false;
}
if (!manifest.dependencies.containsKey("minecraft")) {
LogManager.error("Cannot install as the manifest doesn't contain a minecraft dependency");
LOG.error("Cannot install as the manifest doesn't contain a minecraft dependency");
return false;
}
if (manifest.formatVersion != 1) {
LogManager.warn("Manifest is version " + manifest.formatVersion + " which may be an issue!");
LOG.warn("Manifest is version " + manifest.formatVersion + " which may be an issue!");
}
ArchiveUtils.extract(file.toPath(), tmpDir);
new InstanceInstallerDialog(manifest, tmpDir);
} catch (Exception e) {
LogManager.logStackTrace("Failed to install Modrinth pack", e);
LOG.error("Failed to install Modrinth pack", e);
FileUtils.deleteDirectory(tmpDir);
return false;
}
@ -307,14 +309,13 @@ public class ImportPackUtils {
manifest.config = new MultiMCInstanceConfig(props);
if (manifest.formatVersion != 1) {
LogManager.error("Cannot install as the format is version " + manifest.formatVersion
+ " which I cannot install");
LOG.error("Cannot install as the format is version {} which I cannot install", manifest.formatVersion);
return false;
}
new InstanceInstallerDialog(manifest, extractedPath);
} catch (Exception e) {
LogManager.logStackTrace("Failed to install MultiMC pack", e);
LOG.error("Failed to install MultiMC pack", e);
return false;
}

View file

@ -42,14 +42,18 @@ import javax.net.ssl.TrustManagerFactory;
import com.atlauncher.FileSystem;
import com.atlauncher.Network;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.PerformanceManager;
import com.atlauncher.utils.javafinder.JavaFinder;
import com.atlauncher.utils.javafinder.JavaInfo;
import okhttp3.tls.Certificates;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public class Java{
private static final Logger LOG = LogManager.getLogger(Java.class);
public class Java {
/**
* Get the Java version that the launcher runs on.
*
@ -91,13 +95,13 @@ public class Java {
}
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
LogManager.debug(String.format("Got version \"%s\" for Java at path \"%s\"", version, executablePath));
LOG.debug("Got version '{}' for Java at path '{}'", version, executablePath);
if (version.equals("Unknown")) {
LogManager.warn("Cannot get Java version from the output of \"" + folder.getAbsolutePath() + " -version\"");
LOG.warn("Cannot get Java version from the output of \"{} -version\"", folder.getAbsolutePath());
}
return version;
@ -199,7 +203,7 @@ public class Java {
}
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -236,7 +240,7 @@ public class Java {
return;
}
LogManager.info("Injecting Lets Encrypt Certificates");
LOG.info("Injecting Lets Encrypt Certificates");
Network.addTrustedCertificate(Certificates.decodeCertificatePem("-----BEGIN CERTIFICATE-----\n"
+ "MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw\n"
+ "TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh\n"
@ -278,7 +282,7 @@ public class Java {
try {
return keyStore.getCertificate(alias);
} catch (Exception e) {
LogManager.logStackTrace("Failed to get certificate", e);
LOG.error("Failed to get certificate", e);
return null;
}
}));
@ -291,7 +295,7 @@ public class Java {
try {
return leKS.getCertificate(alias);
} catch (KeyStoreException e) {
LogManager.logStackTrace("Failed to get certificate", e);
LOG.error("Failed to get certificate", e);
return null;
}
}));
@ -310,9 +314,9 @@ public class Java {
SSLContext tls = SSLContext.getInstance("TLS");
tls.init(null, instance.getTrustManagers(), null);
HttpsURLConnection.setDefaultSSLSocketFactory(tls.getSocketFactory());
LogManager.info("Injected new root certificates");
LOG.info("Injected new root certificates");
} catch (Exception e) {
LogManager.logStackTrace("Failed to inject new root certificates. Problems might happen", e);
LOG.error("Failed to inject new root certificates. Problems might happen", e);
}
}
}

View file

@ -0,0 +1,110 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2022 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public final class LoggingUtils{
private LoggingUtils(){}
public static void redirectSystemOutLogs(){
System.setOut(SystemOutInterceptor.asDebug(System.out));
System.setErr(SystemOutInterceptor.asError(System.err));
}
private static final Logger MINECRAFT_LOG = LogManager.getLogger("Minecraft");
public static void minecraft(String line){
if (line.contains("[INFO] [STDERR]")){
MINECRAFT_LOG.warn(line.substring(line.indexOf("[INFO] [STDERR]")));
} else if (line.contains("[INFO]")){
line = line.substring(line.indexOf("[INFO]"));
if (line.contains("CONFLICT")) {
MINECRAFT_LOG.error(line);
} else if (line.contains("overwriting existing item")) {
MINECRAFT_LOG.warn(line);
} else {
MINECRAFT_LOG.info(line);
}
} else if (line.contains("[WARNING]")) {
line = line.substring(line.indexOf("[WARNING]"));
MINECRAFT_LOG.warn(line);
} else if (line.contains("WARNING:")) {
line = line.substring(line.indexOf("WARNING:"));
MINECRAFT_LOG.warn(line);
} else if (line.contains("INFO:")) {
line = line.substring(line.indexOf("INFO:"));
MINECRAFT_LOG.info(line);
} else if (line.contains("Exception")) {
line = line;
MINECRAFT_LOG.error(line);
} else if (line.contains("[SEVERE]")) {
line = line.substring(line.indexOf("[SEVERE]"));
MINECRAFT_LOG.error(line);
} else if (line.contains("[Sound Library Loader/ERROR]")) {
line = line.substring(line.indexOf("[Sound Library Loader/ERROR]"));
MINECRAFT_LOG.error(line);
} else if (line.contains("[Sound Library Loader/WARN]")) {
line = line.substring(line.indexOf("[Sound Library Loader/WARN]"));
MINECRAFT_LOG.warn(line);
} else if (line.contains("[Sound Library Loader/INFO]")) {
line = line.substring(line.indexOf("[Sound Library Loader/INFO]"));
MINECRAFT_LOG.info(line);
} else if (line.contains("[MCO Availability Checker #1/ERROR]")) {
line = line.substring(line.indexOf("[MCO Availability Checker #1/ERROR]"));
MINECRAFT_LOG.error(line);
} else if (line.contains("[MCO Availability Checker #1/WARN]")) {
line = line.substring(line.indexOf("[MCO Availability Checker #1/WARN]"));
MINECRAFT_LOG.warn(line);
} else if (line.contains("[MCO Availability Checker #1/INFO]")) {
line = line.substring(line.indexOf("[MCO Availability Checker #1/INFO]"));
MINECRAFT_LOG.info(line);
} else if (line.contains("[Client thread/ERROR]")) {
line = line.substring(line.indexOf("[Client thread/ERROR]"));
MINECRAFT_LOG.error(line);
} else if (line.contains("[Client thread/WARN]")) {
line = line.substring(line.indexOf("[Client thread/WARN]"));
MINECRAFT_LOG.warn(line);
} else if (line.contains("[Client thread/INFO]")) {
line = line.substring(line.indexOf("[Client thread/INFO]"));
MINECRAFT_LOG.info(line);
} else if (line.contains("[Server thread/ERROR]")) {
line = line.substring(line.indexOf("[Server thread/ERROR]"));
MINECRAFT_LOG.error(line);
} else if (line.contains("[Server thread/WARN]")) {
line = line.substring(line.indexOf("[Server thread/WARN]"));
MINECRAFT_LOG.warn(line);
} else if (line.contains("[Server thread/INFO]")) {
line = line.substring(line.indexOf("[Server thread/INFO]"));
MINECRAFT_LOG.info(line);
} else if (line.contains("[main/ERROR]")) {
line = line.substring(line.indexOf("[main/ERROR]"));
MINECRAFT_LOG.error(line);
} else if (line.contains("[main/WARN]")) {
line = line.substring(line.indexOf("[main/WARN]"));
MINECRAFT_LOG.warn(line);
} else if (line.contains("[main/INFO]")) {
line = line.substring(line.indexOf("[main/INFO]"));
MINECRAFT_LOG.info(line);
} else {
MINECRAFT_LOG.info(line);
}
}
}

View file

@ -26,15 +26,18 @@ import com.atlauncher.constants.Constants;
import com.atlauncher.data.modpacksch.ModpacksChPackList;
import com.atlauncher.data.modpacksch.ModpacksChPackManifest;
import com.atlauncher.data.modpacksch.ModpacksChPackVersionModsManifest;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Download;
import okhttp3.CacheControl;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
/**
* Various utility methods for interacting with the Modpacks.ch API.
*/
public class ModpacksChApi {
private static final Logger LOG = LogManager.getLogger(ModpacksChApi.class);
public static List<ModpacksChPackManifest> searchModPacks(String query, int page) {
String url = String.format("%s/modpack/search/50", Constants.MODPACKS_CH_API_URL);
@ -98,7 +101,7 @@ public class ModpacksChApi {
return modsManifest;
} catch (Exception e) {
LogManager.logStackTrace("Error calling mods endpoint for Modpacks.ch", e);
LOG.error("Error calling mods endpoint for Modpacks.ch", e);
}
return null;

View file

@ -17,40 +17,34 @@
*/
package com.atlauncher.utils;
import com.atlauncher.Gsons;
import com.atlauncher.constants.Constants;
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.data.modrinth.*;
import com.atlauncher.network.Download;
import com.atlauncher.network.DownloadException;
import com.google.gson.reflect.TypeToken;
import okhttp3.CacheControl;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.atlauncher.Gsons;
import com.atlauncher.constants.Constants;
import com.atlauncher.data.minecraft.loaders.LoaderVersion;
import com.atlauncher.data.modrinth.ModrinthCategory;
import com.atlauncher.data.modrinth.ModrinthProject;
import com.atlauncher.data.modrinth.ModrinthProjectType;
import com.atlauncher.data.modrinth.ModrinthSearchResult;
import com.atlauncher.data.modrinth.ModrinthVersion;
import com.atlauncher.managers.LogManager;
import com.atlauncher.network.Download;
import com.atlauncher.network.DownloadException;
import com.google.gson.reflect.TypeToken;
import okhttp3.CacheControl;
import okhttp3.MediaType;
import okhttp3.RequestBody;
/**
* Various utility methods for interacting with the Modrinth API.
*/
public class ModrinthApi {
private static final Logger LOG = LogManager.getLogger(ModrinthApi.class);
public static ModrinthSearchResult searchModrinth(List<String> gameVersions, String query, int page, String index,
List<String> categories, ModrinthProjectType projectType) {
try {
@ -84,7 +78,7 @@ public class ModrinthApi {
return Download.build().cached(new CacheControl.Builder().maxStale(10, TimeUnit.MINUTES).build())
.setUrl(url).asClass(ModrinthSearchResult.class);
} catch (UnsupportedEncodingException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return null;
@ -201,7 +195,7 @@ public class ModrinthApi {
} catch (DownloadException e) {
// 404 is fine from this endpoint, so anything else, log it
if (e.statusCode != 404) {
LogManager.logStackTrace(e);
LOG.error(e);
}
return null;
@ -260,7 +254,7 @@ public class ModrinthApi {
return projects.stream().distinct().collect(Collectors.toMap(p -> p.id, p -> p));
}
} catch (Throwable t) {
LogManager.logStackTrace("Error trying to get Modrinth projects as map", t);
LOG.error("Error trying to get Modrinth projects as map", t);
}
return null;

View file

@ -50,11 +50,13 @@ import com.atlauncher.App;
import com.atlauncher.FileSystem;
import com.atlauncher.Update;
import com.atlauncher.constants.Constants;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.PerformanceManager;
import com.atlauncher.network.Analytics;
import com.atlauncher.utils.javafinder.JavaInfo;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
import oshi.SystemInfo;
import oshi.hardware.GlobalMemory;
import oshi.hardware.HardwareAbstractionLayer;
@ -65,6 +67,8 @@ import oshi.software.os.OperatingSystem.ProcessSorting;
public enum OS {
LINUX, WINDOWS, OSX;
private static final Logger LOG = LogManager.getLogger(OS.class);
private static int memory = 0;
private static SystemInfo systemInfo = null;
private static List<OSProcess> antivirusProcesses = null;
@ -148,7 +152,7 @@ public enum OS {
try {
OS.openWebBrowser(new URI(url));
} catch (Exception e) {
LogManager.logStackTrace("Error opening web browser!", e);
LOG.error("Error opening web browser!", e);
}
}
@ -159,7 +163,7 @@ public enum OS {
try {
OS.openWebBrowser(url.toURI());
} catch (URISyntaxException e) {
LogManager.logStackTrace("Error opening web browser!", e);
LOG.error("Error opening web browser!", e);
}
}
@ -174,10 +178,10 @@ public enum OS {
} else if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
Desktop.getDesktop().browse(uri);
} else {
LogManager.error("Cannot open web browser as no supported methods were found");
LOG.error("Cannot open web browser as no supported methods were found");
}
} catch (Exception e) {
LogManager.logStackTrace("Error opening web browser!", e);
LOG.error("Error opening web browser!", e);
}
}
@ -191,6 +195,7 @@ public enum OS {
public static void openFileExplorer(Path path, boolean toFile) {
try {
if ((toFile || !Files.isDirectory(path)) && OS.isWindows()) {
LOG.info("/select,{}", path.toAbsolutePath());
Runtime.getRuntime().exec("explorer /select," + path.toAbsolutePath());
} else {
Path pathToOpen = path;
@ -205,11 +210,11 @@ public enum OS {
|| Files.exists(Paths.get("/usr/local/bin/xdg-open")))) {
Runtime.getRuntime().exec("xdg-open " + pathToOpen.toString());
} else {
LogManager.error("Cannot open file explorer as no supported methods were found");
LOG.error("Cannot open file explorer as no supported methods were found");
}
}
} catch (Exception e) {
LogManager.logStackTrace("Error opening file explorer!", e);
LOG.error("Error opening file explorer!", e);
}
}
@ -359,7 +364,7 @@ public enum OS {
}
} catch (SecurityException | InvocationTargetException | IllegalAccessException | IllegalArgumentException
| NoSuchMethodException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
PerformanceManager.end();
return ram;
@ -380,7 +385,7 @@ public enum OS {
ram = (int) (globalMemory.getTotal() / 1048576);
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error("error", t);
}
PerformanceManager.end();
@ -497,7 +502,7 @@ public enum OS {
path = thisFile.getCanonicalPath();
path = URLDecoder.decode(path, "UTF-8");
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
List<String> arguments = new ArrayList<>();

View file

@ -24,9 +24,13 @@ import java.util.HashMap;
import java.util.Map;
import com.atlauncher.exceptions.ChunkyException;
import com.atlauncher.managers.LogManager;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
public final class Resources {
private static final Logger LOG = LogManager.getLogger(Resources.class);
private static final Map<String, Object> resources = new HashMap<>();
public static final String[] FONT_FAMILIES = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames();
@ -62,7 +66,7 @@ public final class Resources {
} else {
URL url = Resources.class.getResource("/assets/font/" + name + ".ttf");
if (url == null) {
LogManager.error("Cannot find font " + name);
LOG.error("Cannot find font {}", name);
return new Font("Sans-Serif", Font.PLAIN, 0);
} else {
Font f = Font.createFont(Font.TRUETYPE_FONT, url.openStream());
@ -72,7 +76,7 @@ public final class Resources {
}
}
} catch (Exception ex) {
LogManager.logStackTrace("Cannot find font " + name, ex);
LOG.error("Cannot find font " + name, ex);
return new Font("Sans-Serif", Font.PLAIN, 0);
}
}

View file

@ -17,6 +17,10 @@
*/
package com.atlauncher.utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.image.BufferedImage;
@ -26,9 +30,9 @@ import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import com.atlauncher.managers.LogManager;
public class SkinUtils {
private static final Logger LOG = LogManager.getLogger(SkinUtils.class);
public static ImageIcon getDefaultHead() {
return getHead(Utils.getImage("/assets/image/skins/default.png"));
}
@ -52,7 +56,7 @@ public class SkinUtils {
try {
image = ImageIO.read(file);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
if (image == null) {
@ -62,7 +66,7 @@ public class SkinUtils {
try {
image = ImageIO.read(file);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return getHead(image);
@ -126,7 +130,7 @@ public class SkinUtils {
try {
image = ImageIO.read(file);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
if (image == null) {
@ -136,7 +140,7 @@ public class SkinUtils {
try {
image = ImageIO.read(file);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return getSkin(image);

View file

@ -17,29 +17,67 @@
*/
package com.atlauncher.utils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.Nullable;
import java.io.OutputStream;
import java.io.PrintStream;
import com.atlauncher.evnt.LogEvent.LogType;
import com.atlauncher.managers.LogManager;
public class SystemOutInterceptor extends PrintStream{
private final Logger logger;
public class SystemOutInterceptor extends PrintStream {
private final LogType logType;
public SystemOutInterceptor(OutputStream out, LogType type) {
super(out, true);
logType = type;
private SystemOutInterceptor(final String name, final OutputStream os){
super(os, true);
this.logger = LogManager.getLogger(name);
}
@Override
public void print(String s) {
super.print(s);
protected Logger getLogger(){
return this.logger;
}
if (logType == LogType.ERROR) {
LogManager.error(s);
} else {
LogManager.debug(s);
public static SystemOutInterceptor asDebug(final OutputStream os){
return new DebugOutInterceptor(os);
}
public static SystemOutInterceptor asInfo(final OutputStream os){
return new InfoOutInterceptor(os);
}
public static SystemOutInterceptor asError(final OutputStream os){
return new ErrorOutInterceptor(os);
}
private static final class DebugOutInterceptor extends SystemOutInterceptor{
DebugOutInterceptor(final OutputStream os){
super("debug-osi", os);
}
@Override
public void print(@Nullable String val){
this.getLogger().debug(val);
}
}
private static final class InfoOutInterceptor extends SystemOutInterceptor{
InfoOutInterceptor(final OutputStream os){
super("default-osi", os);
}
@Override
public void print(@Nullable String val){
this.getLogger().info(val);
}
}
private static final class ErrorOutInterceptor extends SystemOutInterceptor{
ErrorOutInterceptor(final OutputStream os){
super("error-osi", os);
}
@Override
public void print(@Nullable String val){
this.getLogger().error(val);
}
}
}

View file

@ -88,16 +88,22 @@ import com.atlauncher.data.minecraft.ExtractRule;
import com.atlauncher.data.minecraft.FabricMod;
import com.atlauncher.data.minecraft.MCMod;
import com.atlauncher.data.openmods.OpenEyeReportResponse;
import com.atlauncher.managers.LogManager;
import com.google.gson.reflect.TypeToken;
import org.apache.commons.io.IOUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
import org.tukaani.xz.LZMAInputStream;
import org.tukaani.xz.XZInputStream;
import net.iharder.Base64;
public class Utils {
private static final Logger LOG = LogManager.getLogger(Utils.class);
public static EnumSet<StandardOpenOption> WRITE = EnumSet.of(StandardOpenOption.CREATE_NEW,
StandardOpenOption.WRITE);
public static EnumSet<StandardOpenOption> READ = EnumSet.of(StandardOpenOption.READ);
@ -134,7 +140,7 @@ public class Utils {
URL url = App.class.getResource(path);
if (url == null) {
LogManager.error("Unable to load resource " + path);
LOG.error("Unable to load resource {}", path);
return null;
}
@ -161,7 +167,7 @@ public class Utils {
*/
public static ImageIcon getIconImage(File file) {
if (!file.exists()) {
LogManager.error("Unable to load file " + file.getAbsolutePath());
LOG.error("Unable to load file {}", file.getAbsolutePath());
return null;
}
@ -189,7 +195,7 @@ public class Utils {
try {
return ImageIO.read(stream);
} catch (IOException e) {
LogManager.logStackTrace("Failed to read image", e);
LOG.error("Failed to read image", e);
return null;
}
}
@ -228,7 +234,7 @@ public class Utils {
writer.close();
reader.close();
} catch (IOException e1) {
LogManager.logStackTrace(e1);
LOG.error("error", e1);
}
return result;
}
@ -246,7 +252,7 @@ public class Utils {
delete(from);
return true;
} else {
LogManager.error("Couldn't move file " + from.getAbsolutePath() + " to " + to.getAbsolutePath());
LOG.error("Couldn't move file {} to {}", from.getAbsolutePath(), to.getAbsolutePath());
return false;
}
}
@ -276,13 +282,11 @@ public class Utils {
boolean isURI = false;
if (!from.toString().startsWith("file:")) {
if (!from.isFile()) {
LogManager
.error("File " + from.getAbsolutePath() + " cannot be copied to " + to.getAbsolutePath() + " as"
LOG.error("File " + from.getAbsolutePath() + " cannot be copied to " + to.getAbsolutePath() + " as"
+ " it isn't a file");
}
if (!from.exists()) {
LogManager
.error("File " + from.getAbsolutePath() + " cannot be copied to " + to.getAbsolutePath() + " as"
LOG.error("File " + from.getAbsolutePath() + " cannot be copied to " + to.getAbsolutePath() + " as"
+ " it doesn't exist");
return false;
}
@ -300,7 +304,7 @@ public class Utils {
try {
to.createNewFile();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return false;
}
@ -310,8 +314,7 @@ public class Utils {
InputStream sourceStream = null;
OutputStream destinationStream = null;
LogManager.debug("Copying file from " + from.getAbsolutePath() + " to " + to.getAbsolutePath());
LOG.debug("Copying file from {} to {}", from.getAbsolutePath(), to.getAbsolutePath());
try {
if (!isURI) {
source = new FileInputStream(from).getChannel();
@ -323,7 +326,7 @@ public class Utils {
IOUtils.copy(sourceStream, destinationStream);
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error",e);
return false;
} finally {
try {
@ -341,7 +344,7 @@ public class Utils {
destinationStream.close();
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return false;
}
}
@ -377,8 +380,9 @@ public class Utils {
delete(sourceLocation);
return true;
} else {
LogManager.error("Couldn't move directory " + sourceLocation.getAbsolutePath() + " to "
+ targetLocation.getAbsolutePath());
LOG.error("Couldn't move directory {} to {}",
sourceLocation.getAbsolutePath(),
targetLocation.getAbsolutePath());
return false;
}
}
@ -430,7 +434,7 @@ public class Utils {
out.close();
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return false;
}
return true;
@ -492,7 +496,7 @@ public class Utils {
}
zipFile.close();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -515,8 +519,9 @@ public class Utils {
}
if (!file.delete()) {
LogManager.error(
(file.isFile() ? "File" : "Folder") + " " + file.getAbsolutePath() + " couldn't be " + "deleted");
LOG.error("({}) {} couldn't be deleted",
(file.isFile() ? "File" : "Folder"),
file.getAbsolutePath());
}
}
@ -535,7 +540,7 @@ public class Utils {
try {
canonDir = file.getParentFile().getCanonicalFile();
} catch (IOException e) {
LogManager.logStackTrace("Failed to get canonical file", e);
LOG.error("Failed to get canonical file", e);
return false;
}
@ -545,7 +550,7 @@ public class Utils {
try {
return !canon.getCanonicalFile().equals(canon.getAbsoluteFile());
} catch (IOException e) {
LogManager.logStackTrace("Failed to get canonical file", e);
LOG.error("Failed to get canonical file", e);
return false;
}
}
@ -628,7 +633,7 @@ public class Utils {
}
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -679,7 +684,7 @@ public class Utils {
byte[] encVal = c.doFinal(Data.getBytes());
encryptedValue = Base64.encodeBytes(encVal);
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return encryptedValue;
}
@ -703,7 +708,7 @@ public class Utils {
} catch (InvalidKeyException | IllegalBlockSizeException | BadPaddingException e) {
return Utils.decryptOld(encryptedData);
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return decryptedValue;
}
@ -924,13 +929,13 @@ public class Utils {
}
return found;
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
} finally {
if (input != null) {
try {
input.close();
} catch (IOException e) {
LogManager.logStackTrace("Unable to close input stream", e);
LOG.error("Unable to close input stream", e);
}
}
}
@ -997,7 +1002,7 @@ public class Utils {
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return false;
}
@ -1040,7 +1045,7 @@ public class Utils {
jos.closeEntry();
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return false;
}
@ -1099,8 +1104,7 @@ public class Utils {
StringBuilder response;
String request = Utils.getFileContents(report);
if (request == null) {
LogManager.error("OpenEye: Couldn't read contents of file '" + report.getAbsolutePath() + "'. Pending "
+ "report sending failed!");
LOG.error("OpenEye: Couldn't read contents of file '{}'. Pending report sending failed!", report.getAbsolutePath());
return null;
}
@ -1124,7 +1128,7 @@ public class Utils {
writer.flush();
writer.close();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return null; // Report not sent
}
@ -1140,7 +1144,7 @@ public class Utils {
response.append('\r');
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
return null; // Report sent, but no response
} finally {
try {
@ -1148,7 +1152,7 @@ public class Utils {
reader.close();
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -1165,7 +1169,7 @@ public class Utils {
*/
public static String getFileContents(File file) {
if (!file.exists()) {
LogManager.error("File '" + file.getAbsolutePath() + "' doesn't exist so cannot read contents of file!");
LOG.error("File '{}' doesn't exist so cannot read contents of file!", file.getAbsolutePath());
return null;
}
String contents = null;
@ -1182,14 +1186,14 @@ public class Utils {
}
contents = sb.toString();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
} finally {
try {
if (br != null) {
br.close();
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
return contents;
@ -1234,10 +1238,10 @@ public class Utils {
connection.setRequestProperty("Expires", "0");
connection.setRequestProperty("Pragma", "no-cache");
connection.connect();
LogManager.info("Proxy returned code " + connection.getResponseCode() + " when testing!");
LOG.info("Proxy returned code {} when testing!", connection.getResponseCode());
return connection.getResponseCode() == 200;
} catch (IOException e) {
LogManager.logStackTrace("Proxy couldn't establish a connection when testing!", e);
LOG.error("Proxy couldn't establish a connection when testing!", e);
return false;
}
}
@ -1308,7 +1312,7 @@ public class Utils {
pingStats = response.toString();
} catch (IOException e) {
LogManager.logStackTrace("IOException while running ping on host " + host, e);
LOG.error("IOException while running ping on host " + host, e);
}
return pingStats;
@ -1340,7 +1344,7 @@ public class Utils {
route = response.toString();
} catch (IOException e) {
LogManager.logStackTrace("IOException while running traceRoute on host " + host, e);
LOG.error("IOException while running traceRoute on host " + host, e);
}
return route;
@ -1439,13 +1443,13 @@ public class Utils {
bytes = new byte[(int) f.length()];
f.read(bytes);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
} finally {
if (f != null) {
try {
f.close();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
}
@ -1474,7 +1478,7 @@ public class Utils {
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
} finally {
try {
if (fis != null) {
@ -1490,7 +1494,7 @@ public class Utils {
lis.close();
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
}
@ -1559,7 +1563,7 @@ public class Utils {
}
}
} catch (Exception e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
} finally {
returnStr = (returnStr == null ? "NotARandomKeyYes" : returnStr);
}
@ -1680,7 +1684,7 @@ public class Utils {
return sb.toString().trim();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return "";
@ -1688,7 +1692,7 @@ public class Utils {
public static String runProcess(Path workingDir, String... command) {
try {
LogManager.debug(String.format("Running %s in %s", String.join(" ", command), workingDir.toString()));
LOG.debug(String.format("Running %s in %s", String.join(" ", command), workingDir.toString()));
ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(workingDir.toFile());
processBuilder.redirectErrorStream(true);
@ -1709,7 +1713,7 @@ public class Utils {
return sb.toString().trim();
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return "";

View file

@ -53,7 +53,8 @@ public class BackgroundImageWorker extends SwingWorker<ImageIcon, Object> {
if (!Files.exists(path)) {
try {
download.downloadFile();
} catch (DownloadException ignored) {
} catch (DownloadException ignored){
//fallthrough
}
}

View file

@ -117,7 +117,6 @@ import com.atlauncher.gui.dialogs.BrowserDownloadDialog;
import com.atlauncher.interfaces.NetworkProgressable;
import com.atlauncher.managers.DialogManager;
import com.atlauncher.managers.InstanceManager;
import com.atlauncher.managers.LogManager;
import com.atlauncher.managers.MinecraftManager;
import com.atlauncher.managers.ServerManager;
import com.atlauncher.network.Analytics;
@ -137,10 +136,16 @@ import com.atlauncher.utils.Utils;
import com.atlauncher.utils.walker.CaseFileVisitor;
import com.google.gson.reflect.TypeToken;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import okhttp3.CacheControl;
import okhttp3.OkHttpClient;
import org.slf4j.LoggerFactory;
public class InstanceInstaller extends SwingWorker<Boolean, Void> implements NetworkProgressable{
private static final Logger LOG = LogManager.getLogger(InstanceInstaller.class);
public class InstanceInstaller extends SwingWorker<Boolean, Void> implements NetworkProgressable {
protected double percent = 0.0; // Percent done installing
protected double subPercent = 0.0; // Percent done sub installing
protected double totalBytes = 0; // Total number of bytes to download
@ -248,10 +253,10 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
@Override
protected Boolean doInBackground() throws Exception {
ErrorReporting.recordPackInstall(this.pack.name, this.version.version, this.loaderVersion);
LogManager.info("Started install of " + this.pack.name + " version " + this.version.version);
LOG.info("Started install of {} version {}", this.pack.name, this.version.version);
if (this.loaderVersion != null) {
LogManager.info("Using loader version " + this.loaderVersion.version);
LOG.info("Using loader version " + this.loaderVersion.version);
}
try {
@ -379,7 +384,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
} catch (Exception e) {
success(false);
cancel(true);
LogManager.logStackTrace(e);
LOG.error("error", e);
}
return success(false);
@ -428,7 +433,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
}
if (curseForgeManifest.manifestVersion != 1) {
LogManager.warn("Manifest is version " + curseForgeManifest.manifestVersion + " which may be an issue!");
LOG.warn("Manifest is version {} which may be an issue!", this.curseForgeManifest.manifestVersion);
}
this.packVersion = new Version();
@ -560,7 +565,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
.getFileForProject(file.projectID, file.fileID));
if (curseForgeFile.downloadUrl == null) {
LogManager.debug(String.format(
LOG.debug(String.format(
"File %s (%d) for mod %s (%d) has no downloadUrl and allowModDistribution set to %s",
curseForgeFile.displayName, curseForgeFile.id, curseForgeProject.name, curseForgeProject.id,
curseForgeProject.allowModDistribution, curseForgeProject.allowModDistribution == null ? "null"
@ -578,7 +583,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
modToAdd.modrinthProject = modrinthProjects.get(modrinthVersion.projectId);
modToAdd.modrinthVersion = modrinthVersion;
LogManager.debug("Found matching mod from Modrinth called " + modToAdd.modrinthProject.title);
LOG.debug("Found matching mod from Modrinth called " + modToAdd.modrinthProject.title);
return modToAdd;
}
@ -862,8 +867,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
}
if (modsManifest == null) {
LogManager
.error(String.format("Mod %s is not available to be downloaded for this pack", f.name));
LOG.error(String.format("Mod %s is not available to be downloaded for this pack", f.name));
return true;
}
@ -874,8 +878,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
.findFirst();
if (!modInfo.isPresent()) {
LogManager
.error(String.format("Mod %s is not available to be downloaded for this pack", f.name));
LOG.error(String.format("Mod %s is not available to be downloaded for this pack", f.name));
return true;
}
@ -998,7 +1001,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
.getFileForProject(curseProjectId, curseFileId));
if (curseForgeFile.downloadUrl == null) {
LogManager.debug(String.format(
LOG.debug(String.format(
"File %s (%d) for mod %s (%d) has no downloadUrl and allowModDistribution set to %s",
curseForgeFile.displayName, curseForgeFile.id, curseForgeProject.name,
curseForgeProject.id,
@ -1018,7 +1021,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
modToAdd.modrinthProject = modrinthProjects.get(modrinthVersion.projectId);
modToAdd.modrinthVersion = modrinthVersion;
LogManager.debug(
LOG.debug(
"Found matching mod from Modrinth called " + modToAdd.modrinthProject.title);
return modToAdd;
@ -1144,7 +1147,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
try (FileReader fileReader = new FileReader(versionJsonPath.toFile())) {
versionJson = Gsons.MINECRAFT.fromJson(fileReader, MinecraftVersion.class);
} catch (Exception e) {
LogManager.error("Error reading in version.json");
LOG.error("Error reading in version.json");
throw e;
}
@ -1156,7 +1159,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
versionJson = Gsons.MINECRAFT.fromJson(ArchiveUtils.getFile(modpackJarPath, "version.json"),
MinecraftVersion.class);
} catch (Exception e) {
LogManager.error("Error reading in version.json from modpack.jar");
LOG.error("Error reading in version.json from modpack.jar");
throw e;
}
@ -1227,7 +1230,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
}
if (modrinthManifest.formatVersion != 1) {
LogManager.warn("Manifest is version " + modrinthManifest.formatVersion + " which may be an issue!");
LOG.warn("Manifest is version " + modrinthManifest.formatVersion + " which may be an issue!");
}
this.packVersion = new Version();
@ -1436,7 +1439,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
this.minecraftVersion = download.asClass(MinecraftVersion.class);
if (this.minecraftVersion == null) {
LogManager.error("Failed to download Minecraft json.");
LOG.error("Failed to download Minecraft json.");
this.cancel(true);
return;
}
@ -1545,7 +1548,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
|| p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.mods)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -1557,7 +1560,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
|| p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.dependency)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -1568,7 +1571,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
|| p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.ic2lib)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
}
@ -1583,7 +1586,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
|| p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.mods)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -1598,7 +1601,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
|| p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.dependency)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
}
@ -1611,7 +1614,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
|| p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.mods)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -1623,7 +1626,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
|| p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.dependency)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -1634,7 +1637,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
|| p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.ic2lib)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
}
@ -1895,8 +1898,8 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
String output = Utils.runProcess(root, Java.getPathToJavaExecutable(javaPath),
"-jar", getMinecraftJar().getAbsolutePath(), "--initSettings");
LogManager.debug("initServerSettings output");
LogManager.debug(output);
LOG.debug("initServerSettings output");
LOG.debug(output);
} catch (Throwable ignored) {
}
}).start();
@ -2422,8 +2425,8 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
// + ".sha1"), runtimeToDownload.version.name.getBytes(StandardCharsets.UTF_8));
hideSubProgressBar();
} catch (IOException e) {
LogManager.logStackTrace("Failed to download Java runtime", e);
} catch (IOException e){
LOG.error("Failed to download Java runtime", e);
}
}
}
@ -2500,7 +2503,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
for (Mod mod : browserDownloadMods) {
if (!browserDownloadDialog.modsDownloaded.stream()
.anyMatch(m -> m.curseForgeFileId == mod.curseForgeFileId)) {
LogManager.info("Browser download mod " + mod.name + " was skipped");
LOG.info("Browser download mod " + mod.name + " was skipped");
Optional<DisableableMod> disableableMod = this.modsInstalled.stream()
.filter(m -> m.curseForgeFileId == mod.curseForgeFileId).findFirst();
if (disableableMod.isPresent()) {
@ -2520,7 +2523,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
fireTask(GetText.tr("Downloading Browser Mods"));
if (!mod.download(this)) {
LogManager.info("Browser download mod " + mod.name + " was skipped");
LOG.info("Browser download mod " + mod.name + " was skipped");
Optional<DisableableMod> disableableMod = this.modsInstalled.stream()
.filter(m -> m.file == mod.file).findFirst();
if (disableableMod.isPresent()) {
@ -2601,7 +2604,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
p -> p.toString().toLowerCase().endsWith(".jar") || p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.mods)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -2611,7 +2614,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
p -> p.toString().toLowerCase().endsWith(".jar") || p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.dependency)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -2621,7 +2624,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
p -> p.toString().toLowerCase().endsWith(".jar") || p.toString().toLowerCase().endsWith(".zip"))
.map(p -> convertPathToDisableableMod(p, Type.ic2lib)).collect(Collectors.toList()));
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
@ -2647,8 +2650,8 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
if (download.needToDownload()) {
try {
download.downloadFile();
} catch (IOException e) {
LogManager.logStackTrace("Failed to download Legacy Java Fixer", e);
} catch (IOException e){
LOG.error("Failed to download Legacy Java Fixer", e);
}
} else {
download.copy();
@ -2746,7 +2749,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
try {
Files.createDirectories(path);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
});
@ -2871,7 +2874,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
long hash = Hashing.murmur(dm.getFile(root, this.packVersion.minecraft).toPath());
murmurHashes.put(hash, dm);
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error("error", t);
}
});
@ -2903,8 +2906,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
dm.description = curseForgeProject.summary;
}
LogManager.debug("Found matching mod from CurseForge called "
+ dm.curseForgeFile.displayName);
LOG.debug("Found matching mod from CurseForge called {}", dm.curseForgeFile.displayName);
});
}
}
@ -2928,7 +2930,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
sha1Hashes.put(Hashing.sha1(dm.getFile(root, this.packVersion.minecraft).toPath()).toString(),
dm);
} catch (Throwable t) {
LogManager.logStackTrace(t);
LOG.error(t);
}
});
@ -2958,8 +2960,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
dm.name = project.title;
dm.description = project.description;
LogManager
.debug(String.format("Found matching mod from Modrinth called %s with file %s",
LOG.debug(String.format("Found matching mod from Modrinth called %s with file %s",
project.title, version.name));
}
}
@ -3168,7 +3169,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
try {
Files.delete(path);
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
}
});
@ -3184,7 +3185,7 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
Files.delete(path);
}
} catch (IOException e) {
LogManager.logStackTrace(e);
LOG.error("error", e);
}
});
}
@ -3484,14 +3485,14 @@ public class InstanceInstaller extends SwingWorker<Boolean, Void> implements Net
shareCodeData = response.getData();
}
} catch (IOException e) {
LogManager.logStackTrace("API call failed", e);
LOG.error("API call failed", e);
}
return shareCodeData;
}
public void fireTask(String name) {
LogManager.debug("Instance Installer: " + name);
LOG.debug("Instance Installer: {}", name);
firePropertyChange("doing", null, name);
}

View file

@ -1,64 +0,0 @@
/*
* ATLauncher - https://github.com/ATLauncher/ATLauncher
* Copyright (C) 2013-2022 ATLauncher
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.atlauncher.writer;
import java.io.Closeable;
import java.io.Flushable;
import java.io.IOException;
import java.io.Writer;
import com.atlauncher.evnt.LogEvent;
import com.atlauncher.exceptions.ChunkyException;
public final class LogEventWriter implements Closeable, Flushable {
private final Writer writer;
public LogEventWriter(Writer writer) {
if (writer == null) {
throw new ChunkyException("Writer == null");
}
this.writer = writer;
}
public void write(LogEvent event) throws IOException {
if (event == null) {
throw new ChunkyException("Event == null");
} else {
this.writer.write(event.toString());
}
}
public void write(String comment) throws IOException {
if (comment == null) {
throw new ChunkyException("Comment == null");
} else {
this.writer.write((!comment.startsWith("#") ? "#" + comment : comment));
}
}
@Override
public void flush() throws IOException {
this.writer.flush();
}
@Override
public void close() throws IOException {
this.writer.close();
}
}

View file

@ -11,14 +11,18 @@ import javax.swing.ImageIcon;
import javax.swing.UIManager;
import com.atlauncher.App;
import com.atlauncher.managers.LogManager;
import io.github.asyncronous.toast.ui.ToastWindow;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Static class to allow easier use of toaster notifications
*/
public final class Toaster {
private static final Logger LOG = LogManager.getLogger(Toaster.class);
private static Toaster instance;
public static Toaster instance() {
@ -131,7 +135,7 @@ public final class Toaster {
try {
return ImageIO.read(stream);
} catch (IOException ex) {
LogManager.logStackTrace("Failed to load Toaster image", ex);
LOG.error("Failed to load Toaster image", ex);
return null;
}
}

Some files were not shown because too many files have changed in this diff Show more