/** * Print a message in the console. * @param session the shell's session * @param msg the message to print out with a newline */ public static void printMessage(Session session, String msg) { PrintStream writer = session.getConsole(); writer.println(msg); } }
@Override public void execute(JobContext context) { try (Session s = sessionFactory.create(new ByteArrayInputStream(new byte[0]), session.getConsole(), session.getConsole(), session)) { script.execute(s, Collections.singletonList(context)); } catch (Exception e) { LOGGER.warn("Error executing script", e); } }
@Override public void execute(JobContext context) { try (Session s = sessionFactory.create(new ByteArrayInputStream(new byte[0]), session.getConsole(), session.getConsole(), session)) { script.execute(s, Collections.singletonList(context)); } catch (Exception e) { LOGGER.warn("Error executing script", e); } }
@Override public Object getListener() { return new TailRuleListener(session.getConsole()); }
@Override public Object getListener() { return new RuleWatchListener(session.getConsole()); }
@Override public Object getListener() { return new TailEventListener(session.getConsole()); }
public Object execute() throws Exception { // Do not use System.out as it may write to the wrong console depending on the thread that calls our log handler PrintStream out = session.getConsole(); out.flush(); outputHeaders(out); Object listener = getListener(); List<String> interfaces = new ArrayList<>(); for (Class<?> listenerInterface : listener.getClass().getInterfaces()) { interfaces.add(listenerInterface.getName()); } ServiceRegistration<?> tailServiceRegistration = bundleContext.registerService(interfaces.toArray(new String[interfaces.size()]), listener, new Hashtable<>()); try { synchronized (this) { wait(); } } catch (InterruptedException e) { // Ignore as it will happen if the user breaks the tail using Ctrl-C } finally { tailServiceRegistration.unregister(); } return null; }
@Override public Object execute() throws Exception { EventPrinter printer = new EventPrinter(session.getConsole(), verbose); collector.getEvents().filter(matchTopic(topicFilter)).forEach(printer); return null; }
if ("always".equals(pst)) { String str = applyStyle(getStackTrace(t), cm, "st"); session.getConsole().print(str); } else if ("CommandNotFoundException".equals(name)) { String str = applyStyle("Command not found: ", cm, "em") + applyStyle((String) t.getClass().getMethod("getCommand").invoke(t), cm, "ee"); session.getConsole().println(str); } else if ("CommandException".equals(name)) { String str; str = applyStyle(t.getMessage(), cm, "em"); session.getConsole().println(str); } else if ("execution".equals(pst)) { String str = applyStyle(getStackTrace(t), cm, "st"); session.getConsole().print(str); } else { String str = applyStyle("Error executing command: ", cm, "em") + applyStyle(t.getMessage() != null ? t.getMessage() : t.getClass().getName(), cm, "ee"); session.getConsole().println(str); session.getConsole().flush(); } catch (Exception ignore) {
@Override public Object execute() throws Exception { if (entries == 0) { entries = 50; } int minLevel = getMinLevel(level); // Do not use System.out as it may write to the wrong console depending on the thread that calls our log handler PrintStream out = session.getConsole(); display(out, minLevel); out.flush(); PaxAppender appender = event -> printEvent(out, event, minLevel); ServiceTracker<LogService, LogService> tracker = new LogServiceTracker(context, LogService.class, null, appender); tracker.open(); try { synchronized (this) { wait(); } out.println("Stopping tail as log.core bundle was stopped."); } catch (InterruptedException e) { // Ignore as it will happen if the user breaks the tail using Ctrl-C } finally { tracker.close(); } out.println(); return null; }
if ("always".equals(pst)) { String str = applyStyle(getStackTrace(t), cm, "st"); session.getConsole().print(str); } else if ("CommandNotFoundException".equals(name)) { String str = applyStyle("Command not found: ", cm, "em") + applyStyle((String) t.getClass().getMethod("getCommand").invoke(t), cm, "ee"); session.getConsole().println(str); } else if ("CommandException".equals(name)) { String str; str = applyStyle(t.getMessage(), cm, "em"); session.getConsole().println(str); } else if ("execution".equals(pst)) { String str = applyStyle(getStackTrace(t), cm, "st"); session.getConsole().print(str); } else { String str = applyStyle("Error executing command: ", cm, "em") + applyStyle(t.getMessage() != null ? t.getMessage() : t.getClass().getName(), cm, "ee"); session.getConsole().println(str); session.getConsole().flush(); } catch (Exception ignore) {
session.getConsole().println(result.toString());
@Override public Object execute() throws Exception { EventPrinter printer = new EventPrinter(session.getConsole(), verbose); Consumer<Event> filteredPrinter = executeIf(matchTopic(topicFilter), printer); collector.addConsumer(filteredPrinter); try { waitTillInterrupted(); } catch (InterruptedException e) { collector.removeConsumer(filteredPrinter); } return null; }
session.put("__log_tail", null); } else { PrintStream sConsole = session.getConsole(); if (sConsole == null || session.getTerminal() == null) return null; @SuppressWarnings("resource")