-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [DHIS2-12544] Add verbose logging to rules engine (#3480)
- Loading branch information
1 parent
4935fa0
commit 2a6d4a8
Showing
11 changed files
with
134 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,5 +230,5 @@ export type IConvertOutputRulesEffectsValue = {| | |
|}; | ||
|
||
export type Flag = { | ||
debug: boolean | ||
verbose: boolean, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...es/capture-core/components/RulesEngineVerboseInitializer/RulesEngineVerboseInitializer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// @flow | ||
import { useRuleEngineFlags } from '../../rules/useRuleEngineFlags'; | ||
|
||
type Props = {| | ||
children: React$Node, | ||
|}; | ||
export const RulesEngineVerboseInitializer = ({ children }: Props) => { | ||
useRuleEngineFlags(); | ||
|
||
return children; | ||
}; |
2 changes: 2 additions & 0 deletions
2
src/core_modules/capture-core/components/RulesEngineVerboseInitializer/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @flow | ||
export { RulesEngineVerboseInitializer } from './RulesEngineVerboseInitializer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// @flow | ||
import { useLayoutEffect } from 'react'; | ||
import { useLocationQuery } from '../utils/routing'; | ||
import { rulesEngine } from './rulesEngine'; | ||
|
||
export const useRuleEngineFlags = () => { | ||
// This hook is used to set the verbose flag on the rules engine | ||
// based on the verbose query param in the URL | ||
|
||
const { verbose } = useLocationQuery(); | ||
|
||
const updateFlags = (flags) => { | ||
rulesEngine.setFlags({ ...rulesEngine.getFlags(), ...flags }); | ||
}; | ||
|
||
useLayoutEffect(() => { | ||
if (verbose === 'true') { | ||
updateFlags({ verbose: true }); | ||
} else { | ||
updateFlags({ verbose: false }); | ||
} | ||
}, [verbose]); | ||
}; |