A structured, testable system for defining, validating, and documenting logging events using Jsonnet.
This repository provides a central source of truth for CIO mobile SDKs log definitions across features and platforms.
- Each feature has its own
.jsonnetdefinition underfeatures/<feature-name>/ - These files are compiled into machine-readable
.jsonfiles - Each feature has a corresponding docs generated under
/docsdirectory - Unit tests verify the structure and content of each feature’s output
.jsonfiles
.
├── features/ # Jsonnet definitions per feature
│ ├── push/
│ │ └── push.jsonnet
│ ├── init/
│ │ └── core.jsonnet
│ └── ...
├── generated/ # Compiled JSON output
│ └── json/
│ └── push/
│ └── push.json
│ └── mermaid/
│ └── push/
│ └── push.mmd
├── docs/ # Docs for each feature
│ ├── ...
├── scripts/ # Helper scripts
│ ├── ...
├── __tests__/ # Jest unit tests per feature
│ ├── ...
Install dependencies for building and testing:
brew install jsonnet
npm installRun the build script to generate .json files from all .jsonnet files in the features/ directory:
npm run generateJsonRun the build script to generate .mmd diagrams from all .json files in the generated/json directory:
npm run generateDiagramsRun the build script to generate .md docs from all .json files in the generated/json directory:
npm run generateMarkdownDocsCheck that all .jsonnet files have corresponding .json outputs:
npm run validateGenerationYou can also run npm run generate to generate all JSON, Mermaid diagrams and docs using a single convenience command.
To define a new logging feature:
- Create a
.jsonnetfile underfeatures/<your-feature>/ - Run
npm run generateJsonto generate the.jsonfile - Run
npm run generateDiagramsto generate the.mmdfile - Run
npm run generateMarkdownDocsto generate.mddocs files - Add a test under
__tests__/<your-feature>.test.js - Run
npm testto validate
Each .jsonnet feature must have a corresponding Jest test file under __tests__/ that:
- Verifies required keys
- Checks for uniqueness of IDs
- Ensures optional fields like
success,error,nextare valid if present
Run all tests:
npm testMIT