Skip to content

Commit 2545d64

Browse files
authored
0.70.6
improvement to log streaming actions - allow regex filter to match part of log message
1 parent 28de492 commit 2545d64

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subprojects {
55
apply plugin: 'maven'
66

77
group 'org.iot-dsa'
8-
version '0.70.5'
8+
version '0.70.6'
99

1010
targetCompatibility = JavaVersion.VERSION_1_8
1111
sourceCompatibility = JavaVersion.VERSION_1_8

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/sys/logging/StreamableLogNode.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.logging.Level;
99
import java.util.logging.LogRecord;
1010
import java.util.logging.Logger;
11+
import java.util.regex.Pattern;
1112
import org.iot.dsa.dslink.Action.ResultsType;
1213
import org.iot.dsa.dslink.ActionResults;
1314
import org.iot.dsa.logging.DSLevel;
@@ -68,7 +69,7 @@ protected void write(LogRecord record) {
6869
DSDateTime ts = DSDateTime.valueOf(record.getMillis());
6970
if (levelMatches(recordLevel, level.toLevel()) &&
7071
(name == null || name.isEmpty() || logNameMatches(recordName, name)) &&
71-
(filter == null || filter.isEmpty() || recordMsg.matches(filter))) {
72+
(filter == null || filter.isEmpty() || logTextMatches(recordMsg, filter))) {
7273

7374
while (lines.size() > 1000) {
7475
lines.remove(0);
@@ -162,6 +163,11 @@ public static boolean levelMatches(Level msgLevel, Level desiredLevel) {
162163
public static boolean logNameMatches(String msgLogName, String desiredLogName) {
163164
return msgLogName != null && msgLogName.startsWith(desiredLogName);
164165
}
166+
167+
public static boolean logTextMatches(String text, String filter) {
168+
Pattern p = Pattern.compile(filter);
169+
return p.matcher(text).find();
170+
}
165171

166172
static {
167173
levelRange = new DSList();

0 commit comments

Comments
 (0)