예제 #1
0
  private void logToChat(Level l, String message) {

    if (chatLevel.intValue() <= l.intValue()) {
      for (Player player : getServer().getOnlinePlayers()) {
        if (hasPermission(player, PermissionData.PERMISSION_NOTIFY, false)) {
          player.sendMessage("[" + l.getName() + "] " + message);
        }
      }
    }
  }
예제 #2
0
        public void assertDeserialized(Serializable initial, Serializable deserialized) {

          Level init = (Level) initial;
          Level dser = (Level) deserialized;

          assertEquals("Class", init.getClass(), dser.getClass());
          assertEquals("Name", init.getName(), dser.getName());
          assertEquals("Value", init.intValue(), dser.intValue());
          assertEquals(
              "ResourceBundleName", init.getResourceBundleName(), dser.getResourceBundleName());
        }
예제 #3
0
 public synchronized void setOutputStream(OutputStream out) {
   if (out != null) {
     if (VERBOSE.intValue() < levelValue) {
       levelValue = VERBOSE.intValue();
     }
     stream.setOutputStream(out);
   } else {
     /* ensure that messages are not logged */
     levelValue = Level.OFF.intValue();
   }
 }
예제 #4
0
 private static void setVlog(Logger logger, LogLevel logLevel) {
   final Level newLevel = logLevel.getLevel();
   logger.setLevel(newLevel);
   do {
     for (Handler handler : logger.getHandlers()) {
       Level handlerLevel = handler.getLevel();
       if (newLevel.intValue() < handlerLevel.intValue()) {
         handler.setLevel(newLevel);
       }
     }
   } while (logger.getUseParentHandlers() && (logger = logger.getParent()) != null);
 }
예제 #5
0
 protected static void Log(Level loglevel, String txt, boolean sendReport) {
   logger.log(loglevel, String.format("[%s] %s", name, txt == null ? "" : txt));
   if (config != null) {
     if (sendReport && loglevel.intValue() > Level.WARNING.intValue() && config.sendErrorReports) {
       sendErrorReport(txt, null);
     }
     if (messenger != null
         && loglevel.intValue() > Level.INFO.intValue()
         && config.sendLogOnError) {
       messenger.sendNotify(String.format("[%s] %s", name, txt == null ? "" : txt));
     }
   }
 }
예제 #6
0
 public ChatArguments colorizeLevel(Level level) {
   ChatStyle color;
   if (level.intValue() >= Level.SEVERE.intValue()) {
     color = ChatStyle.RED;
   } else if (level.intValue() >= Level.WARNING.intValue()) {
     color = ChatStyle.YELLOW;
   } else if (level.intValue() >= Level.INFO.intValue()) {
     color = ChatStyle.DARK_GREEN;
   } else {
     color = ChatStyle.GRAY;
   }
   return new ChatArguments(color, level, ChatStyle.RESET);
 }
 public static void log(Level pLevel, Exception pExp) {
   if (pLevel.intValue() >= Catalog.LOG_LEVEL.intValue()) {
     StringWriter pMsg = new StringWriter();
     pExp.printStackTrace(new PrintWriter(pMsg));
     log("[" + pLevel.getName() + "] " + pMsg.toString());
   }
 }
  protected static void setupSidlogger(Level lvl) {
    if (!Level.OFF.equals(lvl)) {
      Filter bslf = new BoshSidLoggerFilter();

      Logger BoshConnectionManagerLogger = Logger.getLogger(BoshConnectionManager.class.getName());
      Logger BoshSessionLogger = Logger.getLogger(BoshSession.class.getName());

      if (BoshConnectionManagerLogger.getLevel() == null
          || BoshSessionLogger.getLevel() == null
          || BoshConnectionManagerLogger.getLevel().intValue() < lvl.intValue()) {
        BoshConnectionManagerLogger.setLevel(lvl);
        BoshConnectionManagerLogger.setFilter(bslf);
        BoshSessionLogger.setLevel(lvl);
        BoshSessionLogger.setFilter(bslf);

        BoshConnectionManagerLogger.getParent().setFilter(bslf);
      }

      try {
        if (null == sidFilehandler) {
          sidFilehandler = new FileHandler("logs/bosh_sid.log", 10000000, 5, false);
          sidFilehandler.setLevel(lvl);
          sidFilehandler.setFilter(bslf);
          BoshConnectionManagerLogger.getParent().addHandler(sidFilehandler);
        }
      } catch (IOException ex) {
        log.log(Level.CONFIG, "Error creating BOSH SID logger" + ex);
      }
    }
  }
  /**
   * The launcher allows for the following logging levels: "FINEST", "FINE", "INFO", "WARNING",
   * "SEVERE". Since the launcher is unusually chatty, we don't want it to use the same logging
   * level as OperaDriver. Besides, it doesn't have the same logging levels as Java. This method
   * accepts a Java logging level and converts it to something sensible to pass on to the launcher.
   *
   * @param level the Java logging level
   * @return a sensible, non-chatty logging level
   */
  protected static Level toLauncherLoggingLevel(Level level) {
    // ALL -2147483648
    // FINEST 300
    // FINER 400
    // FINE 500
    // CONFIG 700
    // INFO 800
    // WARNING 900
    // SEVERE 1000
    // OFF 2147483647

    switch (level.intValue()) {
      case 1000: // SEVERE
        return Level.SEVERE;

      case 900: // WARNING
        return Level.WARNING;

      case 800: // INFO
      case 700: // CONFIG
      case 500: // FINE
      case 400: // FINER
        return Level.FINE;

      case 300: // FINEST
      case -2147483648: // ALL
        return Level.FINEST;

      default: // OFF
        return Level.OFF;
    }
  }
예제 #10
0
  public void setLogLevel(int newLevel) {
    int currentLevel = 0;
    if (getLogger().getLevel() != null) {
      currentLevel = getLogger().getLevel().intValue();
    }
    Level lLevel = null;
    if (newLevel == LOG_TRACEDEBUG_LEVEL) {
      lLevel = Level.FINEST;
    } else if (newLevel == LOG_TRACEENTRY_LEVEL
        || newLevel == LOG_TRACEEXIT_LEVEL
        || newLevel == LOG_TRACEENTRYEXIT_LEVEL) {
      lLevel = Level.FINER;
    } else if (newLevel == LOG_TRACEEVENT_LEVEL) {
      lLevel = Level.FINE;
    } else if (newLevel == LOG_INFO_LEVEL) {
      lLevel = Level.INFO;
    } else if (newLevel == LOG_WARN_LEVEL) {
      lLevel = Level.WARNING;
    } else if (newLevel == LOG_ERROR_LEVEL) {
      lLevel = Level.SEVERE;
    }

    if (lLevel != null && lLevel.intValue() != currentLevel) {
      resetLevels(getLogger(), lLevel);
    }
  }
예제 #11
0
    @Override
    public void publish(LogRecord record) {
      Level level = record.getLevel();
      Throwable t = record.getThrown();
      AttributeSet attributes = defaultAttributes;

      if (level.intValue() >= Level.WARNING.intValue()) {
        attributes = errorAttributes;
      } else if (level.intValue() < Level.INFO.intValue()) {
        attributes = debugAttributes;
      }

      log(record.getMessage() + "\n", attributes);
      if (t != null) {
        log(getStackTrace(t) + "\n", attributes);
      }
    }
예제 #12
0
  @Override
  public void log(final Object msg, final Level level, final int depth) {

    if (level.intValue() >= debugLevel.intValue()) {
      final StringBuilder tabBuffer = new StringBuilder();
      tabBuffer.append(':');
      for (int i = 0; i < depth; i++) {
        tabBuffer.append(INDENTATION_CHAR);
      }

      final StringBuilder buffer = new StringBuilder();
      buffer.append(tabBuffer);
      buffer.append(
          msg.toString().replaceAll(NEW_LINE_STRING, NEW_LINE_STRING + tabBuffer.toString()));
      System.out.println(buffer);
    }
  }
 /**
  * Store a LogRecord in the ring buffer
  *
  * @param record Description of the log event. A null record is silently ignored and is not
  *     published
  */
 @Override
 public void publish(LogRecord record) {
   if (record != null
       && record.getLevel().intValue() >= level.intValue()
       && level.intValue() != OFF_VALUE) {
     synchronized (buffer) {
       int ix = (start + count) % buffer.length;
       buffer[ix] = record;
       if (count < buffer.length) {
         count++;
       } else {
         start++;
         start %= buffer.length;
       }
     }
   }
 }
예제 #14
0
 private LogStreamLog(LogStream stream, Level level) {
   if ((stream != null) && (level != null)) {
     /* if the stream or level is null, dont log any
      * messages
      */
     levelValue = level.intValue();
   }
   this.stream = stream;
 }
예제 #15
0
 /*
  * (non-Javadoc)
  *
  * @see com.jcraft.jsch.Logger#isEnabled(int)
  */
 public boolean isEnabled(int level) {
   Level jdkLogLevel = null;
   if (logger == null || (jdkLogLevel = toJDKLogLevel(level)) == Level.OFF) {
     return false;
   }
   // Return true if the JDK logger level emcompasses the given JSch log
   // level
   return logger.getLevel().intValue() <= jdkLogLevel.intValue();
 }
예제 #16
0
 /**
  * @param level {@link Level} The level to filter the log entries.
  * @return all log entries for that level and above.
  */
 public List<LogEntry> filter(Level level) {
   List<LogEntry> toReturn = new ArrayList<LogEntry>();
   for (LogEntry entry : entries) {
     if (entry.getLevel().intValue() >= level.intValue()) {
       toReturn.add(entry);
     }
   }
   return toReturn;
 }
예제 #17
0
 /**
  * Method to avoid creating duplicate instances when deserializing the object.
  *
  * @return the singleton instance of this <code>Level</code> value in this classloader
  * @throws ObjectStreamException If unable to deserialize
  */
 protected Object readResolve() throws ObjectStreamException {
   if (this.intValue() == INFO.intValue()) {
     return INFO;
   }
   if (this.intValue() == STDERR.intValue()) {
     return STDERR;
   }
   throw new InvalidObjectException("Unknown instance :" + this);
 }
예제 #18
0
  /**
   * Starts to listen on given log and collect parameters of messages that were send to it. This is
   * supposed to be called at the begining of a test, to get messages from the programs that use <a
   * href="http://wiki.netbeans.org/wiki/view/FitnessViaTimersCounters">timers/counters</a>
   * infrastructure. At the end one should call {@link #assertInstances}.
   *
   * @param log logger to listen on, if null, it uses the standard timers/counters one
   * @param msg name of messages to collect, if null, all messages will be recorded
   * @param level level of messages to record
   * @since 1.44
   */
  public static void enableInstances(Logger log, String msg, Level level) {
    if (log == null) {
      log = Logger.getLogger("TIMER"); // NOI18N
    }

    log.addHandler(new InstancesHandler(msg, level));

    if (log.getLevel() == null || log.getLevel().intValue() > level.intValue()) {
      log.setLevel(level);
    }
  }
예제 #19
0
 protected static void Log(Level loglevel, Exception err, boolean sendReport) {
   logger.log(
       loglevel,
       String.format("[%s] %s", name, err == null ? "? unknown exception ?" : err.getMessage()),
       err);
   if (config != null) {
     if (sendReport && loglevel.intValue() > Level.WARNING.intValue() && config.sendErrorReports) {
       sendErrorReport(null, err);
     }
     if (messenger != null
         && loglevel.intValue() > Level.INFO.intValue()
         && config.sendLogOnError) {
       messenger.sendNotify(
           String.format(
               "[%s] %s%n%s",
               name,
               err == null ? "? unknown exception ?" : err.getMessage(),
               Str.getStackStr(err)));
     }
   }
 }
예제 #20
0
  private synchronized void setLogging() throws IOException {
    int consoleLevel = config.getPropertyAsInt("log.consoleLevel", 0);
    int fileLevel = config.getPropertyAsInt("log.fileLevel", 0);
    Level consoleLogLevel = LogFormatter.getLogLevel(consoleLevel);
    Level fileLogLevel = LogFormatter.getLogLevel(fileLevel);
    Level logLevel =
        consoleLogLevel.intValue() < fileLogLevel.intValue() ? consoleLogLevel : fileLogLevel;
    boolean showThreads = config.getPropertyAsBoolean("log.threads", false);
    String[] packages = config.getPropertyAsArray("log.packages", "se.sics");
    if (packages != null && packages.length > 0) {
      for (int i = 0, n = packages.length; i < n; i++) {
        Logger.getLogger(packages[i]).setLevel(logLevel);
      }
    } else {
      Logger awRoot = Logger.getLogger("se.sics");
      awRoot.setLevel(logLevel);
    }

    formatter.setShowingThreads(showThreads);
    LogFormatter.setConsoleLevel(consoleLogLevel);
    // LogFormatter.setLevelForAllHandlers(logLevel);

    Logger root = Logger.getLogger("");
    if (fileLogLevel != Level.OFF) {
      if (rootFileHandler == null) {
        rootFileHandler = new FileHandler(logFilePrefix + "%g.log", 1000000, 10);
        rootFileHandler.setFormatter(formatter);
        root.addHandler(rootFileHandler);
      }
      rootFileHandler.setLevel(fileLogLevel);
      if (simLogHandler != null) {
        simLogHandler.setLevel(fileLogLevel);
      }
    } else if (rootFileHandler != null) {
      exitSimulationLog();
      root.removeHandler(rootFileHandler);
      rootFileHandler.close();
      rootFileHandler = null;
    }
  }
예제 #21
0
 protected static void Log(Level loglevel, String txt, Exception params, boolean sendReport) {
   if (txt == null) {
     Log(loglevel, params);
   } else {
     logger.log(
         loglevel, String.format("[%s] %s", name, txt == null ? "" : txt), (Exception) params);
     if (config != null) {
       if (sendReport
           && loglevel.intValue() > Level.WARNING.intValue()
           && config.sendErrorReports) {
         sendErrorReport(txt, params);
       }
       if (messenger != null
           && loglevel.intValue() > Level.INFO.intValue()
           && config.sendLogOnError) {
         messenger.sendNotify(
             String.format(
                 "[%s] %s%n%s", name, txt, params.getMessage(), Str.getStackStr(params)));
       }
     }
   }
 }
예제 #22
0
  public Level setLevel(final String iLevel, final Class<? extends Handler> iHandler) {
    final Level level =
        iLevel != null ? Level.parse(iLevel.toUpperCase(Locale.ENGLISH)) : Level.INFO;

    if (level.intValue() < minimumLevel.intValue()) {
      // UPDATE MINIMUM LEVEL
      minimumLevel = level;

      if (level.equals(Level.FINER) || level.equals(Level.FINE) || level.equals(Level.FINEST))
        debug = info = warn = error = true;
      else if (level.equals(Level.INFO)) {
        info = warn = error = true;
        debug = false;
      } else if (level.equals(Level.WARNING)) {
        warn = error = true;
        debug = info = false;
      } else if (level.equals(Level.SEVERE)) {
        error = true;
        debug = info = warn = false;
      }
    }

    Logger log = Logger.getLogger(DEFAULT_LOG);
    while (log != null) {
      log.setLevel(level);

      for (Handler h : log.getHandlers()) {
        if (h.getClass().isAssignableFrom(iHandler)) {
          h.setLevel(level);
          break;
        }
      }

      log = log.getParent();
    }

    return level;
  }
예제 #23
0
  public void recordCondition(Plugin plugin, boolean shouldPrefix, String condition, Level level) {
    String content = ChatColor.AQUA + condition;
    String message = content;
    String prefix = ChatColor.GRAY + plugin.getName() + ChatColor.GRAY + "] ";

    if (shouldPrefix) {
      message = prefix + content;
    }

    if (level.intValue() <= this.broadcastLevel.intValue()) {
      Bukkit.broadcast(message, "pulse.observe");
    }

    System.out.println(
        "[Pulse] " + level.getLocalizedName() + "] " + plugin.getName() + "] " + condition);
  }
예제 #24
0
  /** Renders the given log recorders as RSS. */
  /*package*/ static void doRss(StaplerRequest req, StaplerResponse rsp, List<LogRecord> logs)
      throws IOException, ServletException {
    // filter log records based on the log level
    String level = req.getParameter("level");
    if (level != null) {
      Level threshold = Level.parse(level);
      List<LogRecord> filtered = new ArrayList<LogRecord>();
      for (LogRecord r : logs) {
        if (r.getLevel().intValue() >= threshold.intValue()) filtered.add(r);
      }
      logs = filtered;
    }

    RSS.forwardToRss(
        "Hudson log",
        "",
        logs,
        new FeedAdapter<LogRecord>() {
          public String getEntryTitle(LogRecord entry) {
            return entry.getMessage();
          }

          public String getEntryUrl(LogRecord entry) {
            return "log"; // TODO: one URL for one log entry?
          }

          public String getEntryID(LogRecord entry) {
            return String.valueOf(entry.getSequenceNumber());
          }

          public String getEntryDescription(LogRecord entry) {
            return Functions.printLogRecord(entry);
          }

          public Calendar getEntryTimestamp(LogRecord entry) {
            GregorianCalendar cal = new GregorianCalendar();
            cal.setTimeInMillis(entry.getMillis());
            return cal;
          }

          public String getEntryAuthor(LogRecord entry) {
            return Mailer.descriptor().getAdminAddress();
          }
        },
        req,
        rsp);
  }
예제 #25
0
  /**
   * Enables logging for given logger name and given severity. Everything logged to the object is
   * going to go to the returned CharSequence object which can be used to check the content or
   * converted <code>toString</code>.
   *
   * <p>The logging stops when the returned object is garbage collected.
   *
   * @param loggerName the name to capture logging for
   * @param level the level of details one wants to get
   * @return character sequence which can be check or converted to string
   * @since 1.27
   */
  public static CharSequence enable(String loggerName, Level level) {
    IL il = new IL(false);
    class MyPs extends PrintStream implements CharSequence {
      private ByteArrayOutputStream os;

      public MyPs() {
        this(new ByteArrayOutputStream());
      }

      private MyPs(ByteArrayOutputStream arr) {
        super(arr);
        os = arr;
      }

      public int length() {
        return toString().length();
      }

      public char charAt(int index) {
        return toString().charAt(index);
      }

      public CharSequence subSequence(int start, int end) {
        return toString().subSequence(start, end);
      }

      @Override
      public String toString() {
        return os.toString();
      }
    }

    Logger l = Logger.getLogger(loggerName);
    if (l.getLevel() == null || l.getLevel().intValue() > level.intValue()) {
      l.setLevel(level);
    }
    MyPs ps = new MyPs();
    Log log = new Log(l, ps);
    log.setLevel(level);
    l.addHandler(log);
    return ps;
  }
예제 #26
0
  static void configure(Level lev, String root, NbTestCase current) {
    IL il = new IL(false);

    String c = "handlers=" + Log.class.getName() + "\n" + root + ".level=" + lev.intValue() + "\n";

    ByteArrayInputStream is = new ByteArrayInputStream(c.getBytes());
    try {
      LogManager.getLogManager().readConfiguration(is);
    } catch (IOException ex) {
      // exception
      ex.printStackTrace();
    }

    Log.current = current;
    Log.messages.setLength(0);
    Log.messages.append("Starting test ");
    Log.messages.append(current.getName());
    Log.messages.append('\n');
    Log.initialMessages = Log.messages.length();
  }
  /**
   * Flushes the log buffer, logging each buffered log message using the reef-bridge log function.
   */
  private void logAll() {
    synchronized (this) {
      final StringBuilder sb = new StringBuilder();
      Level highestLevel = Level.FINEST;
      for (final LogRecord record : this.logs) {
        sb.append(formatter.format(record));
        sb.append("\n");
        if (record.getLevel().intValue() > highestLevel.intValue()) {
          highestLevel = record.getLevel();
        }
      }
      try {
        final int level = getLevel(highestLevel);
        NativeInterop.clrBufferedLog(level, sb.toString());
      } catch (Exception e) {
        System.err.println("Failed to perform CLRBufferedLogHandler");
      }

      this.logs.clear();
    }
  }
 protected static void enableTraceOptionIfSetOnConfiguration(
     ILaunchConfiguration configuration, ProjectLauncher launcher) throws CoreException {
   if (configuration.hasAttribute(LaunchConstants.ATTR_TRACE)) {
     launcher.setTrace(
         configuration.getAttribute(LaunchConstants.ATTR_TRACE, LaunchConstants.DEFAULT_TRACE));
   }
   String logLevelStr = configuration.getAttribute(ATTR_LOGLEVEL, (String) null);
   if (logLevelStr != null) {
     Plugin.getDefault()
         .getLog()
         .log(
             new Status(
                 IStatus.WARNING,
                 Plugin.PLUGIN_ID,
                 0,
                 MessageFormat.format(
                     "The {0} attribute is no longer supported, use {1} instead.",
                     ATTR_LOGLEVEL, LaunchConstants.ATTR_TRACE),
                 null));
     Level logLevel = Level.parse(logLevelStr);
     launcher.setTrace(launcher.getTrace() || logLevel.intValue() <= Level.FINE.intValue());
   }
 }
예제 #29
0
 /** Returns the Log4J level for the given Java level. */
 @SuppressWarnings("fallthrough")
 private static org.apache.log4j.Level toLog4JLevel(final Level level) {
   final int n = level.intValue();
   switch (n / 100) {
     default:
       {
         // MAX_VALUE is a special value for Level.OFF. Otherwise and
         // if positive, log to fatal since we are greater than SEVERE.
         switch (n) {
           default:
             if (n >= 0) return org.apache.log4j.Level.FATAL; // fallthrough ALL otherwise.
           case Integer.MIN_VALUE:
             return org.apache.log4j.Level.ALL;
           case Integer.MAX_VALUE:
             return org.apache.log4j.Level.OFF;
         }
       }
     case 10:
       return org.apache.log4j.Level.ERROR; // SEVERE
     case 9:
       return org.apache.log4j.Level.WARN; // WARNING
     case 8: // INFO
     case 7:
       return org.apache.log4j.Level.INFO; // CONFIG
     case 6: // (not allocated)
     case 5:
       return org.apache.log4j.Level.DEBUG; // FINE
     case 4:
       return org.apache.log4j.Level.TRACE; // FINER
     case 3: // FINEST
     case 2: // (not allocated)
     case 1: // (not allocated)
     case 0:
       return org.apache.log4j.Level.ALL; // ALL
   }
 }
예제 #30
0
/** @author Kamnev Georgiy */
public class LocalRepoCommands extends BaseCLIFun {
  // <editor-fold defaultstate="collapsed" desc="log Функции">
  private static final Logger logger = Logger.getLogger(LocalRepoCommands.class.getName());
  private static final Level logLevel = logger.getLevel();
  private static final boolean isLogSevere =
      logLevel == null ? true : logLevel.intValue() <= Level.SEVERE.intValue();

  private static final boolean isLogWarning =
      logLevel == null ? true : logLevel.intValue() <= Level.WARNING.intValue();

  private static final boolean isLogInfo =
      logLevel == null ? true : logLevel.intValue() <= Level.INFO.intValue();

  private static final boolean isLogFine =
      logLevel == null ? true : logLevel.intValue() <= Level.FINE.intValue();

  private static final boolean isLogFiner =
      logLevel == null ? true : logLevel.intValue() <= Level.FINER.intValue();

  private static final boolean isLogFinest =
      logLevel == null ? true : logLevel.intValue() <= Level.FINEST.intValue();

  private static void logFine(String message, Object... args) {
    logger.log(Level.FINE, message, args);
  }

  private static void logFiner(String message, Object... args) {
    logger.log(Level.FINER, message, args);
  }

  private static void logFinest(String message, Object... args) {
    logger.log(Level.FINEST, message, args);
  }

  private static void logInfo(String message, Object... args) {
    logger.log(Level.INFO, message, args);
  }

  private static void logWarning(String message, Object... args) {
    logger.log(Level.WARNING, message, args);
  }

  private static void logSevere(String message, Object... args) {
    logger.log(Level.SEVERE, message, args);
  }

  private static void logException(Throwable ex) {
    logger.log(Level.SEVERE, null, ex);
  }
  // </editor-fold>

  //    public final UpMain upmain;
  //
  //    public LocalRepoCommands( UpMain upmain ){
  //        if( upmain==null )throw new IllegalArgumentException( "upmain==null" );
  //        this.upmain = upmain;
  //    }

  //    public void println(){
  //        upmain.getOutput().println();
  //    }
  //
  //    public void println(Object obj){
  //        upmain.getOutput().println(obj);
  //    }
  //
  //    public BasicTemplate.EasyTemplate template(String template){
  //        return upmain.getOutput().template(template);
  //    }

  @Fun
  @Name(name = "localRepo")
  @Help(shortDesc = "create local repo")
  public LocalUplaunchRepo localRepo(
      @Name(name = "path") @Help(shortDesc = "location of repo") String path) {
    if (path == null) return null;

    File froot = FileSystems.get(path);
    File dir = froot;
    if (dir != null && !dir.isExists()) {
      dir.mkdirs();
    }

    LocalUplaunchRepo luprepo = new LocalUplaunchRepo();
    luprepo.setRoot(froot);

    return luprepo;
  }

  public static final Map<RepoConfig, LocalUplaunchRepo> configRepoMap =
      new WeakHashMap<RepoConfig, LocalUplaunchRepo>();

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "config")
  public RepoConfig getConfig(LocalUplaunchRepo repo) {
    if (repo == null) throw new IllegalArgumentException("repo==null");
    RepoConfig rc = repo.getConfig();
    if (rc != null) {
      configRepoMap.put(rc, repo);
    }
    return rc;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "print")
  public void print(RepoConfig config) {
    if (config == null) throw new IllegalArgumentException("config==null");

    String title = "";

    LocalUplaunchRepo urepo = configRepoMap.get(config);
    if (urepo != null) {
      String repoName = RepositoriesCommands.repoNameMap.get(urepo);
      if (repoName != null) {
        title = template("repo ${repoName} config\n").bind("repoName", repoName).eval();
      } else {
        title = "repo config\n";
      }
    }

    println(title);

    try {
      BeanInfo bi = Introspector.getBeanInfo(config.getClass());
      for (PropertyDescriptor pd : bi.getPropertyDescriptors()) {
        if (pd.getPropertyType() == null) continue;

        Method m = pd.getReadMethod();
        if (m == null) continue;

        try {
          Object val = m.invoke(config);
          template("${property:40} = ${value}")
              .bind("property", pd.getName())
              .bind("value", val)
              .println();
        } catch (IllegalAccessException ex) {
          Logger.getLogger(LocalRepoCommands.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
          Logger.getLogger(LocalRepoCommands.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
          Logger.getLogger(LocalRepoCommands.class.getName()).log(Level.SEVERE, null, ex);
        }
      }
    } catch (IntrospectionException ex) {
      Logger.getLogger(LocalRepoCommands.class.getName()).log(Level.SEVERE, null, ex);
    }

    //        template(
    //            "${title}"
    //                + "checkDepsOnInstall         = ${conf.checkDepsOnInstall}\n"
    //                + "checkDepsOnUnInstall       = ${conf.checkDepsOnUnInstall}\n"
    //                + "useFileLock                = ${conf.useFileLock}\n"
    //                + "updateIndex                = ${conf.updateIndex}\n"
    //                + "checkExistsComponentDir    = ${conf.checkExistsComponentDir}\n"
    //                + "emptyDirAsComponent        = ${conf.emptyDirAsComponent}\n"
    //                + "deleteEmptyDirsOnUnInstall = ${conf.deleteEmptyDirsOnUnInstall}\n"
    //                + "checkConfigChanges         = ${conf.checkConfigChanges}\n"
    //                + "refreshConfigOnChangeRoot  = ${conf.refreshConfigOnChangeRoot}\n"
    //        )
    //            .align()
    //            .bind("conf", config)
    //            .bind("title", title)
    //            .println();
  }

  public static class ConfigSet {
    public RepoConfig config;
    public String property;

    public ConfigSet(RepoConfig config, String property) {
      this.config = config;
      this.property = property;
    }
  }

  @Fun(operator = true)
  @Name(name = "set")
  public ConfigSet configSet_set(RepoConfig config, String property) {
    if (config == null) throw new IllegalArgumentException("config==null");
    if (property == null) throw new IllegalArgumentException("property==null");
    return new ConfigSet(config, property);
  }

  @Fun(operator = true)
  @Name(name = "=")
  public LocalUplaunchRepo configSet_apply(ConfigSet confSet, String value) {
    if (confSet == null) throw new IllegalArgumentException("confSet==null");
    if (value == null) throw new IllegalArgumentException("value==null");

    RepoConfig conf = confSet.config;
    String prop = confSet.property;

    TypeCastGraph tcast = new ExtendedCastGraph();

    try {
      BeanInfo bi = Introspector.getBeanInfo(conf.getClass());
      for (PropertyDescriptor pd : bi.getPropertyDescriptors()) {
        if (pd.getPropertyType() == null) continue;
        if (!pd.getName().equals(prop)) continue;

        Method m = pd.getWriteMethod();
        if (m == null) continue;

        Class t = pd.getPropertyType();
        Object val = tcast.cast(value, t);

        m.invoke(conf, val);
      }
    } catch (IntrospectionException ex) {
      Logger.getLogger(LocalRepoCommands.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
      Logger.getLogger(LocalRepoCommands.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalArgumentException ex) {
      Logger.getLogger(LocalRepoCommands.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InvocationTargetException ex) {
      Logger.getLogger(LocalRepoCommands.class.getName()).log(Level.SEVERE, null, ex);
    }

    return configRepoMap.get(conf);
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "refreshConfigOnChangeRoot")
  public LocalUplaunchRepo configSet_refreshConfigOnChangeRoot(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setRefreshConfigOnChangeRoot(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "checkConfigChanges")
  public LocalUplaunchRepo configSet_checkConfigChanges(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setCheckConfigChanges(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "deleteEmptyDirsOnUnInstall")
  public LocalUplaunchRepo configSet_deleteEmptyDirsOnUnInstall(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setDeleteEmptyDirsOnUnInstall(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "emptyDirAsComponent")
  public LocalUplaunchRepo configSet_emptyDirAsComponent(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setEmptyDirAsComponent(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "checkExistsComponentDir")
  public LocalUplaunchRepo configSet_checkExistsComponentDir(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setCheckExistsComponentDir(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "checkDepsOnInstall")
  public LocalUplaunchRepo configSetCDepsOnInst(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setCheckDepsOnInstall(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "checkDepsOnUnInstall")
  public LocalUplaunchRepo configSetCDepsOnUnInst(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setCheckDepsOnUnInstall(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "deps")
  public LocalUplaunchRepo configSetCDeps(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setCheckDepsOnUnInstall(val);
    config.setCheckDepsOnInstall(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "updateIndex")
  public LocalUplaunchRepo configSet_updateIndex(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setUpdateIndex(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "useFileLock")
  public LocalUplaunchRepo configSet_useFileLock(RepoConfig config, boolean val) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.setUseFileLock(val);

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }

  // TODO doc it
  @Fun(operator = true)
  @Name(name = "commit")
  public LocalUplaunchRepo configCommit(RepoConfig config) {
    if (config == null) throw new IllegalArgumentException("config==null");

    config.commit();

    LocalUplaunchRepo repo = configRepoMap.get(config);
    return repo;
  }
}