コード例 #1
0
  public void begin(InterpretationContext ic, String name, Attributes attributes) {
    threshold = System.currentTimeMillis();

    // See LOGBACK-527 (the system property is looked up first. Thus, it overrides
    // the equivalent property in the config file. This reversal of scope priority is justified
    // by the use case: the admin trying to chase rogue config file
    String debugAttrib = getSystemProperty(DEBUG_SYSTEM_PROPERTY_KEY);
    if (debugAttrib == null) {
      debugAttrib = ic.subst(attributes.getValue(INTERNAL_DEBUG_ATTR));
    }

    if (OptionHelper.isEmpty(debugAttrib)
        || debugAttrib.equalsIgnoreCase("false")
        || debugAttrib.equalsIgnoreCase("null")) {
      addInfo(INTERNAL_DEBUG_ATTR + " attribute not set");
    } else {
      OnConsoleStatusListener.addNewInstanceToContext(context);
    }

    processScanAttrib(ic, attributes);

    ContextUtil contextUtil = new ContextUtil(context);
    contextUtil.addHostNameAsProperty();

    if (EnvUtil.isGroovyAvailable()) {
      LoggerContext lc = (LoggerContext) context;
      contextUtil.addGroovyPackages(lc.getFrameworkPackages());
    }

    // the context is turbo filter attachable, so it is pushed on top of the
    // stack
    ic.pushObject(getContext());
  }
コード例 #2
0
  void doEvaluateAndCheck(String expression, ILoggingEvent event, boolean expected)
      throws EvaluationException {
    gee.setExpression(expression);
    gee.start();

    StatusPrinter.printInCaseOfErrorsOrWarnings(context);
    assertTrue(statusChecker.isErrorFree(0));

    ContextUtil contextUtil = new ContextUtil(context);
    contextUtil.addGroovyPackages(context.getFrameworkPackages());
    contextUtil.addFrameworkPackage(
        context.getFrameworkPackages(), "ch.qos.logback.classic.boolex");

    boolean result = gee.evaluate(event);
    assertEquals(expected, result);
  }