Skip to content

Commit daa148f

Browse files
committed
log message cleanup
1 parent d31e75a commit daa148f

File tree

4 files changed

+48
-36
lines changed

4 files changed

+48
-36
lines changed

src/main/java/dev/dsf/fhir/validator/implementation_guide/ValidationPackage.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ private Consumer<ValidationPackageEntry> doParseResources(FhirContext context, L
151151
{
152152
return entry ->
153153
{
154-
if ("package/package.json".equals(entry.getFileName())
155-
|| (entry.getFileName() != null && (entry.getFileName().startsWith("package/example")
156-
|| entry.getFileName().endsWith(".index.json") || !entry.getFileName().endsWith(".json"))))
154+
if ("package/package.json".equals(entry.getFileName()) || (entry.getFileName() != null
155+
&& (entry.getFileName().startsWith("package/example") || entry.getFileName().endsWith(".index.json")
156+
|| entry.getFileName().endsWith(".schema.json") || !entry.getFileName().endsWith(".json"))))
157157
{
158158
logger.debug("Ignoring {}", entry.getFileName());
159159
return;
@@ -187,8 +187,8 @@ else if (resource instanceof ValueSet v)
187187
}
188188
catch (Exception e)
189189
{
190-
logger.warn("Ignoring resource with error while parsing, {}: {}", e.getClass().getName(),
191-
e.getMessage());
190+
logger.warn("Ignoring resource with error while parsing {}, {}: {}", entry.getFileName(),
191+
e.getClass().getName(), e.getMessage());
192192
}
193193
};
194194
}

src/main/java/dev/dsf/fhir/validator/implementation_guide/ValidationPackageWithDepedencies.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private void logMissingValueSets(Set<String> neededValueSets, List<ValueSet> fou
256256
if (!missingValueSets.isEmpty())
257257
{
258258
logger.warn(
259-
"The following ValueSet are required for validation but could not be found in validation package {}|{} or its dependencies, this may result in incomplete valdidation: [{}]",
259+
"The following ValueSet are required for validation but could not be found in package (incl. dependencies) {}|{}, this may result in incomplete valdidation: [{}]",
260260
getName(), getVersion(), missingValueSets);
261261
}
262262
}

src/main/java/dev/dsf/fhir/validator/main/ValidationMain.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ private BundleValidator createBundleValidator()
138138

139139
public void validate(BundleValidator validator, String[] files)
140140
{
141-
logger.info("Using validation packages {}", validationPackageIdentifiers);
142-
143141
Arrays.stream(files).map(this::read).filter(r -> r != null).forEach(r ->
144142
{
145143
logger.info("Validating {} from {}", r.getResource().getResourceType().name(), r.getFilename());
@@ -188,7 +186,7 @@ private FileNameAndResource tryJson(String file)
188186
try (InputStream in = Files.newInputStream(Paths.get(file)))
189187
{
190188
IBaseResource resource = fhirContext.newJsonParser().parseResource(in);
191-
logger.info("{} read from {}", resource.getClass().getSimpleName(), file);
189+
logger.debug("{} read from {}", resource.getClass().getSimpleName(), file);
192190
return new FileNameAndResource(file, (Resource) resource);
193191
}
194192
catch (Exception e)
@@ -203,7 +201,7 @@ private FileNameAndResource tryXml(String file)
203201
try (InputStream in = Files.newInputStream(Paths.get(file)))
204202
{
205203
IBaseResource resource = fhirContext.newXmlParser().parseResource(in);
206-
logger.info("{} read from {}", resource.getClass().getSimpleName(), file);
204+
logger.debug("{} read from {}", resource.getClass().getSimpleName(), file);
207205
return new FileNameAndResource(file, (Resource) resource);
208206
}
209207
catch (Exception e)

src/main/java/dev/dsf/fhir/validator/service/ValidatorFactoryImpl.java

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import ca.uhn.fhir.context.support.DefaultProfileValidationSupport;
3030
import ca.uhn.fhir.context.support.IValidationSupport;
3131
import dev.dsf.fhir.validator.client.TerminologyServerClient;
32+
import dev.dsf.fhir.validator.implementation_guide.ValidationPackageIdentifier;
3233
import dev.dsf.fhir.validator.implementation_guide.ValidationPackageWithDepedencies;
3334
import dev.dsf.fhir.validator.structure_definition.SnapshotGenerator;
3435
import dev.dsf.fhir.validator.structure_definition.SnapshotGenerator.SnapshotWithValidationMessages;
@@ -154,27 +155,29 @@ private List<ValueSet> withExpandedValueSets(ValidationPackageWithDepedencies pa
154155

155156
packageWithDependencies.getValueSetsIncludingDependencies(valueSetBindingStrengths, fhirContext).forEach(v ->
156157
{
157-
logger.debug("Expanding ValueSet {}|{}", v.getUrl(), v.getVersion());
158+
logger.debug("Expanding ValueSet {}|{} from package (incl. dependencies) {}", v.getUrl(), v.getVersion(),
159+
packageWithDependencies.getIdentifier().toString());
158160

159161
// ValueSet uses filter or import in compose
160162
if (v.hasCompose() && ((v.getCompose().hasInclude()
161163
&& (v.getCompose().getInclude().stream().anyMatch(c -> c.hasFilter() || c.hasValueSet())))
162164
|| (v.getCompose().hasExclude()
163165
&& v.getCompose().getExclude().stream().anyMatch(c -> c.hasFilter() || c.hasValueSet()))))
164166
{
165-
expandExternal(expandedValueSets, v);
167+
expandExternal(expandedValueSets, v, packageWithDependencies.getIdentifier());
166168
}
167169
else
168170
{
169171
// will try external expansion if internal not successful
170-
expandInternal(expandedValueSets, expander, v);
172+
expandInternal(expandedValueSets, expander, v, packageWithDependencies.getIdentifier());
171173
}
172174
});
173175

174176
return expandedValueSets;
175177
}
176178

177-
private void expandExternal(List<ValueSet> expandedValueSets, ValueSet v)
179+
private void expandExternal(List<ValueSet> expandedValueSets, ValueSet v,
180+
ValidationPackageIdentifier validationPackageIdentifier)
178181
{
179182
try
180183
{
@@ -184,41 +187,45 @@ private void expandExternal(List<ValueSet> expandedValueSets, ValueSet v)
184187
catch (WebApplicationException e)
185188
{
186189
logger.warn(
187-
"Error while expanding ValueSet {}|{} externally, this may result in incomplete validation: {} - {}",
188-
v.getUrl(), v.getVersion(), e.getClass().getName(), e.getMessage());
190+
"Unable to expand ValueSet {}|{} from package (incl. dependencies) {} externally, this may result in incomplete validation: {} - {}",
191+
v.getUrl(), v.getVersion(), validationPackageIdentifier.toString(), e.getClass().getName(),
192+
e.getMessage());
189193
getOutcome(e).ifPresent(m -> logger.debug("Expansion error response: {}", m));
190194
logger.debug("ValueSet with error while expanding: {}",
191195
fhirContext.newJsonParser().encodeResourceToString(v));
192196
}
193197
catch (Exception e)
194198
{
195199
logger.warn(
196-
"Error while expanding ValueSet {}|{} externally, this may result in incomplete validation: {} - {}",
197-
v.getUrl(), v.getVersion(), e.getClass().getName(), e.getMessage());
200+
"Unable to expand ValueSet {}|{} from package (incl. dependencies) {} externally, this may result in incomplete validation: {} - {}",
201+
v.getUrl(), v.getVersion(), validationPackageIdentifier.toString(), e.getClass().getName(),
202+
e.getMessage());
198203
logger.debug("ValueSet with error while expanding: {}",
199204
fhirContext.newJsonParser().encodeResourceToString(v));
200205
}
201206
}
202207

203-
private void expandInternal(List<ValueSet> expandedValueSets, ValueSetExpander expander, ValueSet v)
208+
private void expandInternal(List<ValueSet> expandedValueSets, ValueSetExpander expander, ValueSet v,
209+
ValidationPackageIdentifier validationPackageIdentifier)
204210
{
205211
try
206212
{
207213
ValueSetExpansionOutcome expansion = expander.expand(v);
208214

209215
if (expansion.getError() != null)
210-
logger.warn("Error while expanding ValueSet {}|{} internally: {}", v.getUrl(), v.getVersion(),
211-
expansion.getError());
216+
logger.warn("Unable to expand ValueSet {}|{} from package (incl. dependencies) {} internally: {}",
217+
v.getUrl(), v.getVersion(), validationPackageIdentifier.toString(), expansion.getError());
212218
else
213219
expandedValueSets.add(expansion.getValueset());
214220
}
215221
catch (Exception e)
216222
{
217223
logger.info(
218-
"Error while expanding ValueSet {}|{} internally: {} - {}, trying to expand via external terminology server next",
219-
v.getUrl(), v.getVersion(), e.getClass().getName(), e.getMessage());
224+
"Unable to expand ValueSet {}|{} from package (incl. dependencies) {} internally: {} - {}, trying to expand via external terminology server next",
225+
v.getUrl(), v.getVersion(), validationPackageIdentifier.toString(), e.getClass().getName(),
226+
e.getMessage());
220227

221-
expandExternal(expandedValueSets, v);
228+
expandExternal(expandedValueSets, v, validationPackageIdentifier);
222229
}
223230
}
224231

@@ -250,15 +257,16 @@ private IValidationSupport withSnapshots(List<ValueSet> expandedValueSets,
250257
packageWithDependencies.getValidationSupportResources().getStructureDefinitions().stream()
251258
.filter(s -> s.hasDifferential() && !s.hasSnapshot())
252259
.forEach(diff -> createSnapshot(packageWithDependencies, snapshotsAndExpandedValueSets, snapshots,
253-
generator, diff));
260+
generator, diff, packageWithDependencies.getIdentifier()));
254261
}
255262

256263
return supportChain;
257264
}
258265

259266
private void createSnapshot(ValidationPackageWithDepedencies packageWithDependencies,
260267
ValidationSupportWithCustomResources snapshotsAndExpandedValueSets,
261-
Map<String, StructureDefinition> snapshots, SnapshotGenerator generator, StructureDefinition diff)
268+
Map<String, StructureDefinition> snapshots, SnapshotGenerator generator, StructureDefinition diff,
269+
ValidationPackageIdentifier validationPackageIdentifier)
262270
{
263271
if (snapshots.containsKey(diff.getUrl() + "|" + diff.getVersion()))
264272
return;
@@ -267,8 +275,8 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
267275
definitions.addAll(packageWithDependencies.getStructureDefinitionDependencies(diff));
268276
definitions.add(diff);
269277

270-
logger.debug("Generating snapshot for {}|{}, base {}, dependencies {}", diff.getUrl(), diff.getVersion(),
271-
diff.getBaseDefinition(),
278+
logger.debug("Generating snapshot for {}|{} from package (incl. dependencies) {}, base {}, dependencies {}",
279+
diff.getUrl(), diff.getVersion(), validationPackageIdentifier.toString(), diff.getBaseDefinition(),
272280
definitions.stream()
273281
.filter(sd -> !sd.equals(diff) && !sd.getUrl().equals(diff.getBaseDefinition())
274282
&& !(sd.getUrl() + "|" + sd.getVersion()).equals(diff.getBaseDefinition()))
@@ -284,16 +292,19 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
284292

285293
if (PublicationStatus.ACTIVE.equals(diff.getStatus()) && !dependenciesWithDifferentStatus.isEmpty())
286294
{
287-
logger.warn("StructureDefinition {}|{}, has dependencies with no active status [{}]", diff.getUrl(),
288-
diff.getVersion(), dependenciesWithDifferentStatus);
295+
logger.warn(
296+
"StructureDefinition {}|{} from package (incl. dependencies) {}, has dependencies with no active status [{}]",
297+
diff.getUrl(), diff.getVersion(), validationPackageIdentifier.toString(),
298+
dependenciesWithDifferentStatus);
289299
}
290300

291301
definitions.stream().filter(sd -> sd.hasDifferential() && !sd.hasSnapshot()
292302
&& !snapshots.containsKey(sd.getUrl() + "|" + sd.getVersion())).forEach(sd ->
293303
{
294304
try
295305
{
296-
logger.debug("Generating snapshot for {}|{}", sd.getUrl(), sd.getVersion());
306+
logger.debug("Generating snapshot for {}|{} from package (incl. dependencies) {}", sd.getUrl(),
307+
sd.getVersion(), validationPackageIdentifier.toString());
297308
SnapshotWithValidationMessages snapshot = generator.generateSnapshot(sd);
298309

299310
if (snapshot.getSnapshot().hasSnapshot())
@@ -304,8 +315,8 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
304315
}
305316
else
306317
logger.error(
307-
"Error while generating snapshot for {}|{}: Not snaphsot returned from generator",
308-
diff.getUrl(), diff.getVersion());
318+
"Error while generating snapshot for {}|{} from package (incl. dependencies) {}: Not snaphsot returned from generator",
319+
diff.getUrl(), diff.getVersion(), validationPackageIdentifier.toString());
309320

310321
snapshot.getMessages().forEach(m ->
311322
{
@@ -320,12 +331,15 @@ private void createSnapshot(ValidationPackageWithDepedencies packageWithDependen
320331
}
321332
catch (Exception e)
322333
{
323-
logger.error("Error while generating snapshot for {}|{}: {} - {}", diff.getUrl(),
324-
diff.getVersion(), e.getClass().getName(), e.getMessage());
334+
logger.error(
335+
"Error while generating snapshot for {}|{} from package (incl. dependencies) {}: {} - {}",
336+
diff.getUrl(), diff.getVersion(), validationPackageIdentifier.toString(),
337+
e.getClass().getName(), e.getMessage());
325338
}
326339
});
327340

328-
logger.debug("Generating snapshot for {}|{} [Done]", diff.getUrl(), diff.getVersion());
341+
logger.debug("Generating snapshot for {}|{} from package (incl. dependencies) {} [Done]", diff.getUrl(),
342+
diff.getVersion(), validationPackageIdentifier.toString());
329343
}
330344

331345
private ValidationSupportChain createSupportChain(FhirContext context,

0 commit comments

Comments
 (0)