|
8 | 8 | import java.util.logging.Level; |
9 | 9 | import java.util.logging.LogRecord; |
10 | 10 | import java.util.logging.Logger; |
| 11 | +import java.util.regex.Pattern; |
11 | 12 | import org.iot.dsa.dslink.Action.ResultsType; |
12 | 13 | import org.iot.dsa.dslink.ActionResults; |
13 | 14 | import org.iot.dsa.logging.DSLevel; |
@@ -68,7 +69,7 @@ protected void write(LogRecord record) { |
68 | 69 | DSDateTime ts = DSDateTime.valueOf(record.getMillis()); |
69 | 70 | if (levelMatches(recordLevel, level.toLevel()) && |
70 | 71 | (name == null || name.isEmpty() || logNameMatches(recordName, name)) && |
71 | | - (filter == null || filter.isEmpty() || recordMsg.matches(filter))) { |
| 72 | + (filter == null || filter.isEmpty() || logTextMatches(recordMsg, filter))) { |
72 | 73 |
|
73 | 74 | while (lines.size() > 1000) { |
74 | 75 | lines.remove(0); |
@@ -162,6 +163,11 @@ public static boolean levelMatches(Level msgLevel, Level desiredLevel) { |
162 | 163 | public static boolean logNameMatches(String msgLogName, String desiredLogName) { |
163 | 164 | return msgLogName != null && msgLogName.startsWith(desiredLogName); |
164 | 165 | } |
| 166 | + |
| 167 | + public static boolean logTextMatches(String text, String filter) { |
| 168 | + Pattern p = Pattern.compile(filter); |
| 169 | + return p.matcher(text).find(); |
| 170 | + } |
165 | 171 |
|
166 | 172 | static { |
167 | 173 | levelRange = new DSList(); |
|
0 commit comments