Skip to content

Commit 8be5453

Browse files
Logging improvements
Use the LoggingFeature for all of the clients, not just the TylerEFM ones Also try to add tabs in logs that should be aligned
1 parent c69a959 commit 8be5453

4 files changed

Lines changed: 184 additions & 39 deletions

File tree

TylerEcf4/src/main/java/edu/suffolk/litlab/efsp/tyler/SoapClientChooser.java

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@
44
import ecf4.latest.tyler.efm.wsdl.webservicesprofile_implementation_4_0.CourtRecordMDEService;
55
import ecf4.latest.tyler.efm.wsdl.webservicesprofile_implementation_4_0.FilingReviewMDEService;
66
import ecf4.latest.tyler.efm.wsdl.webservicesprofile_implementation_4_0.ServiceMDEService;
7+
import edu.suffolk.litlab.efsp.ConfigurationLoader;
78
import edu.suffolk.litlab.efsp.Jurisdiction;
9+
import jakarta.xml.ws.WebServiceFeature;
810
import java.net.URL;
911
import java.util.Optional;
12+
import org.apache.cxf.ext.logging.LoggingFeature;
1013
import org.slf4j.Logger;
1114
import org.slf4j.LoggerFactory;
1215

@@ -23,6 +26,21 @@ public class SoapClientChooser {
2326
private static final String RECORD_SUFFIX = "-ECF-4.0-CourtRecordMDEService.wsdl";
2427
private static final String SCHEDULE_SUFFIX = "-v5-CourtSchedulingMDE.wsdl";
2528

29+
private static Optional<Boolean> shouldLogRequests = Optional.empty();
30+
31+
public static boolean shouldLogRequests() {
32+
if (shouldLogRequests.isEmpty()) {
33+
shouldLogRequests = Optional.of(ConfigurationLoader.shouldLogRequests());
34+
}
35+
return shouldLogRequests.orElse(false);
36+
}
37+
38+
public static WebServiceFeature getLoggingFeature() {
39+
LoggingFeature loggingFeature = new LoggingFeature();
40+
loggingFeature.setPrettyLogging(true);
41+
return loggingFeature;
42+
}
43+
2644
private static URL getRes(TylerDomain domain, TylerVersion version, String suffix) {
2745
String wsdlPath =
2846
"wsdl/"
@@ -45,22 +63,45 @@ public static Optional<FilingReviewMDEService> getFilingReviewFactory(Jurisdicti
4563
var domain = new TylerDomain(jurisdiction, TylerClients.getTylerEnv());
4664
return version.map(
4765
v -> {
66+
boolean shouldLog = shouldLogRequests();
4867
URL url = getRes(domain, v, REVIEW_SUFFIX);
49-
return new FilingReviewMDEService(url);
68+
if (shouldLog) {
69+
return new FilingReviewMDEService(url, getLoggingFeature());
70+
} else {
71+
return new FilingReviewMDEService(url);
72+
}
5073
});
5174
}
5275

5376
public static Optional<ServiceMDEService> getServiceFactory(Jurisdiction jurisdiction) {
5477
var version = TylerClients.getVersion(jurisdiction);
5578
var domain = new TylerDomain(jurisdiction, TylerClients.getTylerEnv());
5679

57-
return version.map(v -> new ServiceMDEService(getRes(domain, v, SERVICE_SUFFIX)));
80+
return version.map(
81+
v -> {
82+
boolean shouldLog = shouldLogRequests();
83+
URL url = getRes(domain, v, SERVICE_SUFFIX);
84+
if (shouldLog) {
85+
return new ServiceMDEService(url, getLoggingFeature());
86+
} else {
87+
return new ServiceMDEService(url);
88+
}
89+
});
5890
}
5991

6092
public static Optional<CourtRecordMDEService> getCourtRecordFactory(Jurisdiction jurisdiction) {
6193
var version = TylerClients.getVersion(jurisdiction);
6294
var domain = new TylerDomain(jurisdiction, TylerClients.getTylerEnv());
63-
return version.map(v -> new CourtRecordMDEService(getRes(domain, v, RECORD_SUFFIX)));
95+
return version.map(
96+
v -> {
97+
boolean shouldLog = shouldLogRequests();
98+
URL url = getRes(domain, v, RECORD_SUFFIX);
99+
if (shouldLog) {
100+
return new CourtRecordMDEService(url, getLoggingFeature());
101+
} else {
102+
return new CourtRecordMDEService(url);
103+
}
104+
});
64105
}
65106

66107
public static Optional<CourtSchedulingMDE_Service> getCourtSchedulingFactory(
@@ -70,6 +111,15 @@ public static Optional<CourtSchedulingMDE_Service> getCourtSchedulingFactory(
70111
}
71112
var version = TylerClients.getVersion(jurisdiction);
72113
var domain = new TylerDomain(jurisdiction, TylerClients.getTylerEnv());
73-
return version.map(v -> new CourtSchedulingMDE_Service(getRes(domain, v, SCHEDULE_SUFFIX)));
114+
return version.map(
115+
v -> {
116+
boolean shouldLog = shouldLogRequests();
117+
URL url = getRes(domain, v, SCHEDULE_SUFFIX);
118+
if (shouldLog) {
119+
return new CourtSchedulingMDE_Service(url, getLoggingFeature());
120+
} else {
121+
return new CourtSchedulingMDE_Service(url);
122+
}
123+
});
74124
}
75125
}

TylerEcf5/src/main/java/edu/suffolk/litlab/efsp/ecf5/SoapClientChooserV5.java

Lines changed: 109 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@
99
import ecf5.TylerCourtSchedulingMDEService;
1010
import ecf5.TylerFilingAssemblyMDEService;
1111
import ecf5.TylerFilingReviewMDEService;
12+
import edu.suffolk.litlab.efsp.ConfigurationLoader;
1213
import edu.suffolk.litlab.efsp.Jurisdiction;
1314
import edu.suffolk.litlab.efsp.tyler.TylerClients;
1415
import edu.suffolk.litlab.efsp.tyler.TylerDomain;
1516
import edu.suffolk.litlab.efsp.tyler.TylerVersion;
1617
import jakarta.xml.ws.BindingProvider;
18+
import jakarta.xml.ws.WebServiceFeature;
1719
import java.net.URL;
1820
import java.util.Optional;
1921
import java.util.function.Consumer;
2022
import java.util.function.Function;
23+
import org.apache.cxf.ext.logging.LoggingFeature;
2124
import org.slf4j.Logger;
2225
import org.slf4j.LoggerFactory;
2326

@@ -34,15 +37,39 @@ public class SoapClientChooserV5 {
3437
private static final String TYLER_FILING_ASSEM_WSDL = "-ECF5-TylerFilingAssemblyMDEService.wsdl";
3538
private static final String TYLER_FILING_REVIEW_WSDL = "-ECF5-TylerFilingReviewMDEService.wsdl";
3639

40+
private static Optional<Boolean> shouldLogRequests = Optional.empty();
41+
42+
public static boolean shouldLogRequests() {
43+
if (shouldLogRequests.isEmpty()) {
44+
shouldLogRequests = Optional.of(ConfigurationLoader.shouldLogRequests());
45+
}
46+
return shouldLogRequests.orElse(false);
47+
}
48+
49+
public static WebServiceFeature getLoggingFeature() {
50+
LoggingFeature loggingFeature = new LoggingFeature();
51+
loggingFeature.setPrettyLogging(true);
52+
return loggingFeature;
53+
}
54+
3755
public static Optional<Function<Consumer<BindingProvider>, CourtPolicyClient>>
3856
getCourtPolicyFactory(Jurisdiction jurisdiction) {
3957
var version = TylerClients.getVersion(jurisdiction);
4058
var domain = new TylerDomain(jurisdiction, TylerClients.getTylerEnv());
4159
return version.flatMap(
4260
v -> {
4361
var url = createLocalWsdlUrl(domain, v, COURT_POLICY_WSDL);
62+
boolean shouldLog = shouldLogRequests();
4463
return url.map(
45-
u -> (consume) -> new CourtPolicyClient(new CourtPolicyMDEService(u), v, consume));
64+
u ->
65+
(consume) -> {
66+
if (shouldLog) {
67+
return new CourtPolicyClient(
68+
new CourtPolicyMDEService(u, getLoggingFeature()), v, consume);
69+
} else {
70+
return new CourtPolicyClient(new CourtPolicyMDEService(u), v, consume);
71+
}
72+
});
4673
});
4774
}
4875

@@ -53,8 +80,17 @@ public class SoapClientChooserV5 {
5380
return version.flatMap(
5481
v -> {
5582
var url = createLocalWsdlUrl(domain, v, COURT_RECORD_WSDL);
83+
boolean shouldLog = shouldLogRequests();
5684
return url.map(
57-
u -> (consume) -> new CourtRecordClient(new CourtRecordMDEService(u), v, consume));
85+
u ->
86+
(consume) -> {
87+
if (shouldLog) {
88+
return new CourtRecordClient(
89+
new CourtRecordMDEService(u, getLoggingFeature()), v, consume);
90+
} else {
91+
return new CourtRecordClient(new CourtRecordMDEService(u), v, consume);
92+
}
93+
});
5894
});
5995
}
6096

@@ -65,10 +101,18 @@ public class SoapClientChooserV5 {
65101
return version.flatMap(
66102
v -> {
67103
var url = createLocalWsdlUrl(domain, v, COURT_SCHED_WSDL);
104+
boolean shouldLog = shouldLogRequests();
68105
return url.map(
69106
u ->
70-
(consume) ->
71-
new CourtSchedulingClient(new CourtSchedulingMDEService(u), v, consume));
107+
(consume) -> {
108+
if (shouldLog) {
109+
return new CourtSchedulingClient(
110+
new CourtSchedulingMDEService(u, getLoggingFeature()), v, consume);
111+
} else {
112+
return new CourtSchedulingClient(
113+
new CourtSchedulingMDEService(u), v, consume);
114+
}
115+
});
72116
});
73117
}
74118

@@ -79,8 +123,17 @@ public class SoapClientChooserV5 {
79123
return version.flatMap(
80124
v -> {
81125
var url = createLocalWsdlUrl(domain, v, FILING_REVIEW_WSDL);
126+
boolean shouldLog = shouldLogRequests();
82127
return url.map(
83-
u -> (consume) -> new FilingReviewClient(new FilingReviewMDEService(u), v, consume));
128+
u ->
129+
(consume) -> {
130+
if (shouldLog) {
131+
return new FilingReviewClient(
132+
new FilingReviewMDEService(u, getLoggingFeature()), v, consume);
133+
} else {
134+
return new FilingReviewClient(new FilingReviewMDEService(u), v, consume);
135+
}
136+
});
84137
});
85138
}
86139

@@ -91,7 +144,17 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
91144
return version.flatMap(
92145
v -> {
93146
var url = createLocalWsdlUrl(domain, v, SERVICE_WSDL);
94-
return url.map(u -> (consume) -> new ServiceClient(new ServiceMDEService(u), v, consume));
147+
boolean shouldLog = shouldLogRequests();
148+
return url.map(
149+
u ->
150+
(consume) -> {
151+
if (shouldLog) {
152+
return new ServiceClient(
153+
new ServiceMDEService(u, getLoggingFeature()), v, consume);
154+
} else {
155+
return new ServiceClient(new ServiceMDEService(u), v, consume);
156+
}
157+
});
95158
});
96159
}
97160

@@ -102,10 +165,18 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
102165
return version.flatMap(
103166
v -> {
104167
var url = createLocalWsdlUrl(domain, v, TYLER_COURT_RECORD_WSDL);
168+
boolean shouldLog = shouldLogRequests();
105169
return url.map(
106170
u ->
107-
(consume) ->
108-
new TylerCourtRecordClient(new TylerCourtRecordMDEService(u), v, consume));
171+
(consume) -> {
172+
if (shouldLog) {
173+
return new TylerCourtRecordClient(
174+
new TylerCourtRecordMDEService(u, getLoggingFeature()), v, consume);
175+
} else {
176+
return new TylerCourtRecordClient(
177+
new TylerCourtRecordMDEService(u), v, consume);
178+
}
179+
});
109180
});
110181
}
111182

@@ -116,11 +187,18 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
116187
return version.flatMap(
117188
v -> {
118189
var url = createLocalWsdlUrl(domain, v, TYLER_COURT_SCHED_WSDL);
190+
boolean shouldLog = shouldLogRequests();
119191
return url.map(
120192
u ->
121-
(consume) ->
122-
new TylerCourtSchedulingClient(
123-
new TylerCourtSchedulingMDEService(u), v, consume));
193+
(consume) -> {
194+
if (shouldLog) {
195+
return new TylerCourtSchedulingClient(
196+
new TylerCourtSchedulingMDEService(u, getLoggingFeature()), v, consume);
197+
} else {
198+
return new TylerCourtSchedulingClient(
199+
new TylerCourtSchedulingMDEService(u), v, consume);
200+
}
201+
});
124202
});
125203
}
126204

@@ -131,11 +209,18 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
131209
return version.flatMap(
132210
v -> {
133211
var url = createLocalWsdlUrl(domain, v, TYLER_FILING_ASSEM_WSDL);
212+
boolean shouldLog = shouldLogRequests();
134213
return url.map(
135214
u ->
136-
(consume) ->
137-
new TylerFilingAssemblyClient(
138-
new TylerFilingAssemblyMDEService(u), v, consume));
215+
(consume) -> {
216+
if (shouldLog) {
217+
return new TylerFilingAssemblyClient(
218+
new TylerFilingAssemblyMDEService(u, getLoggingFeature()), v, consume);
219+
} else {
220+
return new TylerFilingAssemblyClient(
221+
new TylerFilingAssemblyMDEService(u), v, consume);
222+
}
223+
});
139224
});
140225
}
141226

@@ -146,10 +231,18 @@ public static Optional<Function<Consumer<BindingProvider>, ServiceClient>> getSe
146231
return version.flatMap(
147232
v -> {
148233
var url = createLocalWsdlUrl(domain, v, TYLER_FILING_REVIEW_WSDL);
234+
boolean shouldLog = shouldLogRequests();
149235
return url.map(
150236
u ->
151-
(consume) ->
152-
new TylerFilingReviewClient(new TylerFilingReviewMDEService(u), v, consume));
237+
(consume) -> {
238+
if (shouldLog) {
239+
return new TylerFilingReviewClient(
240+
new TylerFilingReviewMDEService(u, getLoggingFeature()), v, consume);
241+
} else {
242+
return new TylerFilingReviewClient(
243+
new TylerFilingReviewMDEService(u), v, consume);
244+
}
245+
});
153246
});
154247
}
155248

proxyserver/src/main/java/edu/suffolk/litlab/efsp/server/EfspServer.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,23 @@ protected EfspServer(
110110
sf = new JAXRSServerFactoryBean();
111111
sf.setResourceClasses(new ArrayList<Class<?>>(services.keySet()));
112112

113-
LoggingFeature loggingFeature = new LoggingFeature();
114-
// TODO(brycew): control this from a cofig
115-
loggingFeature.addSensitiveElementNames(
116-
Set.of("api_key", "password", "Password", "TYLER-TOKEN-ILLINOIS", "TYLER-ID-ILLINOIS"));
117-
loggingFeature.addSensitiveProtocolHeaderNames(
118-
Set.of(
119-
"TYLER-TOKEN-ILLINOIS",
120-
"TYLER-TOKEN-MASSACHUSETTS",
121-
"TYLER-TOKEN-VERMONT",
122-
"TYLER-ID-ILLINOIS",
123-
"X-API-KEY",
124-
"x-api-key",
125-
"X-Api-Key"));
126-
loggingFeature.setPrettyLogging(true);
127-
sf.setFeatures(List.of(loggingFeature));
113+
if (ConfigurationLoader.shouldLogRequests()) {
114+
LoggingFeature loggingFeature = new LoggingFeature();
115+
// TODO(brycew): control this from a cofig
116+
loggingFeature.addSensitiveElementNames(
117+
Set.of("api_key", "password", "Password", "TYLER-TOKEN-ILLINOIS", "TYLER-ID-ILLINOIS"));
118+
loggingFeature.addSensitiveProtocolHeaderNames(
119+
Set.of(
120+
"TYLER-TOKEN-ILLINOIS",
121+
"TYLER-TOKEN-MASSACHUSETTS",
122+
"TYLER-TOKEN-VERMONT",
123+
"TYLER-ID-ILLINOIS",
124+
"X-API-KEY",
125+
"x-api-key",
126+
"X-Api-Key"));
127+
loggingFeature.setPrettyLogging(true);
128+
sf.setFeatures(List.of(loggingFeature));
129+
}
128130

129131
for (Map.Entry<Class<?>, SingletonResourceProvider> prov : services.entrySet()) {
130132
sf.setResourceProvider(prov.getKey(), prov.getValue());

proxyserver/src/main/java/edu/suffolk/litlab/efsp/tyler/ecfcodes/CodeUpdater.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ private boolean downloadCourtTables(
288288
String baseUrl)
289289
throws JAXBException, IOException, SQLException {
290290
MDC.put(MDCWrappers.SESSION_ID, location);
291-
log.info("Doing updates for: {}, tables: {}", location, tables);
291+
log.info("Doing updates for: {},\ttables: {}", location, tables);
292292
Instant downloadStart = Instant.now();
293293
// TODO(brycew-later): check that the effective date is later than today
294294
// JAXBElement<?> obj = ccl.getEffectiveDate().getDateRepresentation();
@@ -327,7 +327,7 @@ private boolean downloadCourtTables(
327327
var downloadInc = Duration.between(downloadStart, Instant.now());
328328
downloadDuration = downloadDuration.plus(downloadInc);
329329
log.info(
330-
"Location: {}: Downloads took: {} (total: {})", location, downloadInc, downloadDuration);
330+
"Location: {}:\tDownloads took: {} (total: {})", location, downloadInc, downloadDuration);
331331

332332
Instant updateStart = Instant.now();
333333
for (DownloadedCodes down : downloaded.values()) {
@@ -344,7 +344,7 @@ private boolean downloadCourtTables(
344344
updateDuration = updateDuration.plus(updateInc);
345345

346346
cd.commit();
347-
log.info("Location: {}: updates took: {} (total: {})", location, updateInc, updateDuration);
347+
log.info("Location: {}:\tupdates took: {} (total: {})", location, updateInc, updateDuration);
348348
MDC.remove(MDCWrappers.REQUEST_ID);
349349
MDC.remove(MDCWrappers.SESSION_ID);
350350
return true;
@@ -419,7 +419,7 @@ public boolean updateAll(String baseUrl, FilingReviewMDEPort filingPort, CodeDat
419419
final String courtLocation = courtAndTables.getKey();
420420
List<String> tables = courtAndTables.getValue();
421421
log.debug(
422-
"In {}, removing entries for court {} for tables: {}",
422+
"In {},\nremoving entries for court {} for tables: {}",
423423
cd.getJurisdiction(),
424424
courtLocation,
425425
tables);

0 commit comments

Comments
 (0)