public ConsoleManager(GlowServer server) { this.server = server; // install Ansi code handler, which makes colors work on Windows AnsiConsole.systemInstall(); for (Handler h : logger.getHandlers()) { logger.removeHandler(h); } // used until/unless gui is created consoleHandler = new FancyConsoleHandler(); // consoleHandler.setFormatter(new DateOutputFormatter(CONSOLE_DATE)); logger.addHandler(consoleHandler); // todo: why is this here? Runtime.getRuntime().addShutdownHook(new ServerShutdownThread()); // reader must be initialized before standard streams are changed try { reader = new ConsoleReader(); } catch (IOException ex) { logger.log(Level.SEVERE, "Exception initializing console reader", ex); } reader.addCompleter(new CommandCompleter()); // set system output streams System.setOut(new PrintStream(new LoggerOutputStream(Level.INFO), true)); System.setErr(new PrintStream(new LoggerOutputStream(Level.WARNING), true)); }
public void stop() { running = false; for (Handler handler : logger.getHandlers()) { handler.flush(); handler.close(); } if (jFrame != null) { jFrame.dispose(); } }