use of net.technicpack.launchercore.logging.BuildLogFormatter in project LauncherV3 by TechnicPack.
the class LauncherMain method setupLogging.
private static void setupLogging(LauncherDirectories directories, ResourceLoader resources, IBuildNumber buildNumber) {
System.out.println("Setting up logging");
final Logger logger = Utils.getLogger();
File logDirectory = new File(directories.getLauncherDirectory(), "logs");
if (!logDirectory.exists()) {
logDirectory.mkdir();
}
File logs = new File(logDirectory, "techniclauncher_%D.log");
RotatingFileHandler fileHandler = new RotatingFileHandler(logs.getPath());
fileHandler.setFormatter(new BuildLogFormatter(buildNumber.getBuildNumber()));
for (Handler h : logger.getHandlers()) {
logger.removeHandler(h);
}
logger.addHandler(fileHandler);
logger.setUseParentHandlers(false);
LauncherMain.consoleFrame = new ConsoleFrame(2500, resources.getImage("icon.png"));
Console console = new Console(LauncherMain.consoleFrame, buildNumber.getBuildNumber());
logger.addHandler(new ConsoleHandler(console));
System.setOut(new PrintStream(new LoggerOutputStream(console, Level.INFO, logger), true));
System.setErr(new PrintStream(new LoggerOutputStream(console, Level.SEVERE, logger), true));
Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
e.printStackTrace();
logger.log(Level.SEVERE, "Unhandled Exception in " + t, e);
// if (errorDialog == null) {
// LauncherFrame frame = null;
//
// try {
// frame = Launcher.getFrame();
// } catch (Exception ex) {
// //This can happen if we have a very early crash- before Launcher initializes
// }
//
// errorDialog = new ErrorDialog(frame, e);
// errorDialog.setVisible(true);
// }
}
});
}
use of net.technicpack.launchercore.logging.BuildLogFormatter in project LauncherV3 by TechnicPack.
the class LauncherMain method setupLogging.
private static void setupLogging(LauncherDirectories directories, ResourceLoader resources) {
System.out.println("Setting up logging");
final Logger logger = Utils.getLogger();
File logDirectory = new File(directories.getLauncherDirectory(), "logs");
if (!logDirectory.exists()) {
logDirectory.mkdir();
}
File logs = new File(logDirectory, "techniclauncher_%D.log");
RotatingFileHandler fileHandler = new RotatingFileHandler(logs.getPath());
fileHandler.setFormatter(new BuildLogFormatter(buildNumber.getBuildNumber()));
for (Handler h : logger.getHandlers()) {
logger.removeHandler(h);
}
logger.addHandler(fileHandler);
logger.setUseParentHandlers(false);
LauncherMain.consoleFrame = new ConsoleFrame(2500, resources.getImage("icon.png"));
Console console = new Console(LauncherMain.consoleFrame, buildNumber.getBuildNumber());
logger.addHandler(new ConsoleHandler(console));
System.setOut(new PrintStream(new LoggerOutputStream(console, Level.INFO, logger), true));
System.setErr(new PrintStream(new LoggerOutputStream(console, Level.SEVERE, logger), true));
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
e.printStackTrace();
logger.log(Level.SEVERE, "Unhandled Exception in " + t, e);
});
}
Aggregations