Use separate SUSHI and GoFSH logger and stats #143
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This makes it so that FSH Online shows the correct number of errors and warnings in the summary box when running GoFSH. GoFSH previously hadn't had the correct number of errors and warnings for two reasons:
When FSH Online was logging any messages (this pretty much only happens in the
run
functions for SUSHI/GoFSH and when loading the FHIR definitions), it was only using the logger from SUSHI. This meant that if you encountered any of the errors logged within FSH Online itself when running GoFSH, it was not included in the "stats" at the bottom of the summary box. In order to fix this issue, I created a util export for a logger that FSH Online can use and a function that sets that logger. This lets the logger get reset when we start to run either GoFSH or SUSHI so that the correct logger is used for each tool. This also lets other files, likeProcessing.js
, just import the logger once at the top and it will use the correct SUSHI or GoFSH logger, depending on which tool we are using.The second change that was needed was using the correct
stats
when creating the summary boxes. Now that we're using separate loggers at the right times, we should be using the stats from each of those loggers. So use the GoFSH stats in the GoFSH box and the SUSHI stats in the SUSHI box.To test this, you should create some FHIR JSON and run GoFSH and aim to get two types of errors/warnings: ones from GoFSH itself and directly from FSH Online. The stats in the summary should reflect how many errors/warnings you got from the run.
For example, how I tested this was with one JSON document that had a JSON error in it (this logs an error directly from FSH Online) and one JSON document with the following FSH in it (this logs a warning from GoFSH because
MyProfile
is not defined):This should log an error and a warning and have the correct total of both (with a correspondingly appropriate pun) in the summary box.