Skip to content

Commit 3c4a16c

Browse files
Add aggregation for new log line (#52)
1 parent ae32bdb commit 3c4a16c

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

src/main/java/org/gridsuite/shortcircuit/server/reports/ReportMapperCourcirc.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ private ReporterModel forCourcirc(@NonNull final ReporterModel reporterModel) {
102102
ReportWrapper logsTransientReactanceTooLowSummary = null;
103103
TypedValue logsTransientReactanceTooLowSeverity = null;
104104

105+
long logsTransientReactanceUndefinedCount = 0L;
106+
ReportWrapper logsTransientReactanceUndefinedSummary = null;
107+
TypedValue logsTransientReactanceUndefinedSeverity = null;
108+
105109
long logsSimulatingShortCircuitLocatedCount = 0L;
106110
ReportWrapper logsSimulatingShortCircuitLocatedSummary = null;
107111
TypedValue logsSimulatingShortCircuitLocatedSeverity = null;
@@ -121,6 +125,15 @@ private ReporterModel forCourcirc(@NonNull final ReporterModel reporterModel) {
121125
}
122126
copyReportAsTrace(newReporter, report);
123127
logsTransientReactanceTooLowCount++;
128+
} else if (StringUtils.endsWith(report.getDefaultMessage(), " : transient reactance undefined ==> generator ignored")) {
129+
//we match line "X.ABCDEF2 : transient reactance undefined ==> generator ignored"
130+
if (logsTransientReactanceUndefinedSummary == null) {
131+
logsTransientReactanceUndefinedSummary = new ReportWrapper();
132+
newReporter.report(logsTransientReactanceUndefinedSummary);
133+
logsTransientReactanceUndefinedSeverity = report.getValue(Report.REPORT_SEVERITY_KEY);
134+
}
135+
copyReportAsTrace(newReporter, report);
136+
logsTransientReactanceUndefinedCount++;
124137
} else if (StringUtils.startsWith(report.getDefaultMessage(), "Simulating : short-circuit located on node ")) {
125138
//we match line "Simulating : short-circuit located on node .BRIDGE_0"
126139
if (logsSimulatingShortCircuitLocatedSummary == null) {
@@ -153,6 +166,13 @@ private ReporterModel forCourcirc(@NonNull final ReporterModel reporterModel) {
153166
Map.of(Report.REPORT_SEVERITY_KEY, ObjectUtils.defaultIfNull(logsTransientReactanceTooLowSeverity, TypedValue.WARN_SEVERITY),
154167
"nb", new TypedValue(logsTransientReactanceTooLowCount, TypedValue.UNTYPED))));
155168
}
169+
log.debug("Found {} lines in courcirc logs matching \"MYNODE : transient reactance undefined ==> generator ignored\"", logsTransientReactanceUndefinedCount);
170+
if (logsTransientReactanceUndefinedSummary != null) {
171+
logsTransientReactanceUndefinedSummary.setReport(new Report("transientReactanceUndefinedSummary",
172+
"${nb} node(s) with transient reactance undefined ==> generator ignored",
173+
Map.of(Report.REPORT_SEVERITY_KEY, ObjectUtils.defaultIfNull(logsTransientReactanceUndefinedSeverity, TypedValue.WARN_SEVERITY),
174+
"nb", new TypedValue(logsTransientReactanceUndefinedCount, TypedValue.UNTYPED))));
175+
}
156176
log.debug("Found {} lines in courcirc logs matching \"Simulating : short-circuit located on node MYNODE\"", logsSimulatingShortCircuitLocatedCount);
157177
if (logsSimulatingShortCircuitLocatedSummary != null) {
158178
logsSimulatingShortCircuitLocatedSummary.setReport(new Report("simulatingShortCircuitLocatedNodeSummary",

src/test/resources/reporter_courcirc_modified.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,42 @@
189189
"type" : "SEVERITY"
190190
}
191191
}
192+
}, {
193+
"reportKey" : "transientReactanceUndefinedSummary",
194+
"values" : {
195+
"reportSeverity" : {
196+
"value" : "WARN",
197+
"type" : "SEVERITY"
198+
},
199+
"nb" : {
200+
"value" : 3,
201+
"type" : "UNTYPED"
202+
}
203+
}
204+
}, {
205+
"reportKey" : "REC_15",
206+
"values" : {
207+
"reportSeverity" : {
208+
"value" : "TRACE",
209+
"type" : "SEVERITY"
210+
}
211+
}
212+
}, {
213+
"reportKey" : "REC_16",
214+
"values" : {
215+
"reportSeverity" : {
216+
"value" : "TRACE",
217+
"type" : "SEVERITY"
218+
}
219+
}
220+
}, {
221+
"reportKey" : "REC_17",
222+
"values" : {
223+
"reportSeverity" : {
224+
"value" : "TRACE",
225+
"type" : "SEVERITY"
226+
}
227+
}
192228
}, {
193229
"reportKey" : "REC_245",
194230
"values" : {
@@ -309,6 +345,9 @@
309345
"REC_11" : "T:NODE2 : transient reactance too low ==> generator ignored",
310346
"REC_12" : "T NODE3 : transient reactance too low ==> generator ignored",
311347
"REC_13" : "T—NODE4 : transient reactance too low ==> generator ignored",
348+
"REC_15" : "NODE-1 : transient reactance undefined ==> generator ignored",
349+
"REC_16" : "NODE-2 : transient reactance undefined ==> generator ignored",
350+
"REC_17" : "NODE-3 : transient reactance undefined ==> generator ignored",
312351
"REC_245" : "Simulating : short-circuits located on nodes with branches contributions",
313352
"REC_246" : "Simulating : short-circuit located on node NODE123_0",
314353
"REC_274" : "Simulating : short-circuit located on node ABCDEFG_1",
@@ -318,6 +357,7 @@
318357
"REC_306" : "Short circuit on node DUPOND2_0 is not simulated : it is located in an out of voltage part of the network",
319358
"REC_307" : "Simulating : short-circuit located on node CAPTAIN_0",
320359
"transientReactanceTooLowSummary" : "${nb} node(s) with transient reactance too low ==> generator ignored",
360+
"transientReactanceUndefinedSummary" : "${nb} node(s) with transient reactance undefined ==> generator ignored",
321361
"simulatingShortCircuitLocatedNodeSummary": "Simulating: short-circuits located on ${nb} nodes",
322362
"shortCircuitNodeNotSimulatedOutOfVoltageSummary": "Short circuit on ${nb} nodes is not simulated : they are in an out of voltage part of the network."
323363
}

src/test/resources/reporter_courcirc_test.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,30 @@
177177
"type" : "SEVERITY"
178178
}
179179
}
180+
}, {
181+
"reportKey" : "REC_15",
182+
"values" : {
183+
"reportSeverity" : {
184+
"value" : "WARN",
185+
"type" : "SEVERITY"
186+
}
187+
}
188+
}, {
189+
"reportKey" : "REC_16",
190+
"values" : {
191+
"reportSeverity" : {
192+
"value" : "WARN",
193+
"type" : "SEVERITY"
194+
}
195+
}
196+
}, {
197+
"reportKey" : "REC_17",
198+
"values" : {
199+
"reportSeverity" : {
200+
"value" : "WARN",
201+
"type" : "SEVERITY"
202+
}
203+
}
180204
}, {
181205
"reportKey" : "REC_245",
182206
"values" : {
@@ -273,6 +297,9 @@
273297
"REC_11" : "T:NODE2 : transient reactance too low ==> generator ignored",
274298
"REC_12" : "T NODE3 : transient reactance too low ==> generator ignored",
275299
"REC_13" : "T—NODE4 : transient reactance too low ==> generator ignored",
300+
"REC_15" : "NODE-1 : transient reactance undefined ==> generator ignored",
301+
"REC_16" : "NODE-2 : transient reactance undefined ==> generator ignored",
302+
"REC_17" : "NODE-3 : transient reactance undefined ==> generator ignored",
276303
"REC_245" : "Simulating : short-circuits located on nodes with branches contributions",
277304
"REC_246" : "Simulating : short-circuit located on node NODE123_0",
278305
"REC_274" : "Simulating : short-circuit located on node ABCDEFG_1",

0 commit comments

Comments
 (0)