{"id":22989140,"url":"https://github.com/cookpad/daifuku","last_synced_at":"2025-06-26T03:33:31.056Z","repository":{"id":185770338,"uuid":"537370338","full_name":"cookpad/daifuku","owner":"cookpad","description":"A markdown parser and compiler for log definitions in mobile applications","archived":false,"fork":false,"pushed_at":"2023-08-04T10:24:13.000Z","size":665,"stargazers_count":32,"open_issues_count":0,"forks_count":2,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-06-22T01:14:47.264Z","etag":null,"topics":["logging","markdown","swift"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cookpad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-09-16T08:26:25.000Z","updated_at":"2024-11-28T09:35:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"97e967cd-8b26-4d81-9c64-6de66bfe26ab","html_url":"https://github.com/cookpad/daifuku","commit_stats":null,"previous_names":["cookpad/daifuku"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cookpad/daifuku","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cookpad%2Fdaifuku","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cookpad%2Fdaifuku/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cookpad%2Fdaifuku/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cookpad%2Fdaifuku/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cookpad","download_url":"https://codeload.github.com/cookpad/daifuku/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cookpad%2Fdaifuku/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261994415,"owners_count":23241998,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logging","markdown","swift"],"created_at":"2024-12-15T04:16:33.492Z","updated_at":"2025-06-26T03:33:30.993Z","avatar_url":"https://github.com/cookpad.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# daifuku\nA markdown parser and compiler for log definitions in mobile applications\n\n## Usage \nAutomatic generation of document-based type-safe log implementation code\n\n![Transpile](docs/images/transpile.png)\n\n### Step 1\nConsider log specifications and write documentation. \n\n- Syntax: [docs/syntax.ja.md](docs/syntax.ja.md)\n- Example: [example/LogDefinitions/recipe_search.md](./example/LogDefinitions/recipe_search.md)\n\n#### Log definition documents (Markdown)\n\n```md\n# recipe_search\n\nAn category of events related to recipe search.\n\n## search\n\nAn event sent when users perform a recipe search.\n\n- keyword: !string 256\n    - Search keyword\n- order: SearchOrder\n   - latest, popularity\n\n## show_recipe\n\nAn event sent when users move from the search results screen to the recipe details screen.\n\n- recipe_id: !integer\n    - ID of the selected recipe\n\n```\n\n### Step 2\n\nRun the script. \n\n- Example: [example/iOS/generate-log-classes.rb](./example/iOS/generate-log-classes.rb)\n\n```sh\nbundle install\nruby example/iOS/generate-log-classes.rb\n```\n\nAfter that, the following `.swift` files will be automatically generated.\n\n```sh\nls example/AutoGenerated \n# CommonPayload.swift  LogCategories.swift\n```\n\n#### Log definition code (Swift)\n\n```swift\n/// Events on the recipe search screen\npublic enum RecipeSearch: LogCategory {\n    /// An event sent when users perform a recipe search.\n    case search(keyword: String, order: SearchOrder)\n    ///  An event sent when users move from the search results screen to the recipe details screen.\n    case showRecipe(recipeId: Int64)\n}\n```\n\n### Step 3\n\nSend logs with the enums of the log definition.\n\n#### Log implementation code (Swift)\n\n```swift\n// After the search request \nlogger.post(\n    RecipeSearch.search(\n        keyword: keyword, // “egg\" \n        order: order // .latest\n    )\n)\n```\n\n## What makes you happy?\n\n### Fully documented at all times\nBecause of the way it works, you cannot implement logging without writing documentation. This means that there will always be documentation. \n\nHappy implementers and happy analysts 😊\n\n### Type safety\n#### No unintended values are introduced\n\nBecause the possible values, such as character limits, patterns, and numeric ranges, are guaranteed at the type level, it prevents unintended values from entering the log database.\n\n#### Comfortable to be complemented by IDE\n\nCompletion during implementation also improves the development experience and reduces mistakes.\n\n![Code Completion](docs/images/code-completion.png)\n\n### Easy to read for both humans and machines\n\nMarkdown is excellent as a format for log definition documents that anyone could easily read and write.\n\nIn addition, it was useful to be able to statically analyze both the definition document and the implementation.\n\nFor example, mistakes such as \"I defined it in the document but forgot to implement it\" could be detected automatically.\n\nThis mechanism has actually been useful several times in regular CI runs.\n(It was also useful to be able to notice when a log was accidentally deleted during refactoring, etc.).\n\n## Case Study\n\n### Git version control in the same repository as the app\nIn Cookpad (Japan), log definitions and mobile application source code are managed in the same git repository.\n\n#### Everything in one place (easy to find)\nIt is all in one place, so there is no need to wander around looking for information in logs.\n\n#### Background of log definitions can also be checked by following pull requests\n\nIt is also possible to run `git blame` on log markdown definitions and follow pull requests to find out which version of the log was added, who implemented the log, and with what intention.\n\n\n## Articles (Japanese)\n- ドキュメントベースの型安全なモバイルアプリ行動ログ基盤の構築 - クックパッド開発者ブログ https://techlife.cookpad.com/entry/2020/11/05/110000\n- モバイルアプリの行動ログの「仕込み」を快適にする https://speakerdeck.com/yujif/iosdc-japan-2022-mobile-app-logging\n\n## Original Author\n[@giginet](https://github.com/giginet)\n\n## Contributors\n[@hiragram](https://github.com/hiragram)\n[@litmon](https://github.com/litmon)\n[@ksfee684](https://github.com/ksfee684)\n[@aamine](https://github.com/aamine)\n[@vincentisambart](https://github.com/vincentisambart)\n[@kalupas226](https://github.com/kalupas226)\n[@yujif](https://github.com/yujif)\n\n## Contributing\nThis repo is basically *read-only*. We publish this code for knowledge sharing purposes.\nPlease note that we cannot guarantee continuous maintenance or responses to Issues or Pull Requests.\n\n## License\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcookpad%2Fdaifuku","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcookpad%2Fdaifuku","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcookpad%2Fdaifuku/lists"}