Skip to content

Commit fe76353

Browse files
authored
Merge pull request #36 from exadel-inc/develop
[Tech] Added log filtering in test cases
2 parents 928ba89 + b99a4c2 commit fe76353

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Licensed under the Apache License, Version 2.0 (the "License").
3+
* You may not use this file except in compliance with the License.
4+
* You may obtain a copy of the License at
5+
*
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* Unless required by applicable law or agreed to in writing, software
9+
* distributed under the License is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
* See the License for the specific language governing permissions and
12+
* limitations under the License.
13+
*/
14+
package com.exadel.etoolbox.anydiff.log;
15+
16+
import ch.qos.logback.classic.spi.ILoggingEvent;
17+
import ch.qos.logback.core.boolex.EventEvaluatorBase;
18+
import com.exadel.etoolbox.anydiff.Constants;
19+
import org.apache.commons.lang3.StringUtils;
20+
21+
@SuppressWarnings("unused")
22+
public class LogEvaluator extends EventEvaluatorBase<ILoggingEvent> {
23+
@Override
24+
public boolean evaluate(ILoggingEvent event) throws NullPointerException {
25+
return !StringUtils.startsWith(event.getMessage(), Constants.DOT);
26+
}
27+
}

core/src/test/resources/logback-test.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<configuration>
33
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
4+
<filter class="ch.qos.logback.core.filter.EvaluatorFilter">
5+
<evaluator class="com.exadel.etoolbox.anydiff.log.LogEvaluator"/>
6+
<OnMismatch>DENY</OnMismatch>
7+
<OnMatch>ACCEPT</OnMatch>
8+
</filter>
49
<encoder>
510
<pattern>%msg%n</pattern>
611
</encoder>

0 commit comments

Comments
 (0)