{"id":13789897,"url":"https://github.com/otherguy/elysia-logging","last_synced_at":"2025-10-15T21:47:05.775Z","repository":{"id":203272455,"uuid":"707146050","full_name":"otherguy/elysia-logging","owner":"otherguy","description":"Logging middleware for ElysiaJS","archived":false,"fork":false,"pushed_at":"2024-10-18T05:38:59.000Z","size":227,"stargazers_count":20,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-19T14:43:45.408Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/otherguy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-19T10:11:05.000Z","updated_at":"2024-10-16T13:31:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"d2d9135f-0eed-483c-a1ed-3ac9a825b3e9","html_url":"https://github.com/otherguy/elysia-logging","commit_stats":{"total_commits":34,"total_committers":5,"mean_commits":6.8,"dds":0.4411764705882353,"last_synced_commit":"03670e8e6bd348bcb9a2f29a3ce1fec0f456cf05"},"previous_names":["otherguy/elysia-logging"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Felysia-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Felysia-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Felysia-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Felysia-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otherguy","download_url":"https://codeload.github.com/otherguy/elysia-logging/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542288,"owners_count":18242332,"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":[],"created_at":"2024-08-03T22:00:34.326Z","updated_at":"2025-10-15T21:47:00.725Z","avatar_url":"https://github.com/otherguy.png","language":"TypeScript","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"# @otherguy/elysia-logging\n\nAn advanced logging plugin designed for [Elysia.js](https://elysiajs.com), prioritizing structured logging tailored for production environments.\n\n\u003cp align=\"center\"\u003e\n\n  [![npm version](https://img.shields.io/npm/v/%40otherguy/elysia-logging?style=for-the-badge\u0026logo=npm)](https://www.npmjs.com/package/@otherguy/elysia-logging)\n  [![npm downloads](https://img.shields.io/npm/dm/%40otherguy/elysia-logging?style=for-the-badge\u0026logo=npm)](https://www.npmjs.com/package/@otherguy/elysia-logging)\n  [![Snyk Monitored](https://img.shields.io/badge/Snyk-Monitored-8A2BE2?style=for-the-badge\u0026logo=snyk)](https://snyk.io/test/github/otherguy/elysia-logging)\n  [![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/otherguy/elysia-logging/ci.yml?event=push\u0026style=for-the-badge\u0026logo=github)](https://github.com/otherguy/elysia-logging/actions/workflows/ci.yml)\n  [![GitHub License](https://img.shields.io/github/license/otherguy/elysia-logging?style=for-the-badge)](https://github.com/otherguy/elysia-logging/blob/main/LICENSE.md)\n  [![Code Climate Coverage](https://img.shields.io/codeclimate/coverage/otherguy/elysia-logging?style=for-the-badge\u0026logo=codeclimate)](https://codeclimate.com/github/otherguy/elysia-logging)\n  [![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/otherguy/elysia-logging?style=for-the-badge\u0026logo=codefactor)](https://www.codefactor.io/repository/github/otherguy/elysia-logging/)\n  [![Sonar CodeSmells](https://img.shields.io/sonar/violations/elysia-logging/main?server=https%3A%2F%2Fsonarcloud.io\u0026style=for-the-badge\u0026logo=sonarcloud\u0026label=Code%20Smells)](https://sonarcloud.io/project/overview?id=elysia-logging)\n\n\u003c/p\u003e\n\n---\n\n## 🌈 Features\n\n* **Structured Logging** - Log in JSON format for easy parsing and filtering\n* **Customizable** - Customize the log level, formatter and logger\n* **Production First** - Designed for production environments first\n\n## 🚀 Installation\n\n```bash\n# For bun\nbun add @otherguy/elysia-logging\n\n# For npm\nnpm install @otherguy/elysia-logging\n\n# For yarn\nyarn add @otherguy/elysia-logging\n```\n\n## 📚 Usage\n\nBy default, the plugin will log to the console using the `console` module. The default formatter is `json` and the default log level is `info`.\n\n```ts\nimport { Elysia } from \"elysia\";\nimport { ElysiaLogging } from \"../src/elysiaLogging\";\n\n// Create Elysia app\nconst app = new Elysia()\n  .use(ElysiaLogging())\n  .get(\"/\", () =\u003e {\n    return new Response(\"Welcome to Bun!\");\n  })\n  .listen(3000);\n\nconsole.log(`Running at http://${app.server?.hostname}:${app.server?.port}`);\n```\n\nUsing the default settings, the plugin will log the following for each request. Since the `console` module is pretty printing the JSON, the output in the console will be formatted slightly differently.\n\n```json\n{\n  \"message\": \"GET / completed with status 200 in 363.3µs\",\n  \"request\": {\n    \"ip\": \"127.0.0.1\",\n    \"method\": \"GET\",\n    \"url\": {\n      \"path\": \"/\",\n      \"params\": {}\n    }\n  },\n  \"response\": {\n    \"status_code\": 200,\n    \"time\": 363250\n  }\n}\n```\n\n### Custom Logger\n\nSince the `console` is very limited, you may want to use a custom logger. The recommended logger is [pino](https://github.com/pinojs/pino) but you can use any logger that can implement the `Logger` interface.\n\nSee the [examples](examples) directory for implementation examples.\n\n* [Pino](https://github.com/pinojs/pino) (see [example](examples/pino.ts))\n* [TSLog](https://tslog.js.org/) (see [example](examples/tslog.ts))\n* [Winston](https://github.com/winstonjs/winston) (see [example](examples/winston.ts))\n* [Bunyan](https://github.com/trentm/node-bunyan) (see [example](examples/bunyan.ts))\n\n## 🪜 Examples\n\nEven more examples are provided in the [`examples`](examples) directory.\n\n* [Basic](examples/basic.ts) - A basic example of using the plugin with the default settings\n* [JSON](examples/json.ts) - A basic example of logging in JSON\n* [Custom Function](examples/custom-function.ts) - An example of using a function as custom logging formatter\n* [On Error](examples/on-error.ts) - An example of logging errors in addition to access logging\n* [Pino](examples/pino.ts) - An example of using the [Pino](https://github.com/pinojs/pino) logger\n* [Pino Pretty](examples/pino.ts) - An example of using the [Pino](https://github.com/pinojs/pino) logger with [pino-pretty](https://github.com/pinojs/pino-pretty) _(not recommended for production)_\n* [TSLog](examples/tslog.ts) - An example of using the [TSLog](https://tslog.js.org/) logger\n* [Bunyan](examples/bunyan.ts) - An example of using the [Bunyan](https://github.com/trentm/node-bunyan) logger\n* [Winston](examples/winston.ts) - An example of using the [Winston](https://github.com/winstonjs/winston) logger\n\n## 📜 To Do\n\n* [ ] Add logger format classes\n* [ ] Add whitelist for request parameters\n\n## ⚖️ License\n\nThis project is distributed under the [MIT](LICENSE.md) license, allowing for open source distribution and modification, subject to the terms outlined in the [LICENSE.md](LICENSE.md) file.\n\n## 🚧 Contributing\n\nBug reports, feature requests and Pull Requests are more than welcome on GitHub at [`otherguy/elysia-logging`](https://github.com/otherguy/elysia-logging)! Please remember to add test coverage for your code if you are contributing.\n\n## ♥️ Acknowledgements\n\n* [SaltyAom](https://github.com/SaltyAom) for the [Elysia.js](https://elysiajs.com) framework.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotherguy%2Felysia-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotherguy%2Felysia-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotherguy%2Felysia-logging/lists"}