{"_id":"@burakbey/pino-mongodb","_rev":"4-a6baa4576dbcd1170b0e2ebf21105a24","name":"@burakbey/pino-mongodb","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.1":{"name":"@burakbey/pino-mongodb","version":"1.0.1","keywords":["pino","mongodb","pino-mongodb"],"license":"MIT","_id":"@burakbey/pino-mongodb@1.0.1","maintainers":[{"name":"burakbey","email":"rectfc@gmail.com"}],"homepage":"https://github.com/BUR4KBEY/pino-mongodb#readme","bugs":{"url":"https://github.com/BUR4KBEY/pino-mongodb/issues"},"dist":{"shasum":"00fccf9cf1a397b2e89642faf2f647e5ea0a0c64","tarball":"https://registry.npmjs.org/@burakbey/pino-mongodb/-/pino-mongodb-1.0.1.tgz","fileCount":11,"integrity":"sha512-0gMm/LDX+rf7SnQUkf+cqgJnMBQPibT2MiPZyWN8fMG1CeLecRvxSWMwEHL5WU6dRmM5CPBy5n+BUvBskU40vQ==","signatures":[{"sig":"MEUCIHatO0qwFmicxTHEI+v6SNRHTyVfOqEI+4EZa/ipC45eAiEA+y6BqEYGxk5DP5rVFq7i3vWzXIiYk/l7JgqIMcjDCYw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":9537},"main":"dist/index.js","gitHead":"f7845d0d3ed625cd9de2d9398b360b5e2cc827e7","scripts":{"build":"tsc -p .","clean":"rimraf dist","prebuild":"yarn clean"},"typings":"dist/index.d.ts","_npmUser":{"name":"burakbey","email":"rectfc@gmail.com"},"repository":{"url":"git+https://github.com/BUR4KBEY/pino-mongodb.git","type":"git"},"_npmVersion":"9.5.1","description":"[**@burakbey/pino-mongodb**](https://npmjs.org/package/@burakbey/pino-mongodb) is a package that enables you to save logs from pino to MongoDB, offering a convenient method to store your application's logs.","directories":{},"_nodeVersion":"18.16.1","dependencies":{"mongodb":"^5.7.0"},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"^5.0.1","typescript":"^5.1.6","@types/node":"^20.4.2"},"_npmOperationalInternal":{"tmp":"tmp/pino-mongodb_1.0.1_1689456782317_0.4683485435976207","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@burakbey/pino-mongodb","version":"1.0.2","main":"dist/index.js","typings":"dist/index.d.ts","license":"MIT","devDependencies":{"@types/node":"^20.4.2","rimraf":"^5.0.1","typescript":"^5.1.6"},"dependencies":{"mongodb":"^5.7.0"},"scripts":{"build":"tsc -p .","clean":"rimraf dist","prebuild":"yarn clean"},"keywords":["pino","mongodb","pino-mongodb"],"repository":{"type":"git","url":"git+https://github.com/BUR4KBEY/pino-mongodb.git"},"bugs":{"url":"https://github.com/BUR4KBEY/pino-mongodb/issues"},"homepage":"https://github.com/BUR4KBEY/pino-mongodb#readme","funding":"https://burakbey.dev","_id":"@burakbey/pino-mongodb@1.0.2","gitHead":"92e08b77390ca1c5e4b68a5acbe54df5710db322","description":"[**@burakbey/pino-mongodb**](https://npmjs.org/package/@burakbey/pino-mongodb) is a package that enables you to save logs from pino to MongoDB, offering a convenient method to store your application's logs.","_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"integrity":"sha512-+V2WaVw+k4TkNZ/w3LJIdarp3xcEqvR/hp9TSWzCnRbshgSrPsIsb/dRqU+yoXcVTu+czalN99FZ01+zFQVz/A==","shasum":"2d1e42641b734cc206fb8f53389c3f0d68d4fa55","tarball":"https://registry.npmjs.org/@burakbey/pino-mongodb/-/pino-mongodb-1.0.2.tgz","fileCount":11,"unpackedSize":9943,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAhlDW2edvZnWZwdZqjMM2zoFJF+CZKB9CMh/ENLFh9fAiAa7K15qhtdwI9sXiAeSd7kxDRYeIbMRCntsDRzJoirnA=="}]},"_npmUser":{"name":"burakbey","email":"rectfc@gmail.com"},"directories":{},"maintainers":[{"name":"burakbey","email":"rectfc@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/pino-mongodb_1.0.2_1720922533330_0.3829553557697898"},"_hasShrinkwrap":false}},"time":{"created":"2023-07-15T21:33:01.683Z","modified":"2024-07-14T02:02:13.676Z","1.0.0":"2023-07-15T21:28:48.004Z","1.0.1":"2023-07-15T21:33:02.574Z","1.0.2":"2024-07-14T02:02:13.489Z"},"bugs":{"url":"https://github.com/BUR4KBEY/pino-mongodb/issues"},"license":"MIT","homepage":"https://github.com/BUR4KBEY/pino-mongodb#readme","keywords":["pino","mongodb","pino-mongodb"],"repository":{"type":"git","url":"git+https://github.com/BUR4KBEY/pino-mongodb.git"},"description":"[**@burakbey/pino-mongodb**](https://npmjs.org/package/@burakbey/pino-mongodb) is a package that enables you to save logs from pino to MongoDB, offering a convenient method to store your application's logs.","maintainers":[{"name":"burakbey","email":"rectfc@gmail.com"}],"readme":"# @burakbey/pino-mongodb 🎄\n\n[**@burakbey/pino-mongodb**](https://npmjs.org/package/@burakbey/pino-mongodb) is a package that enables you to save logs from pino to MongoDB, offering a convenient method to store your application's logs.\n\n## Installation 🚀\n\nTo get started, use your preferred package manager to install the **@burakbey/pino-mongodb** package.\n\n```\nyarn install @burakbey/pino-mongodb\n```\n\n## Implementation 🛠️\n\nUsing **@burakbey/pino-mongodb** is straightforward. Simply import the `getWritableStream` function and use it as a stream in your code, as shown in the examples below.\n\n```ts\nimport pino from 'pino';\n\nimport { getWritableStream } from '@burakbey/pino-mongodb';\n\nasync function bootstrap() {\n  const mongodbStream = await getWritableStream({\n    connectionUri: 'mongodb://localhost:27017',\n    collectionName: 'logs',\n    dbName: 'logs'\n  });\n\n  const logger = pino(\n    { level: 'info' },\n    pino.multistream([{ stream: process.stdout }, { stream: mongodbStream }])\n  );\n\n  logger.info('hello');\n}\n\nbootstrap();\n```\n\nYou can also customize the default formatter to suit your needs, giving you the flexibility to modify the log data before it is stored in the MongoDB instance. This includes controlling how the timestamp is converted and making any other desired modifications to the log entries.\n\n```ts\nimport pino from 'pino';\n\nimport { FormatFunction, getWritableStream } from '@burakbey/pino-mongodb';\n\nconst customFormat: FormatFunction = chunk => {\n  const result = chunk\n    .split('\\n')\n    .filter(x => x)\n    .map(x => JSON.parse(x))\n    .map(x => {\n      // do whatever you want here\n      // if (x.time) {\n      //   x.time = new Date(x.time);\n      // }\n\n      return x;\n    });\n\n  return result;\n};\n\nasync function bootstrap() {\n  const mongodbStream = await getWritableStream({\n    connectionUri: 'mongodb://localhost:27017',\n    collectionName: 'logs',\n    dbName: 'logs',\n    format: customFormat\n  });\n\n  const logger = pino(\n    { level: 'info' },\n    pino.multistream([{ stream: process.stdout }, { stream: mongodbStream }])\n  );\n\n  logger.info('hello');\n}\n\nbootstrap();\n```\n\nWith **@burakbey/pino-mongodb**, you can easily save and manage your application logs in a MongoDB database. Enjoy streamlined log management for your projects! ✨\n\n## ☕ Support\n\nIf you find this project useful and would like to support [me](https://github.com/BUR4KBEY), you can do so by visiting [my website](https://burakbey.dev).\n\n<a href=\"https://burakbey.dev\" target=\"_blank\"><img src=\"https://burakbey.dev/github_support_snippet.png\" style=\"height: 56px !important;width: 200px !important;\" alt=\"Buy me a coffee\"></img></a>\n","readmeFilename":"README.md"}