private static synchronized void runTasks() { Log.debug("Running all shutdown-hook tasks"); // Iterate through copy of tasks list for (Task task : tasks.toArray(new Task[tasks.size()])) { Log.debug("Running task: ", task); try { task.run(); } catch (Throwable e) { Log.warn("Task failed", e); } } tasks.clear(); }
public void enableInterruptCharacter() { try { if (intr != null) { settings.set("intr", intr); } } catch (Exception e) { if (e instanceof InterruptedException) { Thread.currentThread().interrupt(); } Log.error("Failed to enable interrupt character", e); } }
/** * Create a console reader. * * @param systemIn The input stream * @return The console reader * @throws IOException if there is an error */ protected ConsoleReader createConsoleReader(InputStream systemIn) throws IOException { // need to swap out the output to avoid logging during init final PrintStream nullOutput = new PrintStream(new ByteArrayOutputStream()); final PrintStream originalOut = Log.getOutput(); try { Log.setOutput(nullOutput); ConsoleReader consoleReader = new ConsoleReader(systemIn, out); consoleReader.setExpandEvents(false); return consoleReader; } finally { Log.setOutput(originalOut); } }
/** * Whether or not to allow the use of the JNI console interaction. */ public void setDirectConsole(final boolean flag) { this.directConsole = flag; Log.debug("Direct console: ", flag); }
public static synchronized Terminal create(String ttyDevice) { if (Log.TRACE) { Log.trace(new Throwable("CREATE MARKER")); String type = Configuration.getString(JLINE_TERMINAL, defaultType); Log.debug("Creating terminal; type=", type); Log.error("Failed to construct terminal; falling back to unsupported", e); t = new UnsupportedTerminal(); Log.debug("Created Terminal: ", t); Log.error("Terminal initialization failed; falling back to unsupported", e); return new UnsupportedTerminal();
public void load(final File file) throws IOException { checkNotNull(file); if (file.exists()) { Log.trace("Loading history from: ", file); FileReader reader = null; try{ reader = new FileReader(file); load(reader); } finally{ if(reader != null){ reader.close(); } } } }
public OSvTerminal() { super(true); setAnsiSupported(true); try { if (stty == null) { sttyClass = Class.forName("com.cloudius.util.Stty"); stty = sttyClass.newInstance(); } } catch (Exception e) { Log.warn("Failed to load com.cloudius.util.Stty", e); } }
@SuppressWarnings("unused") @Substitute public static Terminal create(String ttyDevice) { Terminal t; try { t = new UnixTerminal(); t.init(); } catch (Exception e) { Log.error("Failed to construct terminal; falling back to UnsupportedTerminal", e); t = new UnsupportedTerminal(); } Log.debug("Created Terminal: ", t); return t; } }
/** * @since 2.7 */ public static void info(final Object... messages) { log(Level.INFO, messages); }
static void logWithJul(Level level, Object... messages) { Logger logger = Logger.getLogger("jline"); Throwable cause = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); for (int i = 0; i < messages.length; i++) { // Special handling for the last message if its a throwable, render its stack on the next line if (i + 1 == messages.length && messages[i] instanceof Throwable) { cause = (Throwable) messages[i]; } else { render(ps, messages[i]); } } ps.close(); LogRecord r = new LogRecord(toJulLevel(level), baos.toString()); r.setThrown(cause); logger.log(r); }
@TestAccessible static void log(final Level level, final Object... messages) { if (useJul) { logWithJul(level, messages); return; } //noinspection SynchronizeOnNonFinalField synchronized (output) { output.format("[%s] ", level); for (int i=0; i<messages.length; i++) { // Special handling for the last message if its a throwable, render its stack on the next line if (i + 1 == messages.length && messages[i] instanceof Throwable) { output.println(); ((Throwable)messages[i]).printStackTrace(output); } else { render(output, messages[i]); } } output.println(); output.flush(); } }
List<RegionInfo> regions = admin.getRegions(indexTable); Log.info("Merging: " + regions.size()); admin.mergeRegionsAsync(regions.get(0).getEncodedNameAsBytes(), regions.get(1).getEncodedNameAsBytes(), false); Log.info(ex); Log.info("Waiting:" + regions.size()); if (regions.size() < numRegions) { break;
/** * Constructs a <tt>Console</tt> with <tt>System.in</tt> and <tt>System.out</tt> as the I/O streams. */ public Console(InstallData installData, ConsolePrefs prefs) { this.installData = installData; Log.setOutput(new PrintStream(new OutputStream() { @Override public void write(int b) throws IOException { } })); if (prefs.enableConsoleReader) { initConsoleReader(); } if (consoleReader == null) { console = System.console(); } }
protected synchronized void setAnsiSupported(final boolean supported) { this.ansiSupported = supported; Log.debug("Ansi supported: ", supported); }
public static synchronized Terminal create(String ttyDevice) { if (Log.TRACE) { Log.trace(new Throwable("CREATE MARKER")); Log.debug("Creating terminal; type=", type); Log.error("Failed to construct terminal; falling back to unsupported", e); t = new UnsupportedTerminal(); Log.debug("Created Terminal: ", t); Log.error("Terminal initialization failed; falling back to unsupported", e); return new UnsupportedTerminal();
public void flush() throws IOException { Log.trace("Flushing history"); if (!file.exists()) { File dir = file.getParentFile(); if (!dir.exists() && !dir.mkdirs()) { Log.warn("Failed to create directory: ", dir); } if (!file.createNewFile()) { Log.warn("Failed to create file: ", file); } } PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(file))); try { for (Entry entry : this) { out.println(entry.value()); } } finally { out.close(); } }
private String exec(final String... cmd) throws IOException, InterruptedException { checkNotNull(cmd); Log.trace("Running: ", cmd); Process p = null; if (useRedirect) { try { p = inheritInput(new ProcessBuilder(cmd)).start(); } catch (Throwable t) { useRedirect = false; } } if (p == null) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < cmd.length; i++) { if (i > 0) { sb.append(' '); } sb.append(cmd[i]); } sb.append(" < "); sb.append(ttyDevice); p = new ProcessBuilder(shCommand, "-c", sb.toString()).start(); } String result = waitAndCapture(p); Log.trace("Result: ", result); return result; }
public OSvTerminal() { super(true); setAnsiSupported(true); try { if (stty == null) { sttyClass = Class.forName("com.cloudius.util.Stty"); stty = sttyClass.newInstance(); } } catch (Exception e) { Log.warn("Failed to load com.cloudius.util.Stty", e); } }