Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use separate SUSHI and GoFSH logger and stats #143

Merged
merged 2 commits into from
Sep 20, 2023

Conversation

jafeltra
Copy link
Collaborator

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, like Processing.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):

{
  "resourceType": "Patient",
  "id": "MyExample",
  "meta": {
    "profile": [
      "http://example.org/StructureDefinition/MyProfile"
    ]
  }
}

This should log an error and a warning and have the correct total of both (with a correspondingly appropriate pun) in the summary box.

- Stats for GoFSH runs were incorrect because the stats logs were
  using the stats from SUSHI. Use the correct stats for each tool.
- The logger messages that FSH Online logged were not always using
  the correct logger because SUSHI and GoFSH each have their own
  logger. Add a util export for the logger and a function to set the
  logger so that all FSH Online files can import one logger and have
  it set to the correct logger, depending on which tool is running.
  Set the logger when each tool runs.
Copy link
Member

@cmoesel cmoesel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent. I really like the approach to switching loggers since we're only ever doing one direction at a time.

@cmoesel cmoesel merged commit 5eb833e into master Sep 20, 2023
4 checks passed
@cmoesel cmoesel deleted the separate-loggers-and-stats branch September 20, 2023 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants