{"id":24612701,"url":"https://github.com/skoshx/human-logs","last_synced_at":"2026-03-08T18:31:44.902Z","repository":{"id":176711572,"uuid":"659378637","full_name":"skoshx/human-logs","owner":"skoshx","description":"🛠 A tiny log library that allows you to take events, explanations and solutions and connect them like lego-pieces to create user-friendly logs.","archived":false,"fork":false,"pushed_at":"2024-07-27T12:27:11.000Z","size":613,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-28T18:19:44.369Z","etag":null,"topics":["error-handling","human-friendly","logging","typescript"],"latest_commit_sha":null,"homepage":"https://human-logs.vercel.app","language":"TypeScript","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/skoshx.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}},"created_at":"2023-06-27T17:49:05.000Z","updated_at":"2024-07-27T12:27:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"6afa04c5-6149-4e33-8178-96b5d6bfd97a","html_url":"https://github.com/skoshx/human-logs","commit_stats":null,"previous_names":["skoshx/human-logs"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoshx%2Fhuman-logs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoshx%2Fhuman-logs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoshx%2Fhuman-logs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/skoshx%2Fhuman-logs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/skoshx","download_url":"https://codeload.github.com/skoshx/human-logs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252776480,"owners_count":21802462,"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":["error-handling","human-friendly","logging","typescript"],"created_at":"2025-01-24T20:25:03.595Z","updated_at":"2026-03-08T18:31:39.851Z","avatar_url":"https://github.com/skoshx.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n\t\u003cimg src=\"https://github.com/skoshx/human-logs/raw/main/docs/human-logs-logo.jpg\" /\u003e\n\u003c/p\u003e\n\n# human-logs\n\n[![npm version][npm-version-src]][npm-href]\n[![npm downloads][npm-downloads-src]][npm-href]\n[![Github Actions][github-actions-src]][github-actions-href]\n\n\u003e 🛠 A tiny log library that allows you to take events, explanations and solutions and connect them like lego-pieces to create user-friendly logs.\n\nGood log messages increases customer satisfaction, as they work as sort of a guide, helping the user achieve what they wanted to achieve. Good logs minimize the amount of support calls, improve customer satisfaction and trust in your product, ultimately being a win-win for both the creators of software and the users.\n\nInspired by Vercel's [Error design framework](https://vercel.com/design/error#error-design-framework), human-logs allows you to take events, explanations and solutions, and connect them like lego-pieces, to create user-friendly logs in a versatile manner.\n\n**Focus on understanding the errors.**\n\n## Features\n\n- Create consistent, helpful logs that help users fix the problem themselves\n- Build versatile errors by connecting events, explanations and solutions\n- Support for parameters: template variables into the log messages\n- Only 193 lines of code\n\n## 💻 Example Usage\n\nWe start by defining our `events`, `explanations`, and `solutions`. These will later be used in logs to create user-friendly errors, guiding the users to the right solution.\n\n```typescript\nimport { createHumanLogs, event, explanation, solution, createTextFormatter } from \"human-logs\"\n\nexport const notionError = createHumanLogs(\n  [\n    event(\"fetching_posts_failed\", \"fetching posts failed\", {\n      params: {},\n    }),\n    explanation(\n      \"missing_params\",\n      \"the {paramType} `{paramName}` is missing for post with ID `{postId}`, and no fallback was provided\",\n      {\n        params: {\n          paramType: \"\",\n          paramName: \"\",\n          postId: \"\",\n        },\n      }\n    ),\n    solution(\n      \"add_missing_param\",\n      \"add the missing {paramType} on your Notion page\",\n      {\n        params: {},\n      }\n    ),\n    solution(\n      \"provide_fallback\",\n      \"add a fallback to your parameter definition like this:\\n\\nurl(`{paramName}`, { fallback: `https://useflytrap.com` })\",\n      {\n        params: {\n          paramName: \"\",\n        },\n      }\n    ),\n\t\tsolution(\n      \"add_skip_missing_fields\",\n      \"if you want to skip posts that have missing fields, add `skipMissingFields`: true to your `fetchPosts` call like this: `notionSource.fetchPosts({ skipMissingFields: true })`\",\n      {\n        params: {},\n      }\n    ),\n    solution(\"open_issue\", \"open an issue for this on GitHub\", {\n      params: {},\n      actions: [\n        {\n          text: \"Open an issue\",\n          href: \"https://github.com/useflytrap/notion-contentlayer/issues/new\",\n        },\n      ],\n    }),\n  ],\n  {\n    formatter: createTextFormatter({\n      eventsPrefix: \"🚧 \",\n      solutionsPrefix: \"🛠️ \",\n    }),\n  }\n)\n\n// You can now use `notionError` to create user-friendly error logs, by connecting events, explanations and solutions like lego-blocks.\nconst errorLog = notionError([\n  \"fetching_posts_failed\",\n  \"missing_params\",\n  \"add_missing_param\",\n  \"provide_fallback\",\n  \"add_skip_missing_fields\",\n], {\n  // 👇 these are inferred like magic!\n  paramName: 'image',\n  paramType: 'Image',\n  postId: 'abcd-123',\n});\n\nconsole.log(errorLog.toString())\n/* =\u003e \"🚧 Fetching posts failed because the Image `image` is missing for post with ID `abcd-123`, and no fallback was provided.\n\n🛠️ Solutions:\n1) add the missing Image on your Notion page\n2) add a fallback to your parameter definition like this: url(`image`, { fallback: `https://useflytrap.com` })\n3) if you want to skip posts that have missing fields, add `skipMissingFields`: true to your `fetchPosts` call like this: `notionSource.fetchPosts({ skipMissingFields: true })`\"\n*/\n```\n\nWow! Look at how helpful those errors are. These are errors developers, product end-users and everyone in between could only DREAM OF.\n\n## 💻 Development\n\n- Clone this repository\n- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js \u003c 16.10)\n- Install dependencies using `pnpm install`\n- Run the tests using `pnpm dev`\n\n## License\n\nMade with ❤️ in Helsinki\n\nPublished under [MIT License](./LICENSE).\n\n\u003c!-- Links --\u003e\n\n[npm-href]: https://npmjs.com/package/human-logs\n[github-actions-href]: https://github.com/skoshx/human-logs/actions/workflows/ci.yml\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://badgen.net/npm/v/human-logs?color=black\n[npm-downloads-src]: https://badgen.net/npm/dw/human-logs?color=black\n[prettier-src]: https://badgen.net/badge/style/prettier/black?icon=github\n[github-actions-src]: https://github.com/skoshx/human-logs/actions/workflows/ci.yml/badge.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskoshx%2Fhuman-logs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskoshx%2Fhuman-logs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskoshx%2Fhuman-logs/lists"}