protected String[] getParameterNames() { List<String> fullNameList = new ArrayList<String>(); fullNameList.addAll(DEFAULT_PARAM_NAME_LIST); for (int i = 0; i < matcherList.size(); i++) { Matcher m = (Matcher) matcherList.get(i); fullNameList.add(m.getName()); } return (String[]) fullNameList.toArray(CoreConstants.EMPTY_STRING_ARRAY); }
EventEvaluator<ILoggingEvent> ee = evaluatorList.get(i); try { if (ee.evaluate(event)) { printStack = false; break; errorCount++; if (errorCount < CoreConstants.MAX_ERROR_COUNT) { addError("Exception thrown for evaluator named [" + ee.getName() + "]", eex); } else if (errorCount == CoreConstants.MAX_ERROR_COUNT) { ErrorStatus errorStatus = new ErrorStatus("Exception thrown for evaluator named [" + ee.getName() + "].", this, eex); errorStatus.add(new ErrorStatus("This was the last warning about this evaluator's errors." + "We don't want the StatusManager to get flooded.", this));
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError( "Could not start evaluator with expression [" + expression + "]", e); } }
public FilterReply decide(E event) { // let us not throw an exception // see also bug #17. if (!isStarted() || !evaluator.isStarted()) { return FilterReply.NEUTRAL; } try { if (evaluator.evaluate(event)) { return onMatch; } else { return onMismatch; } } catch (EvaluationException e) { addError("Evaluator " + evaluator.getName() + " threw an exception", e); return FilterReply.NEUTRAL; } }
public boolean evaluate(E event) throws EvaluationException { if (!isStarted()) { throw new IllegalStateException("Evaluator [" + name + "] was called in stopped state"); } try { Boolean result = (Boolean) scriptEvaluator.evaluate(getParameterValues(event)); return result.booleanValue(); } catch (Exception ex) { errorCount++; if (errorCount >= ERROR_THRESHOLD) { stop(); } throw new EvaluationException("Evaluator [" + name + "] caused an exception", ex); } }
className, ch.qos.logback.core.boolex.EventEvaluator.class, context); evaluator.setContext(this.context); evaluator.setName(evaluatorName);
if (eventEvaluator.evaluate(eventObject)) {
public void start() { if(name == null) { addError("All Matcher objects must be named"); return; } try { int code = 0; if(!caseSensitive) { code |= Pattern.CASE_INSENSITIVE; } if(canonEq) { code |= Pattern.CANON_EQ; } if(unicodeCase) { code |= Pattern.UNICODE_CASE; } //code |= Pattern.DOTALL; pattern = Pattern.compile(regex, code); start = true; } catch (PatternSyntaxException pse) { addError("Failed to compile regex [" + regex + "]", pse); } }
/** * Checks whether the input matches the regular expression. * * @param input * @return * @throws EvaluationException */ public boolean matches(String input) throws EvaluationException { if(start) { java.util.regex.Matcher matcher = pattern.matcher(input); return matcher.find(); } else { throw new EvaluationException("Matcher ["+regex+"] not started"); } }
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError( "Could not start evaluator with expression [" + expression + "]", e); } }
EventEvaluator<ILoggingEvent> ee = evaluatorList.get(i); try { if (ee.evaluate(le)) { printCallerData = true; break; errorCount++; if (errorCount < MAX_ERROR_COUNT) { addError("Exception thrown for evaluator named [" + ee.getName() + "]", eex); } else if (errorCount == MAX_ERROR_COUNT) { ErrorStatus errorStatus = new ErrorStatus("Exception thrown for evaluator named [" + ee.getName() + "].", this, eex); errorStatus.add(new ErrorStatus("This was the last warning about this evaluator's errors." + "We don't want the StatusManager to get flooded.", this));
protected String[] getParameterNames() { List<String> fullNameList = new ArrayList<String>(); fullNameList.addAll(DEFAULT_PARAM_NAME_LIST); for (int i = 0; i < matcherList.size(); i++) { Matcher m = (Matcher) matcherList.get(i); fullNameList.add(m.getName()); } return (String[]) fullNameList.toArray(CoreConstants.EMPTY_STRING_ARRAY); }
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError( "Could not start evaluator with expression [" + expression + "]", e); } }
EventEvaluator<ILoggingEvent> ee = evaluatorList.get(i); try { if (ee.evaluate(event)) { printStack = false; break; errorCount++; if (errorCount < CoreConstants.MAX_ERROR_COUNT) { addError("Exception thrown for evaluator named [" + ee.getName() + "]", eex); } else if (errorCount == CoreConstants.MAX_ERROR_COUNT) { ErrorStatus errorStatus = new ErrorStatus( "Exception thrown for evaluator named [" + ee.getName() + "].", this, eex); errorStatus.add(new ErrorStatus(
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError( "Could not start evaluator with expression [" + expression + "]", e); } }
EventEvaluator<ILoggingEvent> ee = evaluatorList.get(i); try { if (ee.evaluate(le)) { printCallerData = true; break; errorCount++; if (errorCount < MAX_ERROR_COUNT) { addError("Exception thrown for evaluator named [" + ee.getName() + "]", eex); } else if (errorCount == MAX_ERROR_COUNT) { ErrorStatus errorStatus = new ErrorStatus( "Exception thrown for evaluator named [" + ee.getName() + "].", this, eex); errorStatus.add(new ErrorStatus(
@Override public void start() { try { assert context != null; scriptEvaluator = new ScriptEvaluator(getDecoratedExpression(), EXPRESSION_TYPE, getParameterNames(), getParameterTypes(), THROWN_EXCEPTIONS); super.start(); } catch (Exception e) { addError("Could not start evaluator with expression [" + expression + "]", e); } }