{"id":22556241,"url":"https://github.com/substrate-system/debug","last_synced_at":"2025-07-04T19:08:56.532Z","repository":{"id":204982339,"uuid":"712772428","full_name":"substrate-system/debug","owner":"substrate-system","description":"Debug utility","archived":false,"fork":false,"pushed_at":"2025-07-04T05:51:21.000Z","size":276,"stargazers_count":1,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-04T06:32:27.329Z","etag":null,"topics":["debug","logger"],"latest_commit_sha":null,"homepage":"https://substrate-system.github.io/debug/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/substrate-system.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2023-11-01T06:49:32.000Z","updated_at":"2025-07-04T05:51:17.000Z","dependencies_parsed_at":"2023-11-30T19:29:27.386Z","dependency_job_id":"dca1dbbc-d820-49c3-95e6-299892eeab6a","html_url":"https://github.com/substrate-system/debug","commit_stats":null,"previous_names":["nichoth/debug","bicycle-codes/debug","substrate-system/debug"],"tags_count":85,"template":false,"template_full_name":"nichoth/template-ts-browser","purl":"pkg:github/substrate-system/debug","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fdebug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fdebug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fdebug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fdebug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/substrate-system","download_url":"https://codeload.github.com/substrate-system/debug/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/substrate-system%2Fdebug/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263463876,"owners_count":23470448,"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":["debug","logger"],"created_at":"2024-12-07T19:11:41.206Z","updated_at":"2025-07-04T19:08:56.526Z","avatar_url":"https://github.com/substrate-system.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# debug\n![tests](https://github.com/substrate-system/debug/actions/workflows/nodejs.yml/badge.svg)\n[![module](https://img.shields.io/badge/module-ESM-blue?style=flat-square)](README.md)\n[![types](https://img.shields.io/npm/types/@substrate-system/debug?style=flat-square)](README.md)\n[![semantic versioning](https://img.shields.io/badge/semver-2.0.0-blue?logo=semver\u0026style=flat-square)](https://semver.org/)\n[![install size](https://flat.badgen.net/packagephobia/install/@substrate-system/debug)](https://packagephobia.com/result?p=@substrate-system/debug)\n[![license](https://img.shields.io/badge/license-Polyform_Non_Commercial-26bc71?style=flat-square)](LICENSE)\n\n\nA tiny JavaScript debugging utility that works in Node.js and browsers. Use environment variables to control logging, so there are no ridiculous console log statements in production.\n\nThis is based on [debug](https://github.com/debug-js/debug). It's been rewritten to use contemporary JS.\n\nIn the browser, this should work well with [vite](https://vite.dev/). As is\nconvention, this will look for an env variable prefixed with `VITE_`. So pass\nenv variables like `VITE_DEBUG=\"foo\"`.\n\n**Featuring:**\n* Use [exports](https://github.com/substrate-system/debug/blob/main/package.json#L31) field in `package.json` to choose node JS or browser version\n* ESM only\n\nPlus, [see the docs](https://substrate-system.github.io/debug/) generated by typescript.\n\n## Contents\n\n\u003c!-- toc --\u003e\n\n- [config](#config)\n  * [namespace](#namespace)\n  * [NODE_ENV + Vite](#node_env--vite)\n- [install](#install)\n- [Node JS](#node-js)\n  * [NODE_ENV](#node_env)\n- [develop](#develop)\n  * [browser](#browser)\n- [test](#test)\n  * [node](#node)\n\n\u003c!-- tocstop --\u003e\n\n## config\n\n### namespace\nWorks with `vite` or other systems. This will look at `import.meta.env`, or\nan arbitrary object you can pass in.\n\n```js\nimport Debug from '@substrate-system/debug'\n\n// look at `import.meta.env.VITE_DEBUG`\nconst debug = Debug('example')\n\n// or call with your own env object\nconst debug = Debug('example', { DEBUG: 'example' })\n```\n\nIf you create an instance without passing in a `namespace` string, then this\nwill log iff anything other than `false` is passed as an argument.\n\n```js\nimport Debug from '@substrate-system/debug'\n\n// log b/c we are not calling with `false`\nconst debug = Debug()\n\ndebug('hello')\n```\n\nYou can use any variable as debug status:\n\n```js\nimport Debug from '@substrate-system/debug'\n\n// in Vite\nconst debug = Debug(!!(import.meta.env \u0026\u0026 import.meta.env.DEV))\n\n// in an arbitrary server\nconst debug = Debug(window.EXAMPLE_DEBUG_MODE)\n```\n\nUse an env variable of `*` to log everything.\n\n\n### NODE_ENV + Vite\n\nBuild the site with a `NODE_ENV` variable to set `import.meta.env.DEV`:\n\n```sh\nNODE_ENV=development vite build\n```\n\nAny value of `NODE_ENV`, except `production`, wil equate to\n`import.meta.env.DEV` being true.\n\n```sh\nNODE_ENV=staging vite build\n```\n\n----------------------------------------------------------------------\n\n## install\n\n```sh\nnpm i -D @substrate-system/debug\n```\n\nUse this with [vite](https://vitejs.dev/) in the [browser](#browser), or\nin [node](#node-JS).\n\n\n------------------------------------------------------------------\n\n\n## Node JS\nRun your script with an env variable, `DEBUG`.\n\n```js\n// in node JS\nimport createDebug from '@substrate-system/debug/node'\nconst debug = createDebug('fooo')\ndebug('testing')\n```\n\nCall this with an env var of `DEBUG=fooo`\n```sh\nDEBUG=fooo node ./test/fixture/node.js\n```\n\n### NODE_ENV\nIf you are in dev mode (`process.env.NODE_ENV === 'development'`), then this will log things in a random color if you don't initialize it with a namespace --\n\n```js\nimport createDebug from '@substrate-system/debug'\nconst debug = createDebug()\ndebug('hello')\n```\n\nRun the script like this:\n```sh\nNODE_ENV=development node ./my-script.js\n```\n\n-------------------------------------------------------------------\n\n## develop\n\n### browser\nStart a `vite` server and log some things. This uses [the example directory](./example/).\n\n```sh\nnpm start\n```\n\n\n## test\n\n### node\nRun tests:\n\n```sh\nnpm test\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubstrate-system%2Fdebug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsubstrate-system%2Fdebug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsubstrate-system%2Fdebug/lists"}