{"id":30554624,"url":"https://github.com/xnodeoncode/i45-jslogger","last_synced_at":"2026-01-20T17:01:49.395Z","repository":{"id":311777675,"uuid":"1045038003","full_name":"xnodeoncode/i45-jslogger","owner":"xnodeoncode","description":"A simple JavaScript logger for capturing events in the console and local storage.","archived":false,"fork":false,"pushed_at":"2025-12-19T20:53:35.000Z","size":155,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-22T09:03:29.395Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xnodeoncode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-26T15:05:37.000Z","updated_at":"2025-12-19T20:53:38.000Z","dependencies_parsed_at":"2025-08-26T18:56:23.965Z","dependency_job_id":"6012d3eb-35a8-42d1-bd1a-259ae67a9486","html_url":"https://github.com/xnodeoncode/i45-jslogger","commit_stats":null,"previous_names":["xnodeoncode/i45-jslogger"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xnodeoncode/i45-jslogger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xnodeoncode%2Fi45-jslogger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xnodeoncode%2Fi45-jslogger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xnodeoncode%2Fi45-jslogger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xnodeoncode%2Fi45-jslogger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xnodeoncode","download_url":"https://codeload.github.com/xnodeoncode/i45-jslogger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xnodeoncode%2Fi45-jslogger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28607624,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T16:10:39.856Z","status":"ssl_error","status_checked_at":"2026-01-20T16:10:39.493Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2025-08-28T04:14:20.208Z","updated_at":"2026-01-20T17:01:49.379Z","avatar_url":"https://github.com/xnodeoncode.png","language":"JavaScript","readme":"[NodeJS package](https://www.npmjs.com/package/i45-jslogger)\n\n[![npm version](https://img.shields.io/npm/v/i45-jslogger)](https://www.npmjs.com/package/i45-jslogger)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.9-blue)](https://www.typescriptlang.org/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nA browser based logger to track events during development and testing. Log entries are written to the console as well as stored in localStorage.\n\n## ⚠️ v2.0.0 Breaking Changes\n\n- **Event Namespacing**: CustomEvents now use `i45-logger:` prefix\n  - Old: `window.addEventListener(\"LOG\", ...)`\n  - New: `window.addEventListener(\"i45-logger:LOG\", ...)`\n- **Property Names**: Better, clearer names\n  - `enableEvents` → `enableDispatchEvents` (clearer what it controls)\n  - `enableLogging` → `loggingEnabled` (better grammar)\n- **Removed Exports**: `iLogger` and `iLoggerValidator` are no longer exported\n- **Removed Deprecated**: `clearEvents()` method removed (use `clearEventLog()`, `clearConsole()`, or `clearAll()`)\n- **Return Types**: `addClient()` and `removeClient()` return `boolean` instead of `0|1`\n\nSee [CHANGES.md](CHANGES.md) for full migration guide.\n\nSee [ROADMAP.md](docs/roadmap.md) to see future plans.\n\n## Environment Support\n\n- ✅ **Browser**: Full support with all features\n- ⚠️ **Node.js**: Limited support (no localStorage, no events)\n- ⚠️ **SSR (Next.js, Nuxt)**: Requires client-side initialization\n\nThe package now includes environment detection and won't crash in Node.js environments, but localStorage and CustomEvent features will be unavailable.\n\n## Contents\n\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [API Overview](#api-overview)\n- [Configuration](#configuration)\n- [Custom Logger Clients](#custom-logger-clients)\n- [Event Listeners](#event-listeners)\n- [Advanced Usage](#advanced-usage)\n\n## Installation\n\n```bash\nnpm i i45-jslogger\n```\n\n## Quick Start\n\n### Simple Usage (Default Instance)\n\n```javascript\nimport logger from \"i45-jslogger\";\n\nlogger.log(\"Basic log message\");\nlogger.info(\"This is an info message\");\nlogger.warn(\"This is a warning\");\nlogger.error(\"This is an error\");\n```\n\n### Multiple Instances\n\n```javascript\nimport { Logger } from \"i45-jslogger\";\n\n// Separate loggers for different purposes\nconst debugLogger = new Logger();\nconst analyticsLogger = new Logger();\n\ndebugLogger.info(\"Debug information\");\nanalyticsLogger.suppressConsole = true; // Only log to localStorage and clients\n```\n\n**Console output:**\u003cbr /\u003e\u003cbr /\u003e\n![Console output](https://raw.githubusercontent.com/xnodeoncode/i45-jslogger/master/docs/images/console.png)\n\n**localStorage output:**\u003cbr /\u003e\u003cbr /\u003e\n![Local storage](https://raw.githubusercontent.com/xnodeoncode/i45-jslogger/master/docs/images/local-storage.png)\n\n## API Overview\n\n### Logging Methods\n\nAll methods support method chaining and return `this`.\n\n```javascript\nlogger.log(\"message\", ...args); // Basic log\nlogger.info(\"message\", ...args); // Info level\nlogger.warn(\"message\", ...args); // Warning level\nlogger.error(\"message\", ...args); // Error level\n```\n\n### Client Management\n\n```javascript\nlogger.addClient(customLogger); // Returns: boolean\nlogger.removeClient(customLogger); // Returns: boolean\nlogger.clients(); // Returns: Array\nlogger.removeAllClients(); // Returns: this\n```\n\n### Event Management\n\n```javascript\nlogger.getEvents(); // Returns: Array of logged events\nlogger.clearEventLog(); // Clear localStorage events\nlogger.clearConsole(); // Clear browser console\nlogger.clearAll(); // Clear both\n```\n\n**Full API documentation available in [TypeScript definitions](src/logger.d.ts).**\n\n## Configuration\n\n### Properties\n\n```javascript\n// Enable/disable logging\nlogger.loggingEnabled = true; // Default: true\n\n// CustomEvent dispatching to window\nlogger.enableDispatchEvents = true; // Default: true\n\n// Suppress outputs\nlogger.suppressNative = false; // Skip localStorage/events (Default: false)\nlogger.suppressConsole = false; // Skip console output (Default: false)\n\n// Storage limits\nlogger.maxEvents = null; // Default: null (unlimited)\n// Set to positive integer to limit stored events (oldest are removed)\n// Set to 0 to prevent event storage entirely\n```\n\n### Console Filtering\n\nFilter by log levels in the browser console:\n\n![Logging levels](https://raw.githubusercontent.com/xnodeoncode/i45-jslogger/master/docs/images/logging-levels.png)\n\n## Custom Logger Clients\n\nAdd custom clients to pipe logs to APIs, files, or analytics services.\n\n### Client Interface\n\n```javascript\nconst customLogger = {\n  log: (message, ...args) =\u003e {\n    /* custom logic */\n  },\n  info: (message, ...args) =\u003e {\n    /* custom logic */\n  },\n  warn: (message, ...args) =\u003e {\n    /* custom logic */\n  },\n  error: (message, ...args) =\u003e {\n    /* custom logic */\n  },\n};\n\nlogger.addClient(customLogger); // Returns true if added successfully\n```\n\n### Example: API Logger\n\n```javascript\nconst apiLogger = {\n  log: (msg, ...args) =\u003e\n    fetch(\"/api/logs\", {\n      method: \"POST\",\n      body: JSON.stringify({ level: \"log\", msg, args }),\n    }),\n  info: (msg, ...args) =\u003e\n    fetch(\"/api/logs\", {\n      method: \"POST\",\n      body: JSON.stringify({ level: \"info\", msg, args }),\n    }),\n  warn: (msg, ...args) =\u003e\n    fetch(\"/api/logs\", {\n      method: \"POST\",\n      body: JSON.stringify({ level: \"warn\", msg, args }),\n    }),\n  error: (msg, ...args) =\u003e\n    fetch(\"/api/logs\", {\n      method: \"POST\",\n      body: JSON.stringify({ level: \"error\", msg, args }),\n    }),\n};\n\nlogger.addClient(apiLogger);\nlogger.info(\"User logged in\", { userId: 123 }); // Logs to console AND API\n```\n\n## Event Listeners\n\nSubscribe to log events using window CustomEvents with namespaced event names.\n\n### Available Events\n\nEvents are namespaced with `i45-logger:` prefix to prevent conflicts:\n\n```javascript\nwindow.addEventListener(\"i45-logger:LOG\", (event) =\u003e {\n  console.log(event.detail); // { message, args, timestamp }\n});\n\nwindow.addEventListener(\"i45-logger:INFO\", (event) =\u003e {\n  /* ... */\n});\nwindow.addEventListener(\"i45-logger:WARN\", (event) =\u003e {\n  /* ... */\n});\nwindow.addEventListener(\"i45-logger:ERROR\", (event) =\u003e {\n  /* ... */\n});\n```\n\n### Disable Events\n\n```javascript\nlogger.enableDispatchEvents = false; // Stop dispatching CustomEvents\n```\n\n## Advanced Usage\n\n### Use in Classes\n\n```javascript\nimport logger from \"i45-jslogger\";\n\nclass DataService {\n  #debug;\n\n  constructor(debug = false) {\n    this.#debug = debug;\n  }\n\n  fetchData() {\n    if (this.#debug) logger.info(\"Fetching data...\");\n\n    // ... fetch logic\n\n    if (this.#debug) logger.info(\"Data fetched successfully\");\n  }\n}\n```\n\n### Multiple Isolated Loggers\n\n```javascript\nimport { Logger } from \"i45-jslogger\";\n\n// Development logger\nconst devLog = new Logger();\ndevLog.enableLogging = process.env.NODE_ENV === \"development\";\n\n// Analytics logger (console suppressed)\nconst analyticsLog = new Logger();\nanalyticsLog.suppressConsole = true;\nanalyticsLog.addClient(analyticsClient);\n\n// Error tracking logger\nconst errorLog = new Logger();\nerrorLog.suppressNative = true;\nerrorLog.addClient(sentryClient);\n```\n\n### Testing with Isolated Instances\n\n```javascript\nimport { Logger } from \"i45-jslogger\";\n\ntest(\"logging disabled\", () =\u003e {\n  const logger = new Logger();\n  logger.enableLogging = false;\n\n  logger.info(\"test\"); // Won't log\n  expect(logger.getEvents()).toHaveLength(0);\n});\n```\n\n## TypeScript Support\n\nFull TypeScript definitions included:\n\n```typescript\nimport logger, { Logger, LoggerClient, LogEvent } from \"i45-jslogger\";\n\nconst customClient: LoggerClient = {\n  log: (msg) =\u003e console.log(msg),\n  info: (msg) =\u003e console.info(msg),\n  warn: (msg) =\u003e console.warn(msg),\n  error: (msg) =\u003e console.error(msg),\n};\n\nconst events: LogEvent[] = logger.getEvents();\n```\n\n## Contributing\n\nContributions welcome! Please see [CHANGES.md](CHANGES.md) for the full changelog and migration guides.\n\nPlanning for v3.0.0 is underway - see the [v3.0.0 roadmap](https://github.com/xnodeoncode/i45-jslogger/blob/master/docs/v3.0.0.md) for upcoming features.\n\n## License\n\nMIT\n\n## Links\n\n- [npm package](https://www.npmjs.com/package/i45-jslogger)\n- [GitHub repository](https://github.com/xnodeoncode/i45-jslogger)\n- [Changelog](CHANGES.md)\n- [TypeScript Definitions](src/logger.d.ts)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxnodeoncode%2Fi45-jslogger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxnodeoncode%2Fi45-jslogger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxnodeoncode%2Fi45-jslogger/lists"}