{"id":18753236,"url":"https://github.com/kpn/nuxt-pino-log","last_synced_at":"2025-04-13T00:31:34.158Z","repository":{"id":37904123,"uuid":"452361702","full_name":"kpn/nuxt-pino-log","owner":"kpn","description":"Structured logs for nuxt apps using pino","archived":false,"fork":false,"pushed_at":"2023-08-04T13:49:20.000Z","size":217,"stargazers_count":10,"open_issues_count":5,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-04T21:09:47.535Z","etag":null,"topics":["error-handling","logging","nuxt","nuxt-module","pino"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kpn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-01-26T16:55:24.000Z","updated_at":"2023-12-20T20:05:54.000Z","dependencies_parsed_at":"2023-01-17T17:31:21.270Z","dependency_job_id":null,"html_url":"https://github.com/kpn/nuxt-pino-log","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpn%2Fnuxt-pino-log","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpn%2Fnuxt-pino-log/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpn%2Fnuxt-pino-log/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kpn%2Fnuxt-pino-log/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kpn","download_url":"https://codeload.github.com/kpn/nuxt-pino-log/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650590,"owners_count":21139670,"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":["error-handling","logging","nuxt","nuxt-module","pino"],"created_at":"2024-11-07T17:24:55.662Z","updated_at":"2025-04-13T00:31:33.641Z","avatar_url":"https://github.com/kpn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NUXT-PINO-LOG\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![License][license-src]][license-href]\n\n\u003e Add pinoJS logs to nuxt\n\n[📖 **Release Notes**](./CHANGELOG.md)\n\n## Why pinoJS?\n\n- Server and browser support\n- Fast\n- Easy to use and setup\n- JSON structured logs\n\n## Setup\n\n1. Add `nuxt-pino-log` dependency to your project\n\n```bash\nyarn add nuxt-pino-log\n```\n\n```bash\nnpm install nuxt-pino-log\n```\n\n2. Add `nuxt-pino-log` to the `modules` section of `nuxt.config.js`\n\n```js\n// nuxt.config.js\n{\n  modules: [\n    // Simple usage\n    'nuxt-pino-log',\n\n    // With options\n    ['nuxt-pino-log', { /* module options */ }]\n  ]\n}\n```\n\n## Usage\n\n1. In nuxt middleware\n\n```js\nexport default ({ $logger }) =\u003e {\n  // This will be appear in the browser and server terminal\n  $logger.info('Logging in middleware')\n}\n```\n\n2. In nuxt component, store and pages\n\n```js\nthis.$logger.info('Logging')\n```\n\nSee the [example](./example) folder for more.\n\n## Configuration\n\n1. Following are the default configurations provided to the logger:\n\n```js\ndefaults = {\n    disabled: false,\n    disableClientSide: false,\n    disableServerSide: false,\n    skipRequestMiddlewareHandler: false,\n    skipErrorMiddlewareHandler: false,\n    clientOptions: {\n      browser: {\n        asObject: true\n      }\n    }\n  }\n```\n\n2. The above default configurations can be customized by passing options through `nuxt.config.js` file as following:\n\n```js\nnuxtPinoLog: {\n    // To disable all the logging\n    disabled: true,\n\n    // To disable client side loggging\n    disableClientSide: true,\n\n    // To disable server side logging\n    disableServerSide: true,\n\n    // Settings to determine if default handlers should be\n    // registered for requests and errors respectively.\n    // Set to `true` to skip request logging\n    skipRequestMiddlewareHandler: true,\n    // Set to `true` to skip error logging\n    skipErrorMiddlewareHandler: true,\n\n    clientOptions: {\n        // configure pino client with the configrations from https://github.com/pinojs/pino/blob/master/docs/browser.md\n    },\n    serverOptions: {\n      // configure pino server logger with the configrations from https://github.com/pinojs/pino/blob/master/docs/browser.md\n    },\n    // configure `pino-http`, see more https://github.com/pinojs/pino-http\n    pinoHttpOptions: {\n      serializers: {\n        res: (res) =\u003e ({\n          statusCode: res.statusCode,\n        }),\n      }\n    }\n  },\n```\n\n## Headers redaction\n\nYou may want to redact some headers, that you don't want to appear in the logs.\n`nuxt-pino-log` provides a default list that you can use and even extend.\n\nExample:\n\n```js\n// nuxt.config.js\nconst { redactDefault } = require(\"nuxt-pino-log\");\n\nmodule.exports = {\n  nuxtPinoLog: {\n    serverOptions: {\n      name: \"Logger\",\n      redact: redactDefault,\n    }\n  }\n}\n```\n\n## Pretty logs\n\nBecause the logs are json, during development you may want to make them prettier and\nmore developer friendly. You can use `pino-pretty` for that.\n\n```bash\nyarn add --dev pino-pretty\n```\n\nConfigure your dev in your `package.json`\n\n```js\n// package.json\n{\n  \"scripts\": {\n    \"dev\": \"nuxt example | pino-pretty\"\n  }\n}\n```\n\n## Contributing\n\n1. Clone this repository\n2. Install dependencies using `yarn install` or `npm install`\n3. Start development server using `npm run dev`\n\n## License\n\n[MIT License](./LICENSE)\n\nCopyright (c) KPN\n\n\u003c!-- Badges --\u003e\n[npm-version-src]: https://img.shields.io/npm/v/nuxt-pino-log/latest.svg\n[npm-version-href]: https://npmjs.com/package/nuxt-pino-log\n\n[npm-downloads-src]: https://img.shields.io/npm/dt/nuxt-pino-log.svg\n[npm-downloads-href]: https://npmjs.com/package/nuxt-pino-log\n\n[license-src]: https://img.shields.io/npm/l/nuxt-pino-log.svg\n[license-href]: https://npmjs.com/package/nuxt-pino-log\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpn%2Fnuxt-pino-log","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkpn%2Fnuxt-pino-log","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkpn%2Fnuxt-pino-log/lists"}