{"_id":"@anishsharma/betterlogs","_rev":"4-e869eecad25151904bd26ab031d18e2e","name":"@anishsharma/betterlogs","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@anishsharma/betterlogs","version":"1.0.0","keywords":["logging","console","logger","browser","node","typescript","pretty-logs","colored-logs","themes","emoji-logs"],"author":{"url":"https://github.com/anishdevtech","name":"Anish Sharma","email":"anishdev02@gmail.com"},"license":"MIT","_id":"@anishsharma/betterlogs@1.0.0","maintainers":[{"name":"anishsharma","email":"anish260308@gmail.com"}],"homepage":"https://github.com/anishdevtech/betterlogs#readme","bugs":{"url":"https://github.com/anishdevtech/betterlogs/issues"},"dist":{"shasum":"9fd0386ab47b2676165e48c08173953f275b940d","tarball":"https://registry.npmjs.org/@anishsharma/betterlogs/-/betterlogs-1.0.0.tgz","fileCount":16,"integrity":"sha512-b24rVWH2CNioOwVkKCQryxc4u/s5mAeXDUkSkOg8iSeRpgY+uFDPZRS3SkguftQqceE47OYmf+VZZnRaxzaThw==","signatures":[{"sig":"MEUCIQDSHRWzySbV7OuGRcbFSROm1DZ+jULr0IAvh7aAWv3z3QIgQ4Y8cVVs2paEiR67Qgc1EwDN/UDcPz5xGst2Ax/lM2s=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":59231},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"a2fbfab8585feba3265af7e3bcd9aa80ab99afea","scripts":{"dev":"tsup src/index.ts --format cjs,esm --dts --watch","lint":"eslint src --ext .ts","test":"vitest run","build":"tsup src/index.ts --format cjs,esm --dts --clean","test:ui":"vitest --ui","lint:fix":"eslint src --ext .ts --fix","test:watch":"vitest","test:coverage":"vitest run --coverage","prepublishOnly":"npm run build && npm test && npm run lint","test:coverage:html":"vitest run --coverage && open coverage/index.html","test:coverage:detailed":"vitest run --coverage --reporter=verbose"},"_npmUser":{"name":"anishsharma","email":"anish260308@gmail.com"},"repository":{"url":"git+https://github.com/anishdevtech/betterlogs.git","type":"git"},"_npmVersion":"10.9.3","description":"A lightweight yet powerful logging library that makes console output elegant, expressive, and customizable","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","jsdom":"^23.0.0","eslint":"^8.57.1","vitest":"^4.0.7","prettier":"^3.0.0","@vitest/ui":"^4.0.7","typescript":"^5.0.0","@types/node":"^20.0.0","@vitest/coverage-v8":"^4.0.7","@typescript-eslint/parser":"^8.46.3","@vitest/coverage-istanbul":"^4.0.7","@typescript-eslint/eslint-plugin":"^8.46.3"},"_npmOperationalInternal":{"tmp":"tmp/betterlogs_1.0.0_1762461792815_0.2846932774120492","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@anishsharma/betterlogs","version":"1.0.5","keywords":["logging","console","logger","browser","node","typescript","pretty-logs","colored-logs","themes","emoji-logs"],"author":{"url":"https://github.com/anishdevtech","name":"Anish Sharma","email":"anishdev02@gmail.com"},"license":"MIT","_id":"@anishsharma/betterlogs@1.0.5","maintainers":[{"name":"anishsharma","email":"anish260308@gmail.com"}],"homepage":"https://github.com/anishdevtech/betterlogs#readme","bugs":{"url":"https://github.com/anishdevtech/betterlogs/issues"},"dist":{"shasum":"e1416b5775af5cbf63cbc335711628a3b26360fb","tarball":"https://registry.npmjs.org/@anishsharma/betterlogs/-/betterlogs-1.0.5.tgz","fileCount":18,"integrity":"sha512-lZBWc6ep0+1LiiCcctxn/0ylqNDIVo1h64b2593F5Qa79xdMh1TalG1oLBmvYxZGtu/P+xdqWZME938fh2gykg==","signatures":[{"sig":"MEUCIQCP4/e9MElmI0QH6Ef4AKxSoyWSqtuX/K0XmnEypWfTyQIgEuznwNRGfiP1qAb3IKVhhtWyP9mOTOKf705ijbxmQZU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":71364},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.js"}},"gitHead":"40fd76439431f9e4e2ef5fa96ce725d7ab531408","scripts":{"lint":"eslint 'src/**/*.ts'","test":"vitest run","build":"tsup","format":"prettier --write .","lint:fix":"eslint 'src/**/*.ts' --fix","typecheck":"tsc --noEmit","format:check":"prettier --check .","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"anishsharma","email":"anish260308@gmail.com"},"repository":{"url":"git+https://github.com/anishdevtech/betterlogs.git","type":"git"},"_npmVersion":"10.9.3","description":"A lightweight yet powerful logging library that makes console output elegant, expressive, and customizable","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","jsdom":"^23.0.0","eslint":"^8.57.1","vitest":"^4.0.7","prettier":"^3.0.0","@vitest/ui":"^4.0.7","typescript":"^5.0.0","@types/node":"^20.0.0","@vitest/coverage-v8":"^4.0.7","@typescript-eslint/parser":"^8.46.3","@vitest/coverage-istanbul":"^4.0.7","@typescript-eslint/eslint-plugin":"^8.46.3"},"_npmOperationalInternal":{"tmp":"tmp/betterlogs_1.0.5_1766922370734_0.2797271316373342","host":"s3://npm-registry-packages-npm-production"}},"1.0.6":{"name":"@anishsharma/betterlogs","version":"1.0.6","keywords":["logging","console","logger","browser","node","typescript","pretty-logs","colored-logs","themes","emoji-logs","discord","discord-webhook","alerting","monitoring","error-tracking","production-logger"],"author":{"url":"https://github.com/anishdevtech","name":"Anish Sharma","email":"anishdev02@gmail.com"},"license":"MIT","_id":"@anishsharma/betterlogs@1.0.6","maintainers":[{"name":"anishsharma","email":"anish260308@gmail.com"}],"homepage":"https://github.com/anishdevtech/betterlogs#readme","bugs":{"url":"https://github.com/anishdevtech/betterlogs/issues"},"dist":{"shasum":"2a419f4a7e28f2b10b05260a5ad470027e2192a6","tarball":"https://registry.npmjs.org/@anishsharma/betterlogs/-/betterlogs-1.0.6.tgz","fileCount":18,"integrity":"sha512-nlYvPEhZxdY7tWHVeBog/y+aN4nw9JGLWT1r+Z+G19VfQJuz+a0oT8tUgU9RfDsbtb0rQci7YKrN36HEvSYXgQ==","signatures":[{"sig":"MEYCIQD6Y2Wt4p9Q5ST9apEIBFpd044excDzeCNYev6BkiLD6wIhAOsSY5ZtqbxoKPgfTZB7D+i8dSGIPfDouB01cVfsxNt0","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":71717},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=16.0.0"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"0aa37608f97db26f0dae259d2b675c2e5c8aadec","scripts":{"lint":"eslint 'src/**/*.ts'","test":"vitest run","build":"tsup","format":"prettier --write .","lint:fix":"eslint 'src/**/*.ts' --fix","typecheck":"tsc --noEmit","format:check":"prettier --check .","test:coverage":"vitest run --coverage"},"_npmUser":{"name":"anishsharma","email":"anish260308@gmail.com"},"repository":{"url":"git+https://github.com/anishdevtech/betterlogs.git","type":"git"},"_npmVersion":"10.9.3","description":"A lightweight yet powerful logging library that makes console output elegant, expressive, and customizable","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.0","jsdom":"^23.0.0","eslint":"^8.57.1","vitest":"^4.0.7","prettier":"^3.0.0","@vitest/ui":"^4.0.7","typescript":"^5.0.0","@types/node":"^20.0.0","@vitest/coverage-v8":"^4.0.7","@typescript-eslint/parser":"^8.46.3","@vitest/coverage-istanbul":"^4.0.7","@typescript-eslint/eslint-plugin":"^8.46.3"},"_npmOperationalInternal":{"tmp":"tmp/betterlogs_1.0.6_1766924121551_0.7713780371248757","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@anishsharma/betterlogs","version":"1.2.0","description":"A lightweight yet powerful logging library that makes console output elegant, expressive, and customizable","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","type":"module","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"scripts":{"test":"vitest run","test:coverage":"vitest run --coverage","build":"tsup","lint":"eslint \"src/**/*.ts\"","lint:fix":"eslint \"src/**/*.ts\" --fix","format":"prettier --write .","format:check":"prettier --check .","typecheck":"tsc --noEmit"},"llms":"./llms.txt","llmsFull":"./llms-full.txt","keywords":["logging","logger","console","browser","node","typescript","ai-ready","agent","mcp","cursor","zero-dependency","pretty-logs","colored-logs","themes","emoji-logs","pino-alternative","winston-alternative","consola-alternative","redaction","file-rotation","middleware","discord","slack","telegram","alerting","monitoring","error-tracking","production-logger"],"author":{"name":"Anish Sharma","email":"anishdev02@gmail.com","url":"https://github.com/anishdevtech"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/anishdevtech/betterlogs.git"},"homepage":"https://github.com/anishdevtech/betterlogs#readme","bugs":{"url":"https://github.com/anishdevtech/betterlogs/issues"},"engines":{"node":">=16.0.0"},"devDependencies":{"@types/node":"^20.0.0","@typescript-eslint/eslint-plugin":"^8.46.3","@typescript-eslint/parser":"^8.46.3","@vitest/coverage-istanbul":"^4.0.7","@vitest/coverage-v8":"^4.0.7","@vitest/ui":"^4.0.7","eslint":"^8.57.1","eslint-config-prettier":"^10.1.8","jsdom":"^23.0.0","prettier":"^3.0.0","tsup":"^8.0.0","typescript":"^5.0.0","vitest":"^4.0.7"},"gitHead":"a7c46b9d360f06bf799e3034eb0b45073096c5e2","_id":"@anishsharma/betterlogs@1.2.0","_nodeVersion":"24.14.1","_npmVersion":"11.11.0","dist":{"integrity":"sha512-vF5n5fv0Eu2P2oq2b/3fW2JABnU778VhiI13+RxsYl9e7WBoqC5HnWnuXsDpTiIqIRmJgwG7q1VAFv1m4VkBvg==","shasum":"1d391bcb1828c09a32162073264e8042cd70413f","tarball":"https://registry.npmjs.org/@anishsharma/betterlogs/-/betterlogs-1.2.0.tgz","fileCount":27,"unpackedSize":252235,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCICr8sVg5Hfs4qPCBrranAtD/rgqxbrQwXmdWWVYjBGI0AiEArLnVqoX4rBrOWMgCGP7yDiEttVbBICjoo62cuAPNX/4="}]},"_npmUser":{"name":"anishsharma","email":"anish260308@gmail.com"},"directories":{},"maintainers":[{"name":"anishsharma","email":"anish260308@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/betterlogs_1.2.0_1788017646018_0.20443396722264073"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-06T20:43:12.737Z","modified":"2026-08-29T15:34:06.308Z","1.0.0":"2025-11-06T20:43:13.022Z","1.0.5":"2025-12-28T11:46:10.871Z","1.0.6":"2025-12-28T12:15:21.700Z","1.2.0":"2026-08-29T15:34:06.161Z"},"bugs":{"url":"https://github.com/anishdevtech/betterlogs/issues"},"author":{"name":"Anish Sharma","email":"anishdev02@gmail.com","url":"https://github.com/anishdevtech"},"license":"MIT","homepage":"https://github.com/anishdevtech/betterlogs#readme","keywords":["logging","logger","console","browser","node","typescript","ai-ready","agent","mcp","cursor","zero-dependency","pretty-logs","colored-logs","themes","emoji-logs","pino-alternative","winston-alternative","consola-alternative","redaction","file-rotation","middleware","discord","slack","telegram","alerting","monitoring","error-tracking","production-logger"],"repository":{"type":"git","url":"git+https://github.com/anishdevtech/betterlogs.git"},"description":"A lightweight yet powerful logging library that makes console output elegant, expressive, and customizable","maintainers":[{"name":"anishsharma","email":"anish260308@gmail.com"}],"readme":"# BetterLogs\n\n[![npm version](https://img.shields.io/npm/v/@anishsharma/betterlogs.svg?color=cb3837&logo=npm)](https://www.npmjs.com/package/@anishsharma/betterlogs)\n[![npm downloads](https://img.shields.io/npm/dm/@anishsharma/betterlogs.svg?color=blue&logo=npm)](https://www.npmjs.com/package/@anishsharma/betterlogs)\n[![CI Tests](https://img.shields.io/github/actions/workflow/status/anishdevtech/betterlogs/test.yml?branch=main&label=CI&logo=github)](https://github.com/anishdevtech/betterlogs/actions)\n[![Codecov Coverage](https://img.shields.io/codecov/c/github/anishdevtech/betterlogs?logo=codecov)](https://codecov.io/gh/anishdevtech/betterlogs)\n[![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen.svg)](https://www.npmjs.com/package/@anishsharma/betterlogs)\n[![TypeScript](https://img.shields.io/badge/TypeScript-Strict-3178C6?logo=typescript&logoColor=white)](https://www.typescriptlang.org/)\n[![Node.js](https://img.shields.io/badge/Node.js-%3E%3D16.0.0-339933?logo=node.js&logoColor=white)](https://nodejs.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](./LICENCE)\n\nA fast, zero-dependency logger for Node.js, TypeScript, and browsers. Pretty terminal output in development, structured JSON in production, automatic secret redaction, and built-in Discord/Slack alerts.\n\n```bash\nnpm install @anishsharma/betterlogs\n```\n\n---\n\n## 30-Second Quickstart\n\n```ts\nimport log from '@anishsharma/betterlogs';\n\nlog.info('Server starting...');\nlog.ready('Listening on http://localhost:3000');\nlog.warn('Database query slow (240ms)');\nlog.error(new Error('Connection failed'));\n```\n\n**Terminal Output:**\n\n```text\n[20:45:10] 💡 INFO Server starting...\n[20:45:10] 🚀 READY Listening on http://localhost:3000\n[20:45:10] ⚠️  WARN Database query slow (240ms)\n[20:45:10] ❌ ERROR Connection failed\nError: Connection failed\n    at connect (/app/src/db.ts:42:11)\n```\n\n---\n\n## Why BetterLogs?\n\n- **Zero dependencies**: No bloated `node_modules` tree, no transitive security alerts.\n- **24-bit TrueColor themes**: Includes `dracula`, `nord`, `catppuccin`, `neon`, `dark`, `light`, and `minimal`. Respects `NO_COLOR` standards.\n- **Automatic secret & PII redaction**: Masks passwords, tokens, API keys, and authorization headers before output.\n- **Structured JSON & Pretty mode**: Human-readable colored logs locally, machine-parsable JSON in production.\n- **Drop-in console upgrade**: Call `log.patchConsole()` once to upgrade all `console.log` calls across an entire app.\n- **Zero-dependency file rotation**: Rotate logs by size (`10MB`) or date (`YYYY-MM-DD`) without extra packages.\n- **Built-in webhooks**: Direct transports for Discord, Slack, Telegram, and arbitrary HTTP endpoints.\n- **Universal**: Works in Node.js (CJS & ESM), browsers, Vite, Next.js, and Edge runtimes.\n\n---\n\n## Common Recipes\n\n### 1. Dev (Pretty) vs Production (JSON)\n\nSwitch modes using `process.env.NODE_ENV`:\n\n```ts\nlog.config({\n  mode: process.env.NODE_ENV === 'production' ? 'json' : 'pretty',\n  level: process.env.NODE_ENV === 'production' ? 'info' : 'debug',\n  theme: 'dracula'\n});\n\nlog.info('User logged in', { userId: 42 });\n```\n\n**Production JSON Output:**\n\n```json\n{\n  \"level\": \"info\",\n  \"message\": \"User logged in\",\n  \"timestamp\": \"2026-08-29T15:15:30.123Z\",\n  \"data\": [{ \"userId\": 42 }]\n}\n```\n\n---\n\n### 2. Automatic Secret Redaction\n\nPrevents accidental leakage of passwords, bearer tokens, API keys, and credit cards:\n\n```ts\nlog.config({\n  redaction: {\n    paths: ['password', 'token', 'authorization', '*.apiKey']\n  }\n});\n\nlog.info('Incoming request payload', {\n  username: 'alice',\n  password: 'mySecretPassword123',\n  headers: { authorization: 'Bearer eyJhbGciOi...' }\n});\n\n// Output: { username: 'alice', password: '[REDACTED]', headers: { authorization: '[REDACTED]' } }\n```\n\n---\n\n### 3. Upgrade Existing Codebases with `patchConsole()`\n\nUpgrade an existing project without rewriting hundreds of `console.log` calls:\n\n```ts\nimport log from '@anishsharma/betterlogs';\n\n// Put this in your app entry point (e.g. index.ts or server.ts)\nlog.patchConsole();\n\nconsole.log('Now formatted with timestamps and themes!');\nconsole.error('Errors now include clean stack traces');\n```\n\n---\n\n### 4. Express / Node HTTP Request Logger\n\nReplace heavy middleware packages with the built-in HTTP request logger:\n\n```ts\nimport express from 'express';\nimport log from '@anishsharma/betterlogs';\n\nconst app = express();\n\n// Logs: GET /api/users 200 in 14ms (color-coded by status)\napp.use(log.httpMiddleware());\n\napp.get('/api/users', (req, res) => {\n  res.json({ users: [] });\n});\n\napp.listen(3000, () => {\n  log.ready('Server running at http://localhost:3000');\n});\n```\n\n---\n\n### 5. Child Loggers & Module Scopes\n\nCreate sub-loggers with dedicated labels and metadata:\n\n```ts\nconst userLog = log.child({\n  label: 'UserService',\n  meta: { version: '2.0' }\n});\n\nuserLog.info('Password reset requested', { email: 'user@example.com' });\n// Output: [20:45:10] 💡 INFO [UserService] Password reset requested\n```\n\n---\n\n### 6. Discord & Slack Webhook Alerts\n\nForward warnings and errors to your team's alert channels:\n\n```ts\nimport { DiscordTransport, SlackTransport } from '@anishsharma/betterlogs';\n\n// Discord Webhook\nlog.addTransport(\n  new DiscordTransport({\n    webhookUrl: process.env.DISCORD_WEBHOOK_URL!,\n    filter: { minLevel: 'error' }\n  })\n);\n\n// Slack Webhook\nlog.addTransport(\n  new SlackTransport({\n    webhookUrl: process.env.SLACK_WEBHOOK_URL!,\n    channel: '#backend-alerts',\n    filter: { minLevel: 'error' }\n  })\n);\n\n// Normal error -> sent to Discord & Slack\nlog.error(new Error('Stripe payment gateway timeout'));\n\n// Force send or mute per call:\nlog.with({ discord: true }).success('Milestone: 10,000 active users reached!');\nlog.with({ discord: false }).error('Local test error only');\n```\n\n---\n\n### 7. Rotating Log Files (Node.js)\n\nSave logs to disk with automatic file rotation and retention cleanup:\n\n```ts\nlog.file('./logs/app.log', {\n  maxSize: '10MB', // Rotates when file reaches 10MB\n  maxFiles: 5, // Keeps latest 5 log files\n  datePattern: 'YYYY-MM-DD'\n});\n```\n\n---\n\n### 8. CLI Banners & Startup Boxes\n\nDraw clean terminal boxes for CLIs and scripts:\n\n```ts\nlog.box('BetterLogs CLI v1.0\\nReady on http://localhost:3000', {\n  title: 'Server Info',\n  borderColor: 'cyan',\n  borderStyle: 'rounded'\n});\n```\n\n---\n\n## API Summary\n\n| Method                                    | Description                                                   |\n| ----------------------------------------- | ------------------------------------------------------------- |\n| `log.info(msg, ...data)`                  | Info log                                                      |\n| `log.ready(msg, ...data)`                 | Readiness log (`🚀 READY`)                                    |\n| `log.start(msg, ...data)`                 | Task started log (`⏳ START`)                                 |\n| `log.success(msg, ...data)`               | Success log (`✅ SUCCESS`)                                    |\n| `log.warn(msg, ...data)`                  | Warning log (`⚠️ WARN`)                                       |\n| `log.error(err, ...data)`                 | Error log with formatted stack traces (`❌ ERROR`)            |\n| `log.fatal(err, ...data)`                 | Fatal exception log (`💀 FATAL`)                              |\n| `log.debug(msg, ...data)`                 | Debug log (`🔍 DEBUG`)                                        |\n| `log.trace(msg, ...data)`                 | Trace log (`🔬 TRACE`)                                        |\n| `log.child({ label, meta, level })`       | Creates an isolated child logger                              |\n| `log.with(meta)`                          | Attaches metadata or transport flags to a log                 |\n| `log.box(text, options)`                  | Renders a styled Unicode border box                           |\n| `log.time(label)` / `log.timeEnd(label)`  | Measures and returns execution time in ms                     |\n| `log.throttle({ limit, windowMs })`       | Returns a rate-limited logger instance                        |\n| `log.sample(rate)`                        | Returns a probabilistically sampled logger (e.g. `0.1` = 10%) |\n| `log.runWithContext(ctx, fn)`             | Injects request context via Node `AsyncLocalStorage`          |\n| `log.httpMiddleware(options)`             | Express / Node HTTP request logger                            |\n| `log.patchConsole()` / `unpatchConsole()` | Global console monkey-patching                                |\n| `log.config(options)`                     | Updates global configuration                                  |\n| `log.file(path, rotationOptions)`         | Enables file logging with optional rotation                   |\n| `log.addTransport(transport)`             | Adds a custom destination (Discord, Slack, HTTP, etc.)        |\n| `log.close()`                             | Flushes and closes file handles and transports                |\n\n---\n\n## Documentation\n\nFor full configuration options, custom theme creation, and advanced transport options, see [DOCUMENTATION.md](./DOCUMENTATION.md).\n\n## License\n\n[MIT](./LICENCE) © Anish Sharma\n","readmeFilename":"README.md"}