{"_id":"@alkeshgupta/logguard","name":"@alkeshgupta/logguard","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@alkeshgupta/logguard","version":"1.0.0","description":"LogGuard — styled, toggleable logging for Browser & Node","type":"module","main":"dist/index.js","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"require":"./dist/index.cjs","default":"./dist/index.cjs"}},"scripts":{"build":"tsup src/index.ts","dev":"ts-node -r tsconfig-paths/register src/example.ts","test":"vitest","prepare":"npm run build"},"keywords":["logging","console","debug","log","logger","logguard"],"author":{"name":"Alkesh Gupta"},"license":"MIT","devDependencies":{"ts-node":"^10.0.0","tsconfig-paths":"^4.0.0","tsup":"^6.7.0","typescript":"^5.0.0","vitest":"^1.0.0"},"repository":{"type":"git","url":"git+https://github.com/thealkeshgupta/LogGuard.git"},"bugs":{"url":"https://github.com/thealkeshgupta/LogGuard/issues"},"homepage":"https://github.com/thealkeshgupta/LogGuard#readme","gitHead":"6c67a5586058614f2e58766258cca2731c2848b7","_id":"@alkeshgupta/logguard@1.0.0","_nodeVersion":"20.19.4","_npmVersion":"11.6.2","dist":{"integrity":"sha512-3i6x7c/l90wWdIt0r20iXArTAJ1g1r8CwiJSeBISzU++a+wcNmFUcWtvMcW5zgTtSQlAoWPeEdu7j5j7jBllXA==","shasum":"a402629bff20ce53c27beb4dacc793aced7e1108","tarball":"https://registry.npmjs.org/@alkeshgupta/logguard/-/logguard-1.0.0.tgz","fileCount":8,"unpackedSize":56080,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIGVy/FmB3LUZxV+uQeiNumDRMVTkoPdzmv9WIF5ZP2OgAiEAnH8h2Dh9XJr9mHrIJqBdXIrRRJvdfy2idGfp5/ES/Io="}]},"_npmUser":{"name":"alkeshgupta","email":"thealkeshgupta@gmail.com"},"directories":{},"maintainers":[{"name":"alkeshgupta","email":"thealkeshgupta@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/logguard_1.0.0_1762706534046_0.9976559353877901"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-09T16:42:13.927Z","1.0.0":"2025-11-09T16:42:14.258Z","modified":"2025-11-09T16:42:14.582Z"},"maintainers":[{"name":"alkeshgupta","email":"thealkeshgupta@gmail.com"}],"description":"LogGuard — styled, toggleable logging for Browser & Node","homepage":"https://github.com/thealkeshgupta/LogGuard#readme","keywords":["logging","console","debug","log","logger","logguard"],"repository":{"type":"git","url":"git+https://github.com/thealkeshgupta/LogGuard.git"},"author":{"name":"Alkesh Gupta"},"bugs":{"url":"https://github.com/thealkeshgupta/LogGuard/issues"},"license":"MIT","readme":"# @alkeshgupta/LogGuard\n\nA **next-generation**, **developer-friendly logging** library for Node.js and browsers. LogGuard makes logging **easy, beautiful**, and **configurable** with **themes, tags, timestamps, caller info**, and **a single toggle to enable/disable logging**.\n\n---\n\n## ✨ Features\n\n- Level-based Logging: `trace`, `debug`, `info`, `success`, `warn`, `error`.\n- Single Switch Enable/Disable: Turn off all logs in production with a simple config change\n- Themes & Styles: Fully customizable themes for browser & terminal: `minimal`, `forest`, `neon`, `candy`, `cyberpunk`, `ocean`, `sunset`, `retro`\n- Tags Support: Suggestion-based tags like log.tags.DB and log.tags.AUTH. Only enabled tags are printed.\n- Timestamps & Caller Info: Optional timestamps and caller info for quick debugging.\n- Cross-Environment Support: Works seamlessly in Node.js and React/browser.\n- Flexible Configuration: Global settings through `logguard.config.js` or dynamically via `log.setConfig()`.\n\n---\n\n## 📦 Installation\n\n```bash\nnpm install @alkeshgupta/logguard\n```\n\nor\n\n```bash\nyarn add @alkeshgupta/logguard\n```\n\n---\n\n## 📝 Basic Usage\n\n### 🧠 Node.js\n\n```js\nconst { log } = require(\"@alkeshgupta/logguard\");\n\nlog.trace(\"Trace message\");\nlog.debug(\"Debug message\");\nlog.info(\"Info message\");\nlog.success(\"Operation successful!\");\nlog.warn(\"Warning issued\");\nlog.error(\"An error occurred\");\n```\n\n---\n\n### ⚛️ React Usage Example\n\nWorks anywhere inside your components.\n\n```js\nimport {log} from \"@alkeshgupta/logguard\";\nimport { useEffect } from \"react\";\nimport config from \"../logguard.config\";\n\nuseEffect(() => {\n  // Dynamic config in browser\n  log.setConfig(config);\n\n  log.success(\"App Mounted Successfully!\");\n  log.info(, \"Database connected\");\n}, []);\n```\n\n---\n\n## ⚙️ Configuration (`logguard.config.js`)\n\nLogGuard can be fully customized through a `logguard.config.js` file in your project root. This allows you to control log levels, themes, timestamps, caller info, and tag behavior across Node.js and browser environments.\n\n### Example Configuration\n\n```js\nexport default {\n  logGuardEnabled: true,            // Single Point of Enablement/Disablement of logs\n  loglevel: \"debug\",                // Minimum level of logs to display\n  timestamp: {\n    show: true,                     // Show timestamps in logs\n    utc: false                      // Use UTC time format (true) or local time (false)\n  },\n  caller: {\n    show: true                      // Display caller info (file & line number)\n  },\n  theme: \"minimal\",                 // Theme for log styling: minimal, forest, neon, candy, cyberpunk, ocean, sunset, retro\n  tags: {\n    show: true\n    allowed: [\"DB\", \"AUTH\", \"API\"], // Tags which the user wants to use\n    enabled: [\"DB\", \"API\"]          // Only logs with these enabled tags will be printed\n  }\n};\n```\n\n---\n\n## Detailed Option Description\n\n| Option            | Type                                                                    | Default   | Description                                                                                                                              |\n| ----------------- | ----------------------------------------------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------- |\n| `logGuardEnabled` | boolean                                                                 | `true`    | Directly enable/disable all the logs.                                                                                                    |\n| `loglevel`        | string (`trace` \\| `debug` \\| `info` \\| `success` \\| `warn` \\| `error`) | `debug`   | Minimum level of logs that will be printed. All levels above this will also be shown.                                                    |\n| `timestamp.show`  | boolean                                                                 | `true`    | Whether to display timestamps for each log message.                                                                                      |\n| `timestamp.utc`   | boolean                                                                 | `false`   | If true, timestamps are shown in UTC; otherwise, local time is used.                                                                     |\n| `caller.show`     | boolean                                                                 | `true`    | Whether to display the caller file and line number for each log. Only the last folder, file name and line number are shown for brevity.  |\n| `theme`           | string                                                                  | `minimal` | Theme for styling logs in both Node and browser. Options: `minimal`, `forest`, `neon`, `candy`, `cyberpunk`, `ocean`, `sunset`, `retro`. |\n| `tags.show`       | boolean                                                                 | `true`    | Whether to display the tag for each log.                                                                                                 |\n| `tags.allowed`    | array of strings                                                        | `[]`      | Tags which the user wants to use. It's recommended to mention the used tags in here for peers to know.                                   |\n| `tags.enabled`    | array of strings                                                        | `[]`      | Only logs with these enabled tags will be printed. If a log is sent with a tag not in this list, it will be ignored.                     |\n\n---\n\n## ✅ Enable / Disable Logging\n\n- Enable all logs: `logGuardEnabled: true`\n\n- Disable all logs: `logGuardEnabled : false` — perfect for production!\n\n---\n\n## 🎨 Themes\n\n- Available for Node and Browser: `minimal`, `forest`, `neon`, `candy`, `cyberpunk`, `ocean`, `sunset`, `retro`\n\n- Each theme comes with custom colors for every log level, both for text and background.\n\n---\n\n## 🔖 Tags\n\nUse tags for categorizing logs:\n\n```js\nlog.success(\"DB\", \"Database initialized\"); // Here, the tag is \"DB\"\nlog.warn(\"AUTH\", \"Unauthorized login attempt\"); // And here, its \"AUTH\"\n```\n\n- Available for Node and Browser: `minimal`, `forest`, `neon`, `candy`, `cyberpunk`, `ocean`, `sunset`, `retro`\n\n- Each theme comes with custom colors for every log level, both for text and background.\n\n---\n\n### Notes\n\n1. **Dynamic Configuration**: You can also override these settings at runtime in React or browser projects using:\n\n```javascript\nlog.setConfig({\n  loglevel: \"warn\",\n  timestamp: { show: false },\n  caller: { show: true },\n  ...\n});\n```\n\n2. **Tags Behavior**:\n\n   - **Suggested tags**: Listed in `allowed` Tags for peers to know.\n   - **Enabled tags**: Only these tags are printed to the console. Logs without a tag are always printed.\n\n3. **Themes**:\n\n   - Themes affect **both browser and Node** styling.\n   - Each theme defines **text colors and background colors** for each log level.\n\n4. **Log Level Hierarchy**:\n\n```\ntrace < debug < info < success < warn < error\n```\n\nSetting `loglevel: \"info\"` will **skip trace and debug logs**.\n\n---\n\n## ⚡ Why LogGuard?\n\n- **Unified experience**: Same config for Node and Browser.\n- **Clean and readable logs**: Colored badges, optional timestamps, and caller info.\n- **Developer productivity**: Tags based filtering, themes, and log level management.\n- **Production-ready**: Single toggle to disable logs without touching code.\n\n---\n\n## 📄 License\n\nMIT License © 2025 Alkesh Gupta \\\nFeel free to use, modify, and distribute.\n\n---\n\n## ⭐ Support\n\nIf you like this library, consider:\n\n- leaving a [GitHub](https://github.com/thealkeshgupta/LogGuard) & [npm]() star ⭐\n- reporting issues\n- contributing ideas\n","readmeFilename":"README.md","_rev":"1-f963a00eeabec73027206d878e7006ec"}