/** * Check if the verbosity level is set to {@link Verbosity#DEBUG}. * * <p>For general usage, when debug output is required, it is better * to use the logging facility instead. */ public boolean isDebug() { return getVerbosity() == Verbosity.DEBUG; }
binding.setProperty("jenkins", Jenkins.getActiveInstance()); IO io = new IO(new BufferedInputStream(stdin),stdout,stderr); Groovysh shell = new Groovysh(cl, binding, io, registrar); shell.getImports().add("hudson.model.*"); final Closure originalErrorHook = shell.getErrorHook(); shell.setErrorHook(new Closure(shell, shell) { private static final long serialVersionUID = 1L;
@Override protected int run() { // this allows the caller to manipulate the JVM state, so require the admin privilege. Jenkins.getActiveInstance().checkPermission(Jenkins.RUN_SCRIPTS); // this being remote means no jline capability is available System.setProperty("jline.terminal", UnsupportedTerminal.class.getName()); TerminalFactory.reset(); StringBuilder commandLine = new StringBuilder(); for (String arg : args) { if (commandLine.length() > 0) { commandLine.append(" "); } commandLine.append(arg); } Groovysh shell = createShell(stdin, stdout, stderr); return shell.run(commandLine.toString()); }
private void log(final String level, Object msg, Throwable cause) { assert level != null; assert msg != null; if (io == null) { synchronized (Logger.class) { if (io == null) { io = new IO(); } } } // Allow the msg to be a Throwable, and handle it properly if no cause is given if (cause == null) { if (msg instanceof Throwable) { cause = (Throwable) msg; msg = cause.getMessage(); } } Color color = GREEN; if (WARN.equals(level) || ERROR.equals(level)) { color = RED; } io.out.println(ansi().a(INTENSITY_BOLD).fg(color).a(level).reset().a(" [").a(name).a("] ").a(msg)); if (cause != null) { cause.printStackTrace(io.out); } io.flush(); }
public void execute( String script ) { groovy.execute( script ); } }
public void preferenceChange(final PreferenceChangeEvent event) { if (event.getKey().equals(VERBOSITY_KEY)) { String name = event.getNewValue(); if (name == null) { name = IO.Verbosity.INFO.name; } try { verbosity = IO.Verbosity.forName(name); } catch (Exception e) { event.getNode().put(event.getKey(), verbosity.name); } } } });
protected int execute(CommandLine cli) throws CompilationFailedException, IOException { if (cli.hasOption(SCRIPT_FLAG_SHORT)) { evalFiles(cli.getArgs(), cli); } else { String setupScript = "-e//Starting AtlasConsole...please wait.\n" + ":set verbosity QUIET\n" + ":set interpreterMode\n" + ":set show-last-result false\n" + getJavaCallbackString(cli.hasOption(MUTATIONS_ENABLED_FLAG_SHORT)); if(cli.hasOption(BIND_FLAG_SHORT)) { additionalBindingsToSetUp = cli.getOptionValues(BIND_FLAG_SHORT); Preconditions.checkArgument(additionalBindingsToSetUp.length % 2 == 0, "An odd amount of parameters were passed into --bind"); } if(cli.hasOption(EVAL_FLAG_SHORT)) { setupScript += "\n" + Joiner.on('\n').join(cli.getOptionValues(EVAL_FLAG_SHORT)); } setupScript += "\n//AtlasConsole started, type help() for more info!"; List<String> args = new ArrayList<String>(Arrays.asList(cli.getArgs())); args.add(setupScript); if(cli.hasOption(CLASSPATH_FLAG_SHORT)) { args.add("-cp"); args.add(cli.getOptionValue(CLASSPATH_FLAG_SHORT)); } String[] groovyArgs = args.toArray(new String[0]); Main.main(groovyArgs); } return 0; }
/** * Check if the verbosity level is set to {@link Verbosity#QUIET}. */ public boolean isQuiet() { return getVerbosity() == Verbosity.QUIET; }
@Override public Object eval(final String script) throws ScriptException { return this.shell.execute(script); }
/** * Check if the verbosity level is set to {@link Verbosity#INFO}. */ public boolean isInfo() { return getVerbosity() == Verbosity.INFO; }
/** * Check if the verbosity level is set to {@link Verbosity#VERBOSE}. */ public boolean isVerbose() { return getVerbosity() == Verbosity.VERBOSE; }
/** * Check if the verbosity level is set to {@link Verbosity#INFO}. */ public boolean isInfo() { return getVerbosity() == Verbosity.INFO; }
/** * Check if the verbosity level is set to {@link Verbosity#VERBOSE}. */ public boolean isVerbose() { return getVerbosity() == Verbosity.VERBOSE; }
/** * Check if the verbosity level is set to {@link Verbosity#QUIET}. */ public boolean isQuiet() { return getVerbosity() == Verbosity.QUIET; }
/** * Check if the verbosity level is set to {@link Verbosity#QUIET}. */ public boolean isQuiet() { return getVerbosity() == Verbosity.QUIET; }
/** * Check if the verbosity level is set to {@link Verbosity#INFO}. */ public boolean isInfo() { return getVerbosity() == Verbosity.INFO; }
/** * Check if the verbosity level is set to {@link Verbosity#QUIET}. */ public boolean isQuiet() { return getVerbosity() == Verbosity.QUIET; }
/** * Check if the verbosity level is set to {@link Verbosity#VERBOSE}. */ public boolean isVerbose() { return getVerbosity() == Verbosity.VERBOSE; }
/** * Check if the verbosity level is set to {@link Verbosity#INFO}. */ public boolean isInfo() { return getVerbosity() == Verbosity.INFO; }
/** * Check if the verbosity level is set to {@link Verbosity#VERBOSE}. */ public boolean isVerbose() { return getVerbosity() == Verbosity.VERBOSE; }