{"_id":"@austonpramodh/s3-streamlogger-ts","_rev":"4-e298825a05e62fb6874fd7967dd6a3f9","time":{"0.0.1":"2020-11-20T23:12:48.532Z","created":"2020-11-21T10:01:55.184Z","0.0.2":"2020-11-21T10:01:55.331Z","modified":"2022-04-04T16:30:23.715Z"},"name":"@austonpramodh/s3-streamlogger-ts","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.2":{"name":"@austonpramodh/s3-streamlogger-ts","version":"0.0.2","description":"Stream for logging to s3 with rotated object names. Usable as a wiston-file stream. ","main":"lib/index.js","types":"lib/index.d.ts","scripts":{"test":"jest","build":"tsc","lint":"eslint --fix \"src/**/*.ts\" --ignore-pattern node_modules/","prepare":"npm run build","prepublishOnly":"npm test && npm run lint","preversion":"npm run lint","version":"npm run lint && git add -A src","postversion":"git push && git push --tags"},"repository":{"type":"git","url":"git+https://github.com/austonpramodh/s3-streamlogger-ts.git"},"keywords":["winston","logging","s3"],"author":{"name":"Auston Pramodh Barboza","email":"austonpramodh@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/austonpramodh/s3-streamlogger-ts/issues"},"homepage":"https://github.com/austonpramodh/s3-streamlogger-ts","dependencies":{"aws-sdk":"^2.797.0","dayjs":"^1.9.6"},"devDependencies":{"@types/jest":"^26.0.15","@types/node":"^14.14.9","@typescript-eslint/eslint-plugin":"^4.8.1","@typescript-eslint/parser":"^4.8.1","eslint":"^7.14.0","eslint-config-prettier":"^6.15.0","eslint-plugin-import":"^2.22.1","eslint-plugin-prettier":"^3.1.4","jest":"^26.6.3","prettier":"^2.2.0","ts-jest":"^26.4.4","typescript":"^4.1.2"},"gitHead":"d75aef27ba269c9f91b63ff7bc0e1489d6a2c914","_id":"@austonpramodh/s3-streamlogger-ts@0.0.2","_nodeVersion":"14.14.0","_npmVersion":"6.14.8","dist":{"integrity":"sha512-1QpOcUsNataKTlxBPovNQBYqwroMuEmoTdR9Zu7cB+xf7Hp1gyJt3V470jg7WxwJsWiWWRhrSWhwIschs12yrA==","shasum":"6e78074fc97136b831a99a8d844531cfae70a6fa","tarball":"https://registry.npmjs.org/@austonpramodh/s3-streamlogger-ts/-/s3-streamlogger-ts-0.0.2.tgz","fileCount":6,"unpackedSize":25890,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfuOWTCRA9TVsSAnZWagAA/SkP/3Kg/jHmshyMBPfSJYIk\nHQsNaFNUsB7atXamrjoh0C6W8edUaMNJihhpLUpeqctGVTJ8cYf7Av0cu+sA\nRySYvzf/nRmdkUbIzQFSPzMhRAThftDwBmdyBmB/MhtcqBxc3wazNQ21Rtq9\nVZLm1K+LUHuAOkYh2IqIYi7tM1RwyaQqBG3XPNBK4oo0xhXFwsJfKCc9xHuf\nPtzhHhpPLUsLv21uE7N1MRBVQrAMS1JnmChpd5s3P+6K0Cpr0A1SYwG0F+qr\nPwFzA4D02Ugaw6eMRTjdXB8y3ghJxY2KvRjcdUDD/3sXR4GRVnrySdKGr4rO\n4liHpsuzmHGv438fpMfeNXREG+5WrjCz7CaAMXjuJ3IWx+wlapFWBOrfT55P\nKFcmOQdLN3L7aCyFPn4NqFf2oPK0pAdM+FoEpGGvUWKlf/CBPjkSBaG5I+tH\ni1CMM2txXWsnvYXZHV1hG+n5UvXjFmF+27wpT/GJuTdYjMcKXzuCLHQBpHEY\npAp2TN+HF3AJNwULDj07XexE3ilivgXYILEsN8asVn0jP6dtPwD/qNX9u29S\npE/837Sy+fw/XuXVgVrizaYxbw7cxK99LTm0BHec3bW5Ps42IQAowkb/h2QW\nMjtLIqBdSSfFIFjhKvzL/Zt+Ux014uIAq+Hj7swwia5eEutuTSYH2NMtae5+\nOaG/\r\n=UGSb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIArLZsOAKQfE6xp27TJSsaG3Mz/cPiBXWPx/fG56hWQcAiEAvVz00zLCt/VVa9DUa95IBkL7eJCwsSoKv1QrgzMtexc="}]},"_npmUser":{"name":"austonpramodh","email":"austonpramodh@gmail.com"},"directories":{},"maintainers":[{"name":"austonpramodh","email":"austonpramodh@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/s3-streamlogger-ts_0.0.2_1605952915223_0.8503093194563565"},"_hasShrinkwrap":false}},"maintainers":[{"name":"austonpramodh","email":"austonpramodh@gmail.com"}],"description":"Stream for logging to s3 with rotated object names. Usable as a wiston-file stream. ","homepage":"https://github.com/austonpramodh/s3-streamlogger-ts","keywords":["winston","logging","s3"],"repository":{"type":"git","url":"git+https://github.com/austonpramodh/s3-streamlogger-ts.git"},"author":{"name":"Auston Pramodh Barboza","email":"austonpramodh@gmail.com"},"bugs":{"url":"https://github.com/austonpramodh/s3-streamlogger-ts/issues"},"license":"ISC","readme":"### This respository is based on [s3-streamlogger](https://github.com/Coggle/s3-streamlogger).\r\n\r\n## s3-streamlogger-ts\r\n[![NPM version](https://badge.fury.io/js/s3-streamlogger-ts.svg)](http://badge.fury.io/js/s3-streamlogger-ts)\r\n\r\n\r\nA Writable Stream object that uploads to s3 objects, periodically rotating to a\r\nnew object name.\r\n\r\n\r\n### Installation\r\n```bash\r\nnpm install --save @austonpramodh/s3-streamlogger-ts\r\n```\r\n\r\n### Basic Usage\r\n```js\r\nimport { S3StreamLogger } from \"@austonpramodh/s3-streamlogger-ts\";\r\n\r\nconst s3stream = new S3StreamLogger({\r\n    bucket: \"mys3bucket\",\r\n    accessKeyId: \"...\",\r\n    secretAccessKey: \"...\"\r\n});\r\n\r\ns3stream.write(\"hello S3\");\r\n```\r\n\r\n### Use with Winston: Log to S3\r\n```sh\r\nnpm install --save winston\r\nnpm install --save @austonpramodh/s3-streamlogger-ts\r\n```\r\n\r\n```js\r\nimport { transports, createLogger } from \"winston\";\r\nimport { S3StreamLogger } from \"@austonpramodh/s3-streamlogger-ts\";\r\n\r\nconst s3stream = new S3StreamLogger({\r\n    bucket: \"mys3bucket\",\r\n    accessKeyId: \"...\",\r\n    secretAccessKey: \"...\"\r\n});\r\n\r\nconst transport = new transports.Stream({ stream: s3_stream })\r\n\r\n// see error handling section below\r\ntransport.on('error', function(err){/* ... */});\r\n\r\nconst logger = createLogger({\r\n  transports: [transport]\r\n});\r\n\r\nlogger.info('Hello Winston!');\r\n```\r\n\r\n\r\n### Define subfolder\r\n```js\r\nimport { S3StreamLogger } from \"@austonpramodh/s3-streamlogger-ts\";\r\n\r\nconst s3stream = new S3StreamLogger({\r\n    bucket: \"mys3bucket\",\r\n    accessKeyId: \"...\",\r\n    secretAccessKey: \"...\",\r\n    folder: \"my/nested/subfolder\"\r\n});\r\n\r\ns3stream.write(\"hello S3\");\r\n```\r\n\r\n### Assign tags\r\n```js\r\nimport { S3StreamLogger } from \"@austonpramodh/s3-streamlogger-ts\";\r\n\r\nconst s3stream = new S3StreamLogger({\r\n    bucket: \"mys3bucket\",\r\n    accessKeyId: \"...\",\r\n    secretAccessKey: \"...\",\r\n    folder: \"my/nested/subfolder\",\r\n    tags: {type: 'myType', project: 'myProject'},\r\n});\r\n\r\ns3stream.write(\"hello S3\");\r\n```\r\n\r\n### Handling logging errors\r\nWhen there is an error writing to s3, the stream emits an 'error' event with\r\ndetails. You should take care **not** to log these errors back to the same\r\nstream (as that is likely to cause infinite recursion). Instead log them to the\r\nconsole, to a file.\r\n\r\nNote that these errors will result in uncaught exceptions unless you have an\r\n`error` event handler registered, for example:\r\n\r\n```js\r\ns3stream.on('error', function(err){\r\n    // there was an error!\r\n    some_other_logging_transport.log('error', 'logging transport error', err)\r\n});\r\n```\r\n\r\nWhen using s3-streamlogger with the Winston Stream transport, the Stream transport\r\nattaches its own error handler to the stream, so you do not need your own,\r\nhowever it will re-emit the errors on itself which must be handled instead:\r\n\r\n```js\r\nconst transport = new transports.Stream({ stream: s3_stream })\r\n\r\ntransport.on('error', function(err){\r\n  /* handle s3 stream errors (e.g. invalid credentials, EHOSTDOWN) here */\r\n});\r\n\r\nconst logger = createLogger({\r\n  transports: [transport]\r\n});\r\n```\r\n\r\n### Options\r\n\r\n#### bucket *(required)*\r\nName of the S3 bucket to upload data to. Must exist.\r\nCan also be provided as the environment variable `BUCKET_NAME`.\r\n\r\n#### folder\r\nAn optional folder to stream log files to. Takes a path string,\r\neg: \"my/subfolder\" or \"nested\".\r\n\r\n#### tags\r\nAn optional set of tags to assign to the log files. Takes an object,\r\neg: `{type: \"myType\"}` or `{type: \"myType\", project: \"myProject\"}`.\r\n\r\n#### access_key_id\r\nAWS access key ID, must have putObject permission on the specified bucket.  Can\r\nalso be provided as the environment variable `AWS_SECRET_ACCESS_KEY`, or as any\r\nof the other [authentication\r\nmethods](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html)\r\nsupported by the AWS SDK.\r\n\r\n#### secret_access_key\r\nAWS secret key for the `access_key_id` specified.  Can also be provided as the\r\nenvironment variable `AWS_SECRET_KEY_ID`, or as any of the other\r\n[authentication\r\nmethods](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html)\r\nsupported by the AWS SDK.\r\n\r\n#### config\r\n\r\nConfiguration object for the AWS SDK. The full list of options is available on the [AWS SDK Configuration Object page](http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html). This is an alternative to using access_key_id and secret_access_key and is overwritten by them if both are used.\r\n\r\n#### name_format\r\nFormat of file names to create, accepts [strftime specifiers](https://github.com/samsonjs/strftime). Defaults to `\"YYYY-MMM-DD-HH-mm-<NODE_ENV>-<hostname>.log\"`. The Date() used to fill the format specifiers is created with the current UTC time, but still *has the current timezone*, so any specifiers that perform timezone conversion will return incorrect dates.\r\n\r\nIf `compress` is set to true, then the default extension is `.log.gz` instead of\r\n`.log`.\r\n\r\n#### rotate_every\r\nFiles will be rotated every `rotate_every` milliseconds. Defaults to 3600000 (60\r\nminutes).\r\n\r\n#### max_file_size\r\nFiles will be rotated when they reach `maxFileSize` bytes. Defaults to 200 KB.\r\n\r\n#### uploadDelay\r\nFiles will be uploaded every `uploadDelay` milliseconds. Defaults to 20\r\nseconds.\r\n\r\n#### bufferSize\r\nFiles will be uploaded if the un-uploaded data exceeds `bufferSize` bytes.\r\nDefaults to 10 KB.\r\n\r\n#### serverSideEncryption\r\nThe server side encryption `AES256` algorithm used when storing objects in S3.\r\nDefaults to false.\r\n\r\n#### storageClass\r\nThe S3 StorageClass (STANDARD, REDUCED_REDUNDANCY, etc.). If omitted, no value\r\nis used and aws-sdk will fill in its default.\r\n\r\n#### acl\r\nThe canned ACL (access control list) to apply to uploaded objects.\r\nDefaults to no ACL.\r\n\r\n#### compress\r\nIf true, the files will be gzipped before uploading (may reduce s3 storage costs).\r\nDefaults to false.\r\n\r\n### License\r\n<!-- [ISC](http://opensource.org/licenses/ISC): equivalent to 2-clause BSD. -->\r\nUNLICENSED\r\n\r\n","readmeFilename":"readme.md"}