View Javadoc

1   /**
2    * Logback: the generic, reliable, fast and flexible logging framework.
3    * 
4    * Copyright (C) 2000-2008, QOS.ch
5    * 
6    * This library is free software, you can redistribute it and/or modify it under
7    * the terms of the GNU Lesser General Public License as published by the Free
8    * Software Foundation.
9    */
10  package ch.qos.logback.classic.boolex;
11  
12  import ch.qos.logback.classic.Level;
13  import ch.qos.logback.classic.spi.LoggingEvent;
14  import ch.qos.logback.core.boolex.EvaluationException;
15  import ch.qos.logback.core.boolex.EventEvaluatorBase;
16  
17  /**
18   * Evaluates to true when the logging event passed as parameter has level ERROR
19   * or higher.
20   * 
21   * @author Ceki Gülcü
22   * 
23   */
24  public class OnErrorEvaluator extends EventEvaluatorBase<LoggingEvent> {
25  
26    /**
27     * Return true if event passed as parameter has level ERROR or higher, returns
28     * false otherwise.
29     */
30    public boolean evaluate(LoggingEvent event) throws NullPointerException,
31        EvaluationException {
32      return event.getLevel().levelInt >= Level.ERROR_INT;
33    }
34  }