{"id":24498187,"url":"https://github.com/nyxb/consolji","last_synced_at":"2026-05-11T07:33:41.729Z","repository":{"id":162225434,"uuid":"636815311","full_name":"nyxb/consolji","owner":"nyxb","description":"😁 Easily log console messages in Node.js and the browser with this sleek and sophisticated logger.","archived":false,"fork":false,"pushed_at":"2023-06-17T14:32:26.000Z","size":1155,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-23T04:20:25.864Z","etag":null,"topics":["beutiful","cli","console","fancy","log","node","terminal"],"latest_commit_sha":null,"homepage":"https://nyxb.xyz","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/nyxb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":["nyxb"]}},"created_at":"2023-05-05T17:58:36.000Z","updated_at":"2024-12-15T08:41:11.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc313e94-5f33-431b-b7ee-04fe8adf98ef","html_url":"https://github.com/nyxb/consolji","commit_stats":null,"previous_names":["nyxb/consolji"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/nyxb/consolji","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyxb%2Fconsolji","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyxb%2Fconsolji/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyxb%2Fconsolji/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyxb%2Fconsolji/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nyxb","download_url":"https://codeload.github.com/nyxb/consolji/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nyxb%2Fconsolji/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266496399,"owners_count":23938711,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["beutiful","cli","console","fancy","log","node","terminal"],"created_at":"2025-01-21T22:10:45.983Z","updated_at":"2026-05-11T07:33:41.651Z","avatar_url":"https://github.com/nyxb.png","language":"TypeScript","funding_links":["https://github.com/sponsors/nyxb"],"categories":[],"sub_categories":[],"readme":"[![cover][cover-src]][cover-href]\n[![npm version][npm-version-src]][npm-version-href] \n[![npm downloads][npm-downloads-src]][npm-downloads-href] \n[![bundle][bundle-src]][bundle-href] \n[![License][license-src]][license-href]\n\n\u003e 🧙‍♂️ Magical Console Wrapper with Conventional💙Commits\n\n## 🤔 Why Consolji?\n\n🌟 Consolji's Enchanting Features:\n\n- ✨  Effortless to use\n- 🎩  Captivating output with graceful fallbacks\n- 🔮  Enchanting reporters to suit your needs\n- 💻  Seamless command line experience\n- 🏷️  Tag support for organized logging\n- 🌐  Cross-platform compatibility, including browsers\n- ⏯️  Pause and resume logging as needed\n- 🎭  Embrace the power of log mocking\n- 🚫  Prevent log spam with sorcery of throttling\n- 🔁  Intercept and redirect console and stdout/stderr with ease\n- 💙  [Full conventional💙Commit support](https://github.com/conventional-emoji-commits)\n- 🔮 Interactive prompt support with the magic of [tyck](https://github.com/nyxblabs/tyck)\n\n## 💻 Installation:\nUsing [nyxi](https://github.com/nyxb/nyxi)\n\n```bash\n# nyxi\nnyxi consolji\n\n# pnpm\npnpm add consolji\n\n# npm\nnpm i consolji\n\n# yarn\nyarn add consolji\n```\n\n## 🚀 Getting Started\n\n```ts\n// ESM\nimport { consolji, createConsolji } from 'consolji'\n\n// CommonJS\nconst { consolji, createConsolji } = require('consolji')\n\nconsolji.info('Using consolji 0.0.1')\nconsolji.start('Building project...')\nconsolji.warn('🥳 consolji is published: 0.0.1')\nconsolji.success('Project built!')\nconsolji.error(new Error('This is an example error. Everything is fine!'))\nawait consolji.prompt('Deploy to the production?', {\n   type: 'confirm',\n})\n```\n\n🖥️ Will display in the terminal:\n\n\u003cimg width=\"760\" alt=\"image\" src=\".github/assets/example.png\"\u003e\n\n📦 You can use smaller core builds without fancy reporter to save 80% of the bundle size:\n\n```ts\nimport { consolji, createconsolji } from 'consolji/basic'\nimport { consolji, createconsolji } from 'consolji/browser'\nimport { createconsolji } from 'consolji/core'\n```\n\n## 📚 consolji Methods\n\n#### 📝 `\u003ctype\u003e(logObject)` 📝 `\u003ctype\u003e(args...)`\n\nLog to all reporters.\n\nExample: `consolji.info('Message')`\n\n#### ⏳ `await prompt(message, { type })`\n\n🔠 Show an input prompt. Type can be one of `text`, `confirm`, `select`, or `multiselect`.\n\nSee [📂 examples/prompt.ts](./examples/prompt.ts) for usage examples.\n\n#### ➕ `addReporter(reporter)`\n\n- Aliases: ➕ `add`\n\nRegister a custom reporter instance.\n\n#### ➖ `removeReporter(reporter?)`\n\n- Aliases: ➖ `remove`, ➖ `clear`\n\nRemove a registered reporter.\n\nIf no arguments are passed all reporters will be removed.\n\n#### 🔄 `setReporters(reporter|reporter[])`\n\nReplace all reporters.\n\n#### 🔧 `create(options)`\n\nCreate a new `consolji` instance and inherit all parent options for defaults.\n\n#### 🛠️ `withDefaults(defaults)`\n\nCreate a new `consolji` instance with provided defaults\n\n#### 🏷️ `withTag(tag)`\n\n- Aliases: 🏷️ `withScope`\n\nCreate a new `consolji` instance with that tag.\n\n#### 🔄 `wrapConsole()` ⏪ `restoreConsole()`\n\nGlobally redirect all `console.log`, etc calls to consolji handlers.\n\n#### 🔄 `wrapStd()` ⏪ `restoreStd()`\n\nGlobally redirect all stdout/stderr outputs to consolji.\n\n#### 🔄 `wrapAll()` ⏪ `restoreAll()`\n\nWrap both, std and console.\n\nconsole uses std in the underlying so calling `wrapStd` redirects console too.\nBenefit of this function is that things like `console.info` will be correctly redirected to the corresponding type.\n\n#### ⏸️ `pauseLogs()` ▶️ `resumeLogs()`\n\n- Aliases: ⏸️ `pause`/▶️ `resume`\n\n**Globally** ⏸️ pause and ▶️ resume logs.\n\nconsolji will enqueue all logs when paused and then sends them to the reported when resumed.\n\n#### 🃏 `mockTypes`\n\n- Aliases: 🃏 `mock`\n\nMock all types. Useful for using with tests.\n\nThe first argument passed to `mockTypes` should be a callback function accepting `(typeName, type)` and returning the mocked value:\n\n```ts\nconsolji.mockTypes((typeName, type) =\u003e jest.fn())\n```\n\nPlease note that with the example above, everything is mocked independently for each type. If you need one mocked fn create it outside:\n\n```ts\nconst fn = jest.fn()\nconsolji.mockTypes(() =\u003e fn)\n```\n\nIf callback function returns a _falsy_ value, that type won't be mocked.\n\nFor example if you just need to mock `consolji.fatal`:\n\n```ts\nconsolji.mockTypes(typeName =\u003e typeName === 'fatal' \u0026\u0026 jest.fn())\n```\n\n**NOTE:** Any instance of 🃏 consolji that inherits the mocked instance will apply the provided callback again. This way, mocking works for 🏷️ `withTag` scoped loggers without the need for extra efforts.\n\n## 📝 Custom Reporters\n\n😁 consolji ships with 3 built-in reporters out of the box. A fancy colored reporter by default and fallsback to a basic reporter if running in a testing or CI environment detected using [nyxblabs/envizor](https://github.com/nyxblabs/envizor) and a basic browser reporter.\n\nYou can create a new reporter object that implements `{ log(logObject): () =\u003e { } }` interface.\n\n**Example:** Simple JSON reporter 📝\n\n```ts\nimport { createconsolji } from 'consolji'\n\nconst consolji = createconsolji({\n   reporters: [\n      {\n         log: (logObj) =\u003e {\n            console.log(JSON.stringify(logObj))\n         },\n      },\n   ],\n})\n\n// Prints {\"date\":\"2023-04-18T12:43:38.693Z\",\"args\":[\"foo bar\"],\"type\":\"log\",\"level\":2,\"tag\":\"\"}\nconsolji.log('foo bar')\n```\n\n## 📊 Log Level\n\n😁 consolji only shows logs with configured log level or below. (Default is `3`)\n\n📊 Available log levels:\n\n- `0`: ❗️ Fatal and Error\n- `1`: ⚠️ Warnings\n- `2`: ℹ️ Normal logs\n- `3`: ✨ Informational logs, success, fail, ready, start, ...\n- `4`: 🐞 Debug logs\n- `5`: 🕵️ Trace logs\n- `-999`: 🔇 Silent\n- `+999`: 🔊 Verbose logs\n\n📊 You can set the log level by either:\n\n- 🛠️ Passing `level` option to `createconsolji`\n- 🔄 Setting `consolji.level` on instance\n- 🌐 Using the `consolji_LEVEL` environment variable (not supported for browser and core builds).\n\n## 📝 Log Types\n\nLog types are exposed as `consolji.[type](...)` and each is a preset of styles and log level.\n\nA list of all available built-in types is [available here](./src/constants.ts).\n\n## 🧪 Creating a new instance\n\n😁 consolji has a global instance and is recommended to use everywhere.\nIn case more control is needed, create a new instance.\n\n```ts\nimport { createconsolji } from 'consolji'\n\nconst logger = createconsolji({\n   // level: 4,\n   // fancy: true | false\n   // formatOptions: {\n   //     columns: 80,\n   //     colors: false,\n   //     compact: false,\n   //     date: false,\n   // },\n})\n```\n\n## 🛠️ Integrations\n\n### With 🃏 jest or 🌱 vitest\n\n```ts\ndescribe('your-consolji-mock-test', () =\u003e {\n   beforeAll(() =\u003e {\n      // Redirect std and console to consolji too\n      // Calling this once is sufficient\n      consolji.wrapAll()\n   })\n\n   beforeEach(() =\u003e {\n      // Re-mock consolji before each test call to remove\n      // calls from before\n      consolji.mockTypes(() =\u003e jest.fn())\n   })\n\n   test('your test', async () =\u003e {\n      // Some code here\n\n      // Let's retrieve all messages of `consolji.log`\n      // Get the mock and map all calls to their first argument\n      const consoljiMessages = consolji.log.mock.calls.map(c =\u003e c[0])\n      expect(consoljiMessages).toContain('your message')\n   })\n})\n```\n\n### With 🌐 jsdom\n\n```ts\n{\n   virtualConsole: new jsdom.VirtualConsole().sendTo(consolji)\n}\n```\n\n## 📜 License\n\n[MIT](./LICENSE) - Made with 💞\n\n\u003c!-- Badges --\u003e\n\n[npm-version-src]: https://img.shields.io/npm/v/consolji?style=flat\u0026colorA=18181B\u0026colorB=14F195\n[npm-version-href]: https://npmjs.com/package/consolji\n[npm-downloads-src]: https://img.shields.io/npm/dm/consolji?style=flat\u0026colorA=18181B\u0026colorB=14F195\n[npm-downloads-href]: https://npmjs.com/package/consolji\n[bundle-src]: https://img.shields.io/bundlephobia/minzip/consolji?style=flat\u0026colorA=18181B\u0026colorB=14F195\n[bundle-href]: https://bundlephobia.com/result?p=consolji\n[license-src]: https://img.shields.io/github/license/nyxblabs/consolji.svg?style=flat\u0026colorA=18181B\u0026colorB=14F195\n[license-href]: https://github.com/nyxblabs/consolji/blob/main/LICENSE\n\n\u003c!-- Cover --\u003e\n[cover-src]: https://raw.githubusercontent.com/nyxblabs/consolji/main/.github/assets/cover-github-consolji.png\n[cover-href]: https://💻nyxb.ws\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyxb%2Fconsolji","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnyxb%2Fconsolji","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnyxb%2Fconsolji/lists"}