improved logging

This commit is contained in:
Grahame Grieve 2019-09-07 07:31:22 +10:00
parent 631ca754d9
commit bd4a93067b
5 changed files with 12 additions and 11 deletions

View File

@ -1524,7 +1524,7 @@ public class ProfileComparer implements ProfileKnowledgeProvider {
public BindingResolution resolveBindingInt(StructureDefinition def, String url, String desc) throws FHIRException {
ValueSet vs = null;
if (url.startsWith("#")) {
if (url != null && url.startsWith("#")) {
for (ValueSet t : valuesets) {
if (("#"+t.getId()).equals(url)) {
vs = t;
@ -1532,7 +1532,7 @@ public class ProfileComparer implements ProfileKnowledgeProvider {
}
}
}
if (vs == null)
if (url != null && vs == null)
context.fetchResource(ValueSet.class, url);
BindingResolution br = new BindingResolution();
if (vs != null) {

View File

@ -36,6 +36,7 @@ import org.hl7.fhir.exceptions.DefinitionException;
import org.hl7.fhir.exceptions.FHIRException;
import org.hl7.fhir.exceptions.TerminologyServiceException;
import org.hl7.fhir.r5.conformance.ProfileUtilities;
import org.hl7.fhir.r5.context.IWorkerContext.ILoggingService.LogCategory;
import org.hl7.fhir.r5.context.TerminologyCache.CacheToken;
import org.hl7.fhir.r5.model.BooleanType;
import org.hl7.fhir.r5.model.CapabilityStatement;
@ -341,7 +342,10 @@ public abstract class BaseWorkerContext implements IWorkerContext {
protected void tlog(String msg) {
if (tlogging )
System.out.println("-tx cache miss: "+msg);
if (logger != null)
logger.logDebugMessage(LogCategory.TX, msg);
else
System.out.println("-tx: "+msg);
}
// --- expansion support ------------------------------------------------------------------------------------------------------------

View File

@ -430,7 +430,11 @@ public interface IWorkerContext {
public interface ILoggingService {
public enum LogCategory {
PROGRESS, TX, INIT, CONTEXT, HTML
INIT,
PROGRESS,
TX,
CONTEXT,
HTML
}
public void logMessage(String message); // status messages, always display
public void logDebugMessage(LogCategory category, String message); // verbose; only when debugging

View File

@ -323,19 +323,16 @@ public class TerminologyCache {
for (String fn : new File(folder).list()) {
if (fn.endsWith(".cache") && !fn.equals("validation.cache")) {
try {
// System.out.println("Load "+fn);
String title = fn.substring(0, fn.lastIndexOf("."));
NamedCache nc = new NamedCache();
nc.name = title;
caches.put(title, nc);
System.out.print(" - load "+title+".cache");
String src = TextFile.fileToString(Utilities.path(folder, fn));
if (src.startsWith("?"))
src = src.substring(1);
int i = src.indexOf(ENTRY_MARKER);
while (i > -1) {
String s = src.substring(0, i);
System.out.print(".");
src = src.substring(i+ENTRY_MARKER.length()+1);
i = src.indexOf(ENTRY_MARKER);
if (!Utilities.noString(s)) {
@ -363,7 +360,6 @@ public class TerminologyCache {
nc.list.add(ce);
}
}
System.out.println("done");
} catch (Exception e) {
throw new FHIRException("Error loading "+fn+": "+e.getMessage(), e);
}

View File

@ -91,7 +91,6 @@ public class NPMPackageGenerator {
public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, Date date) throws FHIRException, IOException {
super();
System.out.println("create package file at "+destFile);
this.destFile = destFile;
start();
List<String> fhirVersion = new ArrayList<>();
@ -114,7 +113,6 @@ public class NPMPackageGenerator {
public NPMPackageGenerator(String destFile, String canonical, String url, PackageType kind, ImplementationGuide ig, Date date, List<String> fhirVersion) throws FHIRException, IOException {
super();
System.out.println("create package file at "+destFile);
this.destFile = destFile;
start();
buildPackageJson(canonical, kind, url, date, ig, fhirVersion);
@ -122,7 +120,6 @@ public class NPMPackageGenerator {
public NPMPackageGenerator(String destFile, JsonObject npm, Date date) throws FHIRException, IOException {
super();
System.out.println("create package file at "+destFile);
String dt = new SimpleDateFormat("yyyyMMddHHmmss").format(date);
packageJ = npm;
packageManifest = new JsonObject();