protected void setUp() throws Exception {
    super.setUp();

    LoggerManager loggerManager = (LoggerManager) lookup(LoggerManager.ROLE);

    loggerManager.setThreshold(Logger.LEVEL_DEBUG);
  }
  private void convert(CommandLine cli, PlexusContainer plexus)
      throws IOException, ComponentLookupException {
    if (cli.hasOption(DEBUG)) {
      try {
        LoggerManager mgr = (LoggerManager) plexus.lookup(LoggerManager.class);
        mgr.setThresholds(Logger.LEVEL_DEBUG);
      } catch (ComponentLookupException e) {
        // too bad we can't change log level
      }
    }

    File repository = new File(cli.getOptionValue(REPO));

    if (!repository.exists() || !repository.canRead() || !repository.isDirectory()) {
      System.err.println(
          "Invalid options.  Repository '"
              + repository.getCanonicalPath()
              + "' (the repository directory) must exists and be readable!");

      return;
    }

    File output = new File(cli.getOptionValue(OUTPUT));

    if (!output.exists()) {
      if (!output.mkdirs()) {
        System.err.println(
            "Invalid options.  Output '"
                + output.getCanonicalPath()
                + "' (where the output repositories locate) does not exist and can not be created!");

        return;
      }
    }

    if (!output.canWrite() || !output.isDirectory()) {
      System.err.println(
          "Invalid options.  Output '"
              + output.getCanonicalPath()
              + "' (where the output repositories locate) must be readable and writale!");

      return;
    }

    RepositoryConvertor repositoryConvertor =
        (RepositoryConvertor) plexus.lookup(RepositoryConvertor.class);

    try {
      if (cli.hasOption(MOVE)) {
        repositoryConvertor.convertRepositoryWithMove(repository, output);
      } else {
        repositoryConvertor.convertRepositoryWithCopy(repository, output);
      }
    } catch (IOException ioe) {
      showError("Repository conversion failed!", ioe, true);
    }

    System.out.println("Repository conversion is successful!");
  }
  public Logger getLoggerForComponent(final String role, final String roleHint) {
    checkNotNull(role);

    Logger logger =
        new LoggerImpl(
            getThreshold(),
            toLoggerName(role, roleHint),
            delegate.getLoggerForComponent(role, roleHint));

    log.debug("Created logger: {}", logger);

    return logger;
  }
Beispiel #4
0
  private void initializeLoggerManager() throws PlexusContainerException {
    // ----------------------------------------------------------------------
    // The logger manager may have been set programmatically so we need
    // to check. If it hasn't
    // ----------------------------------------------------------------------

    if (loggerManager == null) {
      try {
        loggerManager = (LoggerManager) lookup(LoggerManager.ROLE);
      } catch (ComponentLookupException e) {
        throw new PlexusContainerException("Unable to locate logger manager", e);
      }
    }

    enableLogging(loggerManager.getLoggerForComponent(PlexusContainer.class.getName()));
  }