operator/src/test/java/oracle/kubernetes/utils/TestUtils.java
public static ConsoleHandlerMemento silenceOperatorLogger() {
    Logger logger = LoggingFactory.getLogger("Operator", "Operator").getUnderlyingLogger();
    List<Handler> savedHandlers = new ArrayList<>();
    for (Handler handler : logger.getHandlers()) {
      if (handler instanceof ConsoleHandler) {
        savedHandlers.add(handler);
      }
    }

    for (Handler handler : savedHandlers) {
      logger.removeHandler(handler);
    }

    TestLogHandler testHandler = createStub(TestLogHandler.class);
    logger.addHandler(testHandler);

    return new ConsoleHandlerMemento(logger, testHandler, savedHandlers);
  }
/**
   * Removes the console handlers from the specified logger, in order to silence them during a test.
   *
   * @return a collection of the removed handlers
   */
Removes the console handlers from the specified logger, in order to silence them during a test.
@return a collection of the removed handlers
Removes the console handlers from the specified logger in order to silence them during a test . @return a collection of the removed handlers
public static ConsoleHandlerMemento silenceOperatorLogger() {
    Logger logger = LoggingFactory.getLogger("Operator", "Operator").getUnderlyingLogger();
    List<Handler> savedHandlers = new ArrayList<>();
    for (Handler handler : logger.getHandlers()) {
      if (handler instanceof ConsoleHandler) {
        savedHandlers.add(handler);
      }
    }
    for (Handler handler : savedHandlers) {
      logger.removeHandler(handler);
    }
    TestLogHandler testHandler = createStub(TestLogHandler.class);
    logger.addHandler(testHandler);
    return new ConsoleHandlerMemento(logger, testHandler, savedHandlers);
  }
public static ConsoleHandlerMemento silenceOperatorLogger ( ) { Logger logger = LoggingFactory . getLogger ( "Operator" , "Operator" ) . getUnderlyingLogger ( ) ; List < Handler > savedHandlers = new ArrayList < > ( ) ; for ( Handler handler : logger . getHandlers ( ) ) { if ( handler instanceof ConsoleHandler ) { savedHandlers . add ( handler ) ; } } for ( Handler handler : savedHandlers ) { logger . removeHandler ( handler ) ; } TestLogHandler testHandler = createStub ( TestLogHandler . class ) ; logger . addHandler ( testHandler ) ; return new ConsoleHandlerMemento ( logger , testHandler , savedHandlers ) ; }
Removes the console handlers from the specified logger, in order to silence them during a test.
Removes the console handlers from the specified logger in order to silence them during a test .