public void exec(CLIContext cli, String[] args) throws Exception { this.p = cli.getOutputStream(); this.cli = cli; this.ansi = cli.getConsoleReader().getTerminal().isANSISupported(); if (args.length == 1) { usage(cli); return; } for (int i = 1; i < args.length; i++) { try { Logger logger = (Logger) NameRegistrar.get("logger." + args[i]); logger.addListener(this); } catch (NameRegistrar.NotFoundException e) { cli.println("Logger " + args[i] + " not found -- ignored."); } } cli.getConsoleReader().readCharacter(new char[] {'q', 'Q'}); for (int i = 1; i < args.length; i++) { try { Logger logger = (Logger) NameRegistrar.get("logger." + args[i]); logger.removeListener(this); } catch (NameRegistrar.NotFoundException e) { } } }
private void showTMs(CLIContext cli) { NameRegistrar nr = NameRegistrar.getInstance(); int maxw = 0; Iterator iter = NameRegistrar.getMap().entrySet().iterator(); StringBuilder sb = new StringBuilder("available transaction managers:"); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); if (entry.getValue() instanceof TransactionManager) { sb.append(' '); sb.append(key); } } cli.println(sb.toString()); }
public void exec(CLIContext cli, String[] args) throws Exception { this.p = cli.getOutputStream(); this.cli = cli; this.ansi = cli.getConsoleReader().getTerminal().isANSISupported(); if (args.length == 1) { usage(cli); return; } for (int i = 1; i < args.length; i++) { try { Object obj = NameRegistrar.get(args[i]); if (obj instanceof TransactionManager) { ((TransactionManager) obj).addListener(this); } else { cli.println( "Object '" + args[i] + "' is not an instance of TransactionManager (" + obj.toString() + ")"); } } catch (NameRegistrar.NotFoundException e) { cli.println("TransactionManager '" + args[i] + "' not found -- ignored."); } } cli.getConsoleReader().readCharacter(new char[] {'q', 'Q'}); for (int i = 1; i < args.length; i++) { try { Object obj = NameRegistrar.get(args[i]); if (obj instanceof TransactionManager) { ((TransactionManager) obj).removeListener(this); } } catch (NameRegistrar.NotFoundException ignored) { } } }
private void showLoggers(CLIContext cli) { NameRegistrar nr = NameRegistrar.getInstance(); int maxw = 0; Iterator iter = NameRegistrar.getAsMap().entrySet().iterator(); StringBuilder sb = new StringBuilder("available loggers:"); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); String key = (String) entry.getKey(); if (key.startsWith("logger.") && entry.getValue() instanceof Logger) { sb.append(' '); sb.append(key.substring(7)); } } cli.println(sb.toString()); }
public synchronized LogEvent log(LogEvent ev) { if (p != null) { Date d = new Date(System.currentTimeMillis()); ANSIBuffer ab = new ANSIBuffer(); ab.setAnsiEnabled(ansi); cli.println( ab.bold( ev.getSource().getLogger().getName() + ": " + ev.getRealm() + " " + d.toString() + "." + d.getTime() % 1000) .toString(ansi)); ev.dump(p, " "); p.flush(); } return ev; }
public void exec(CLIContext ctx, String[] args) { ctx.println(new Date().toString()); }
public void update(TransactionStatusEvent e) { cli.println(e.toString()); }
public void usage(CLIContext cli) { cli.println("Usage: tmmon [tm-name] [tm-name] ..."); showTMs(cli); }
public void usage(CLIContext cli) { cli.println("Usage: tail [log-name] [log-name] ..."); showLoggers(cli); }