Ejemplo n.º 1
0
  private static void configureLogging(CommandLineOptionHelper helper) {
    Level logLevel =
        helper.isParamPresent("-debug") ? Level.FINE : LoggingOptions.getDefaultLogLevel();
    if (logLevel == null) {
      logLevel = Level.INFO;
    }
    Logger.getLogger("").setLevel(logLevel);
    Logger.getLogger("org.openqa.jetty").setLevel(Level.WARNING);

    String logFilename =
        helper.isParamPresent("-log")
            ? helper.getParamValue("-log")
            : LoggingOptions.getDefaultLogOutFile();
    if (logFilename != null) {
      for (Handler handler : Logger.getLogger("").getHandlers()) {
        if (handler instanceof ConsoleHandler) {
          Logger.getLogger("").removeHandler(handler);
        }
      }
      try {
        Handler logFile = new FileHandler(new File(logFilename).getAbsolutePath(), true);
        logFile.setFormatter(new TerseFormatter(true));
        logFile.setLevel(logLevel);
        Logger.getLogger("").addHandler(logFile);
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    } else {
      boolean logLongForm = helper.isParamPresent("-logLongForm");
      for (Handler handler : Logger.getLogger("").getHandlers()) {
        if (handler instanceof ConsoleHandler) {
          handler.setLevel(logLevel);
          handler.setFormatter(new TerseFormatter(logLongForm));
        }
      }
    }
  }
Ejemplo n.º 2
0
 private static void printInfoAboutRoles(CommandLineOptionHelper helper) {
   if (helper.hasParamValue("-role")) {
     CliUtils.printWrappedLine(
         "",
         "Error: the role '"
             + helper.getParamValue("-role")
             + "' does not match a recognized server role\n");
   } else {
     CliUtils.printWrappedLine(
         "",
         "Error: -role option needs to be followed by the value that defines role of this component in the grid\n");
   }
   System.out.println(
       "Selenium server can run in one of the following roles:\n"
           + "  hub         as a hub of a Selenium grid\n"
           + "  node        as a node of a Selenium grid\n"
           + "  standalone  as a standalone server not being a part of a grid\n"
           + "\n"
           + "If -role option is omitted the server runs standalone\n");
   CliUtils.printWrappedLine(
       "",
       "To get help on the options available for a specific role run the server"
           + " with -help option and the corresponding -role option value");
 }