Skip to content

Commit f06f3da

Browse files
committed
Add filter for test logging.
Let's get a much saner output without the Unknown[RelationshipType|PropertyKey]Warning messages.
1 parent a883bb7 commit f06f3da

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2011-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.neo4j.test;
17+
18+
import ch.qos.logback.classic.spi.ILoggingEvent;
19+
import ch.qos.logback.core.filter.Filter;
20+
import ch.qos.logback.core.spi.FilterReply;
21+
22+
import java.util.List;
23+
24+
/**
25+
* @author Gerrit Meier
26+
*/
27+
public class TestLogFilter extends Filter<ILoggingEvent> {
28+
29+
private static final List<String> FILTER_MESSAGES = List.of(
30+
"ClientNotification.Statement.UnknownRelationshipTypeWarning",
31+
"ClientNotification.Statement.UnknownPropertyKeyWarning"
32+
);
33+
34+
@Override
35+
public FilterReply decide(ILoggingEvent event) {
36+
37+
String message = event.getMessage();
38+
39+
for (String filterMessage : FILTER_MESSAGES) {
40+
if (message.contains(filterMessage)) {
41+
return FilterReply.DENY;
42+
}
43+
}
44+
45+
return FilterReply.ACCEPT;
46+
}
47+
}

src/test/resources/logback-test.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<configuration>
1919

2020
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
21+
<filter class="org.springframework.data.neo4j.test.TestLogFilter" />
2122
<encoder>
2223
<pattern>[%t] %d %5p %40.40c:%4L - %m%n</pattern>
2324
</encoder>

0 commit comments

Comments
 (0)