Skip to content

Commit 61140ea

Browse files
committed
fix JaninoEvaluator issue/800, prepare release 1.5.4
1 parent 370de39 commit 61140ea

File tree

9 files changed

+102
-17
lines changed

9 files changed

+102
-17
lines changed

logback-classic-blackbox/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>ch.qos.logback</groupId>
1010
<artifactId>logback-parent</artifactId>
11-
<version>1.5.4-SNAPSHOT</version>
11+
<version>1.5.4</version>
1212
</parent>
1313

1414
<artifactId>logback-classic-blackbox</artifactId>

logback-classic-blackbox/src/test/java/ch/qos/logback/classic/blackbox/boolex/BlackboxJaninoEventEvaluatorTest.java

+19-5
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@
1414
package ch.qos.logback.classic.blackbox.boolex;
1515

1616
import java.io.IOException;
17+
import java.util.List;
1718

1819
import ch.qos.logback.classic.boolex.JaninoEventEvaluator;
1920
import ch.qos.logback.classic.util.LogbackMDCAdapter;
2021
import org.junit.jupiter.api.BeforeEach;
2122
import org.junit.jupiter.api.Disabled;
2223
import org.junit.jupiter.api.Test;
2324
import org.slf4j.MDC;
25+
import org.slf4j.Marker;
2426
import org.slf4j.MarkerFactory;
2527

2628
import ch.qos.logback.classic.Level;
@@ -121,10 +123,22 @@ public void mdcAsString() throws Exception {
121123
logbackMDCAdapter.remove(k);
122124
}
123125

124-
@Disabled
126+
@Test
127+
public void markerList() throws Exception {
128+
129+
jee.setExpression("markerList.contains(\"BLUE\")");
130+
jee.start();
131+
132+
LoggingEvent event = makeLoggingEvent(null);
133+
event.addMarker(MarkerFactory.getMarker("BLUE"));
134+
StatusPrinter.print(loggerContext);
135+
assertTrue(jee.evaluate(event));
136+
}
137+
125138
@Test
126139
public void marker() throws Exception {
127-
jee.setExpression("markerList.stream().anyMatch( m -> m.contains(\"BLUE\"))");
140+
141+
jee.setExpression("marker.contains(\"BLUE\")");
128142
jee.start();
129143

130144
LoggingEvent event = makeLoggingEvent(null);
@@ -133,10 +147,10 @@ public void marker() throws Exception {
133147
assertTrue(jee.evaluate(event));
134148
}
135149

136-
@Disabled
150+
// LBCORE_118
137151
@Test
138-
public void withNullMarker_LBCORE_118() throws Exception {
139-
jee.setExpression("markerList.contains(\"BLUE\")");
152+
public void withNullMarker_LOGBACK_63() throws Exception {
153+
jee.setExpression("marker.contains(\"BLUE\")");
140154
jee.start();
141155

142156
ILoggingEvent event = makeLoggingEvent(null);

logback-classic/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>ch.qos.logback</groupId>
1010
<artifactId>logback-parent</artifactId>
11-
<version>1.5.4-SNAPSHOT</version>
11+
<version>1.5.4</version>
1212
</parent>
1313

1414
<artifactId>logback-classic</artifactId>

logback-classic/src/main/java/ch/qos/logback/classic/boolex/JaninoEventEvaluator.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import ch.qos.logback.core.CoreConstants;
2626
import ch.qos.logback.core.boolex.JaninoEventEvaluatorBase;
2727
import ch.qos.logback.core.boolex.Matcher;
28+
import org.slf4j.Marker;
2829

2930
public class JaninoEventEvaluator extends JaninoEventEvaluatorBase<ILoggingEvent> {
3031

@@ -47,7 +48,8 @@ public class JaninoEventEvaluator extends JaninoEventEvaluatorBase<ILoggingEvent
4748
DEFAULT_PARAM_NAME_LIST.add("loggerContext");
4849
DEFAULT_PARAM_NAME_LIST.add("level");
4950
DEFAULT_PARAM_NAME_LIST.add("timeStamp");
50-
// DEFAULT_PARAM_NAME_LIST.add("markerList");
51+
DEFAULT_PARAM_NAME_LIST.add("marker");
52+
DEFAULT_PARAM_NAME_LIST.add("markerList");
5153
DEFAULT_PARAM_NAME_LIST.add("mdc");
5254
DEFAULT_PARAM_NAME_LIST.add("throwableProxy");
5355
DEFAULT_PARAM_NAME_LIST.add("throwable");
@@ -64,7 +66,8 @@ public class JaninoEventEvaluator extends JaninoEventEvaluatorBase<ILoggingEvent
6466
DEFAULT_PARAM_TYPE_LIST.add(LoggerContextVO.class);
6567
DEFAULT_PARAM_TYPE_LIST.add(int.class);
6668
DEFAULT_PARAM_TYPE_LIST.add(long.class);
67-
// DEFAULT_PARAM_TYPE_LIST.add(List.class);
69+
DEFAULT_PARAM_TYPE_LIST.add(Marker.class);
70+
DEFAULT_PARAM_TYPE_LIST.add(MarkerList.class);
6871
DEFAULT_PARAM_TYPE_LIST.add(Map.class);
6972
DEFAULT_PARAM_TYPE_LIST.add(IThrowableProxy.class);
7073
DEFAULT_PARAM_TYPE_LIST.add(Throwable.class);
@@ -123,7 +126,12 @@ protected Object[] getParameterValues(ILoggingEvent loggingEvent) {
123126
// // In order to avoid NullPointerException, we could push a dummy marker if
124127
// // the event's marker is null. However, this would surprise user who
125128
// // expect to see a null marker instead of a dummy one.
126-
// values[i++] = loggingEvent.getMarkerList();
129+
130+
MarkerList markerList = new MarkerList(loggingEvent.getMarkerList());
131+
Marker marker = markerList.getFirstMarker();
132+
values[i++] = marker;
133+
values[i++] = markerList;
134+
127135
values[i++] = loggingEvent.getMDCPropertyMap();
128136

129137
IThrowableProxy iThrowableProxy = loggingEvent.getThrowableProxy();
@@ -146,5 +154,4 @@ protected Object[] getParameterValues(ILoggingEvent loggingEvent) {
146154

147155
return values;
148156
}
149-
150157
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Logback: the reliable, generic, fast and flexible logging framework.
3+
* Copyright (C) 1999-2024, QOS.ch. All rights reserved.
4+
*
5+
* This program and the accompanying materials are dual-licensed under
6+
* either the terms of the Eclipse Public License v1.0 as published by
7+
* the Eclipse Foundation
8+
*
9+
* or (per the licensee's choosing)
10+
*
11+
* under the terms of the GNU Lesser General Public License version 2.1
12+
* as published by the Free Software Foundation.
13+
*/
14+
15+
package ch.qos.logback.classic.boolex;
16+
17+
import org.slf4j.Marker;
18+
19+
import java.util.List;
20+
21+
/**
22+
* A helper class to be used in conjunction with {@link ch.qos.logback.classic.boolex.JaninoEventEvaluator}
23+
*
24+
* @since 1.5.4
25+
*/
26+
public class MarkerList {
27+
28+
List<Marker> markers;
29+
30+
public MarkerList(List<Marker> markers) {
31+
this.markers = markers;
32+
}
33+
34+
/**
35+
* Check whether this list contains a given marker.
36+
*
37+
* @param markerName
38+
* @return
39+
*/
40+
public boolean contains(String markerName) {
41+
if(markerName == null || markerName.trim().length() == 0)
42+
return false;
43+
44+
if(markers == null || markers.isEmpty())
45+
return false;
46+
47+
final boolean result = markers.stream().anyMatch( m -> m.contains(markerName));
48+
return result;
49+
}
50+
51+
/**
52+
* Return the first marker on the list, can be null.
53+
*
54+
*
55+
* @return the first marker on the list, can be null
56+
*/
57+
public Marker getFirstMarker() {
58+
if(markers == null || markers.isEmpty()) {
59+
return null;
60+
} else {
61+
return markers.get(0);
62+
}
63+
}
64+
}

logback-core-blackbox/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>ch.qos.logback</groupId>
1010
<artifactId>logback-parent</artifactId>
11-
<version>1.5.4-SNAPSHOT</version>
11+
<version>1.5.4</version>
1212
</parent>
1313

1414
<artifactId>logback-core-blackbox</artifactId>

logback-core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>ch.qos.logback</groupId>
1010
<artifactId>logback-parent</artifactId>
11-
<version>1.5.4-SNAPSHOT</version>
11+
<version>1.5.4</version>
1212
</parent>
1313

1414
<artifactId>logback-core</artifactId>

logback-examples/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<parent>
99
<groupId>ch.qos.logback</groupId>
1010
<artifactId>logback-parent</artifactId>
11-
<version>1.5.4-SNAPSHOT</version>
11+
<version>1.5.4</version>
1212
</parent>
1313

1414
<artifactId>logback-examples</artifactId>

pom.xml

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<groupId>ch.qos.logback</groupId>
99
<artifactId>logback-parent</artifactId>
10-
<version>1.5.4-SNAPSHOT</version>
10+
<version>1.5.4</version>
1111
<packaging>pom</packaging>
1212

1313
<name>Logback-Parent</name>
@@ -48,7 +48,7 @@
4848

4949
<properties>
5050
<!-- yyyy-MM-dd'T'HH:mm:ss'Z' -->
51-
<project.build.outputTimestamp>2024-03-07T10:52:46Z</project.build.outputTimestamp>
51+
<project.build.outputTimestamp>2024-04-09T07:33:00Z</project.build.outputTimestamp>
5252

5353
<!-- minimal JDK version at runtime -->
5454
<jdk.version>11</jdk.version>
@@ -93,7 +93,7 @@
9393
<maven-resources-plugin.version>3.1.0</maven-resources-plugin.version>
9494
<license-maven-plugin.version>3.0</license-maven-plugin.version>
9595
<maven-jar-plugin.version>3.2.2</maven-jar-plugin.version>
96-
<maven-jxr-plugin.version>3.1.1</maven-jxr-plugin.version>
96+
<maven-jxr-plugin.version>3.3.2</maven-jxr-plugin.version>
9797
<maven-release-plugin.version>3.0.0-M4</maven-release-plugin.version>
9898
<maven-deploy-plugin.version>3.0.0-M1</maven-deploy-plugin.version>
9999
<maven-dependency-plugin.version>3.2.0</maven-dependency-plugin.version>

0 commit comments

Comments
 (0)