{"id":29143473,"url":"https://github.com/appsaeed/loggest","last_synced_at":"2025-06-30T20:07:36.212Z","repository":{"id":300409561,"uuid":"1006127184","full_name":"appsaeed/loggest","owner":"appsaeed","description":"A flexible logging utility package","archived":false,"fork":false,"pushed_at":"2025-06-28T17:08:42.000Z","size":248,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-28T17:36:20.596Z","etag":null,"topics":["javascript","logger","ndoejs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/appsaeed.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2025-06-21T14:56:04.000Z","updated_at":"2025-06-28T17:08:45.000Z","dependencies_parsed_at":"2025-06-21T14:59:26.467Z","dependency_job_id":"f949b01d-71ab-4d6f-9c1f-6704f7cd55a5","html_url":"https://github.com/appsaeed/loggest","commit_stats":null,"previous_names":["appsaeed/loggest"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/appsaeed/loggest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsaeed%2Floggest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsaeed%2Floggest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsaeed%2Floggest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsaeed%2Floggest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appsaeed","download_url":"https://codeload.github.com/appsaeed/loggest/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appsaeed%2Floggest/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262473408,"owners_count":23316878,"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":["javascript","logger","ndoejs"],"created_at":"2025-06-30T20:07:35.287Z","updated_at":"2025-06-30T20:07:36.166Z","avatar_url":"https://github.com/appsaeed.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fast \u0026 Pluggable logger\n\n\u003e A flexible, minimalistic logging utility package — fast and pluggable.\n\n### ✨ Features\n\n- ⚡ Fast and lightweight\n- 🔌 Plugin-based logging (File, Console, API, Custom)\n- 🧩 Custom log drivers (e.g., database, HTTP)\n- 🗃️ File and remote/API logging\n- 🧠 Context-aware and structured logs\n- 🎚️ Filterable and configurable log levels\n\nIncludes everything needed for structured logging, while remaining small and dependency-free.\n\n## 📦 Installation\n\n```bash\nnpm install loggest\n```\n\n## 🚀 Basic Usage\n\nA logger instance can be initialized with one or more plugins to control how logs are processed.\n\n### Inline Plugin Example\n\n```ts\nimport { Logger } from \"loggest\";\n\nconst logger = new Logger({\n  plugins: [\n    {\n      handle: function (level, context, message, ...optional) {\n        console.log(level, message, ...optional);\n      },\n    },\n  ],\n});\n\nlogger.info({ name: \"app\", version: \"1.x\" });\nlogger.info(\"Application started\", \"additional context\");\n```\n\n### Using Imported Plugins\n\n```ts\nimport { Logger } from \"loggest\";\nimport FileLog from \"loggest/dist/plugins/FileLog\";\n\nconst logger = new Logger({\n  plugins: [new FileLog()],\n});\n\nlogger.info({ name: \"app\", version: \"1.x\" });\nlogger.info(\"Application started\", \"additional context\");\n```\n\nPlugins can be mixed and matched, and custom implementations can also be added as needed. See the [Available Plugins](#-available-plugins) section for more examples.\n\n## ⚙️ Advanced Configuration\n\n```ts\nimport Logger from \"loggest\";\nimport FileLog from \"loggest/dist/plugins/FileLog\"\nimport ApiLog from \"loggest/dist/plugins/ApiLog\"\n\nconst logger = new Logger({\n\t// customize level defalut: info, warn, error, debug, log.\n\tlevels: [\"info\", \"warn\"] //now only will log info, warn.\n\tplugins: [\n\t\tnew ApiLog({ url: \"https://example.com/logs\" }),\n\t\t//other plugins\n\t],\n\tcontext: { app: \"my-app\", env: \"production\" } // context object (optional),\n\tformat: (level, ctx, msg, ...rest) =\u003e `New message: ${msg}`,\n\tfilter: (level, ctx, msg, ...rest) =\u003e level !== \"warn\" // avoid warn log,\n});\n```\n\n## 📋 Available Plugins\n\nThe logger includes several built-in plugins for common logging use cases:\n\n- `FileLog` – Writes logs to a file.\n- `FetchLog` – Sends logs to an external HTTP endpoint.\n- `ConsoleLog` – Outputs logs to the console.\n- `CustomLog` – Allows defining custom behavior via plugin.\n\nCustom plugins can be created using either an object or a class.\n\n### 🔧 Object-based Plugin Example\n\n```ts\nconst CustomLogger = {\n  /**\n   * Handle the plugin log\n   */\n  handle: async (level: LogLevel, ctx, message: any, ...optional: any[]) =\u003e {\n    // Custom handling logic: store in a database, send to an API, etc.\n  },\n};\n```\n\n### Class-based Plugin Example\n\n```ts\nexport class ColoredConsoleLog {\n  /**\n   * Handle the plugin log\n   */\n  async handle(level, ctx, message, ...optional) {\n    const colorMap = {\n      info: \"\\x1b[36m\", // Cyan\n      warn: \"\\x1b[33m\", // Yellow\n      error: \"\\x1b[31m\", // Red\n      debug: \"\\x1b[90m\", // Gray\n    };\n    console.log(`${colorMap[level] || \"\"}${level}:`, message, ...optional);\n  }\n}\n```\n\n### ✅ Registering Plugins\n\n```ts\nconst logger = new Logger({\n  plugins: [new ColoredConsoleLog(), CustomLogger],\n});\n\nlogger.info(\"Server started successfully\");\n```\n\n### 🧩 Plugin Interface for TypeScript\n\nTo enable type checking and IntelliSense support, implement the `Plugin` interface:\n\n```ts\nimport { LogLevel, Plugin } from \"loggest\";\n\nexport class MyLogger implements Plugin {\n  //handle the plugin log\n  async handle(level: LogLevel, ctx: any, message: any, ...optional: any[]): Promise\u003cvoid\u003e {\n    // Custom logic for handling log output\n  }\n}\n```\n\n## 🤝 Contributing\n\nContributions are welcome! Feel free to open issues or submit pull requests.\n\n1. Fork the repo\n2. Create a branch\n3. Commit changes\n4. Open a PR\n\nLet’s improve this project together!\n\n## 📄 License\n\nMIT License — Saeed Hosan\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsaeed%2Floggest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappsaeed%2Floggest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappsaeed%2Floggest/lists"}