From b9a46852b50590db960046c0c81571a7b388048e Mon Sep 17 00:00:00 2001 From: KaelynJefferson <106775284+KaelynJefferson@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:06:11 -0400 Subject: [PATCH] console debug log level (#190) * adding debug level selection * adding debug logger level functionality, added test and modify impacted tests * adding unit test for checking debug when running sushi --------- Co-authored-by: Chris Moesel --- src/App.jsx | 7 ++ src/components/FSHControls.jsx | 22 +++- src/utils/FSHHelpers.js | 8 +- src/utils/logger.js | 3 +- tests/components/FSHControls.test.jsx | 167 ++++++++++++++++++++++++-- 5 files changed, 188 insertions(+), 19 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 9fdd47e..2929a98 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -166,6 +166,7 @@ export default function App(props) { const [configToShare, setConfigToShare] = useState({ canonical: '', version: '', fhirVersion: [], dependencies: '' }); const [sharedConfig, setSharedConfig] = useState({}); const [isLineWrapped, setIsLineWrapped] = useState(false); + const [isDebugConsoleChecked, setIsDebugConsoleChecked] = useState(false); useEffect(() => { async function waitForFSH() { @@ -267,6 +268,10 @@ export default function App(props) { setIsLineWrapped(wrapSelected); } + function setDebugConsoleChecked(debugSelected) { + setIsDebugConsoleChecked(debugSelected); + } + function debouncedMove(clientX) { if (isDragging) { const newPercentage = (clientX / window.innerWidth) * 100; @@ -365,6 +370,8 @@ export default function App(props) { saveAll={saveAll} setIsLineWrapped={setLineWrap} isLineWrapped={isLineWrapped} + setIsDebugConsoleChecked={setDebugConsoleChecked} + isDebugConsoleChecked={isDebugConsoleChecked} />
diff --git a/src/components/FSHControls.jsx b/src/components/FSHControls.jsx index c7e838b..dfcb281 100644 --- a/src/components/FSHControls.jsx +++ b/src/components/FSHControls.jsx @@ -177,6 +177,11 @@ export default function FSHControls(props) { props.setIsLineWrapped(isLineWrappedChecked); }; + const updateConsoleMessageLevel = (event) => { + const isDebugConsoleChecked = event.target.checked; + props.setIsDebugConsoleChecked(isDebugConsoleChecked); + }; + async function handleSUSHIClick() { if (props.isWaiting) { // If SUSHI or GoFSH is in the middle of processes, don't do anything @@ -193,7 +198,12 @@ export default function FSHControls(props) { FSHOnly: true, fhirVersion: fhirVersion ? [fhirVersion] : ['4.0.1'] }; - const outPackage = await runSUSHI(props.fshText, config, parsedDependencies); + const outPackage = await runSUSHI( + props.fshText, + config, + parsedDependencies, + props.isDebugConsoleChecked ? 'debug' : 'info' + ); let jsonOutput = JSON.stringify(outPackage, replacer, 2); if (outPackage && outPackage.codeSystems) { if ( @@ -239,7 +249,7 @@ export default function FSHControls(props) { } const options = { dependencies: parsedDependencies, indent: isGoFSHIndented }; - const { fsh, config } = await runGoFSH(gofshInputStrings, options); + const { fsh, config } = await runGoFSH(gofshInputStrings, options, props.isDebugConsoleChecked ? 'debug' : 'info'); props.onGoFSHClick(fsh, false); setIsGoFSHRunning(false); if (canonical === '' && config.canonical) setCanonical(config.canonical); @@ -401,6 +411,14 @@ export default function FSHControls(props) { onChange={updateLineWrapping} /> If set, FSH Online will display code with line wrapping + } + label="Debug level console messages" + onChange={updateConsoleMessageLevel} + /> + If set, FSH Online will display debug level messages within the console