From 9770c465fde49742ddab8ed25122b4ad88e14dc8 Mon Sep 17 00:00:00 2001 From: Matt Berther Date: Sat, 27 Oct 2018 18:29:40 -0600 Subject: [PATCH] add ability to pass custom options to address #184 --- README.md | 1 + daily-rotate-file.js | 3 ++- package-lock.json | 58 ++++++++++++++++++++------------------------ package.json | 8 +++--- 4 files changed, 33 insertions(+), 37 deletions(-) diff --git a/README.md b/README.md index e68e599..3f02bd3 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,7 @@ The DailyRotateFile transport can rotate files by minute, hour, day, month, year * **stream:** Write directly to a custom stream and bypass the rotation capabilities. (default: null) * **maxSize:** Maximum size of the file after which it will rotate. This can be a number of bytes, or units of kb, mb, and gb. If using the units, add 'k', 'm', or 'g' as the suffix. The units need to directly follow the number. (default: null) * **maxFiles:** Maximum number of logs to keep. If not set, no logs will be removed. This can be a number of files or number of days. If using days, add 'd' as the suffix. (default: null) +* **options:** An object resembling https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options indicating additional options that should be passed to the file stream. (default: `{ flags: 'a' }`) ## Usage ``` js diff --git a/daily-rotate-file.js b/daily-rotate-file.js index d57716f..035259a 100644 --- a/daily-rotate-file.js +++ b/daily-rotate-file.js @@ -87,7 +87,8 @@ var DailyRotateFile = function (options) { size: getMaxSize(options.maxSize), max_logs: options.maxFiles, end_stream: true, - audit_file: path.join(self.dirname, '.' + hash(options) + '-audit.json') + audit_file: path.join(self.dirname, '.' + hash(options) + '-audit.json'), + file_options: options.options ? options.options : {flags: 'a'} }); this.logStream.on('rotate', function (oldFile, newFile) { diff --git a/package-lock.json b/package-lock.json index c339d25..4476737 100644 --- a/package-lock.json +++ b/package-lock.json @@ -273,9 +273,9 @@ "integrity": "sha512-EDpX3a7wHMWFA7PUHWPHNWqOxIIRSJetuwl0AS5Oi/5FMV8kWm69RTlgm00GKjBO1xFHMtBbL49yRtMMdticBw==" }, "commander": { - "version": "2.11.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", - "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "version": "2.15.1", + "resolved": "http://registry.npmjs.org/commander/-/commander-2.15.1.tgz", + "integrity": "sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==", "dev": true }, "concat-map": { @@ -424,7 +424,7 @@ "progress": "2.0.0", "regexpp": "1.1.0", "require-uncached": "1.0.3", - "semver": "5.5.0", + "semver": "^5.3.0", "strip-ansi": "4.0.0", "strip-json-comments": "2.0.1", "table": "4.0.2", @@ -558,9 +558,9 @@ } }, "file-stream-rotator": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/file-stream-rotator/-/file-stream-rotator-0.4.0.tgz", - "integrity": "sha512-cQO3i2s5T6QgtrPcM/6cP30oSwqKymlhkYi/jTl6VCSi44q3UW8eb0zdqyU51tIzrbRe8zolU6Fb4a5e/90u4g==", + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/file-stream-rotator/-/file-stream-rotator-0.4.1.tgz", + "integrity": "sha512-W3aa3QJEc8BS2MmdVpQiYLKHj3ijpto1gMDlsgCRSKfIUe6MwkcpODGPQ3vZfb0XvCeCqlu9CBQTN7oQri2TZQ==", "requires": { "moment": "^2.11.2" } @@ -630,9 +630,9 @@ "dev": true }, "growl": { - "version": "1.10.3", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", - "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "version": "1.10.5", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", + "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", "dev": true }, "has-ansi": { @@ -871,45 +871,39 @@ } }, "mocha": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.1.1.tgz", - "integrity": "sha512-kKKs/H1KrMMQIEsWNxGmb4/BGsmj0dkeyotEvbrAuQ01FcWRLssUNXCEUZk6SZtyJBi6EE7SL0zDDtItw1rGhw==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.2.0.tgz", + "integrity": "sha512-2IUgKDhc3J7Uug+FxMXuqIyYzH7gJjXECKe/w43IGgQHTSj3InJi+yAA7T24L9bQMRKiUEHxEX37G5JpVUGLcQ==", "dev": true, "requires": { "browser-stdout": "1.3.1", - "commander": "2.11.0", + "commander": "2.15.1", "debug": "3.1.0", "diff": "3.5.0", "escape-string-regexp": "1.0.5", "glob": "7.1.2", - "growl": "1.10.3", + "growl": "1.10.5", "he": "1.1.1", "minimatch": "3.0.4", "mkdirp": "0.5.1", - "supports-color": "4.4.0" + "supports-color": "5.4.0" }, "dependencies": { - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz", + "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "2.0.0" + "has-flag": "^3.0.0" } } } }, "moment": { - "version": "2.20.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.20.1.tgz", - "integrity": "sha512-Yh9y73JRljxW5QxN08Fner68eFLxM5ynNOAw2LbIB1YAGeQzZT8QFSUvkAz609Zf+IHhhaUxqZK8dG3W/+HEvg==" + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz", + "integrity": "sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y=" }, "ms": { "version": "2.0.0", @@ -1131,9 +1125,9 @@ "dev": true }, "semver": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz", - "integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==" + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" }, "shebang-command": { "version": "1.2.0", diff --git a/package.json b/package.json index 35c7f83..2b61d61 100644 --- a/package.json +++ b/package.json @@ -35,14 +35,14 @@ "chai": "3.5.0", "eslint": "^4.19.1", "eslint-config-xo": "^0.19.0", - "mocha": "^5.1.1", - "moment": "^2.19.1", + "mocha": "^5.2.0", + "moment": "^2.22.2", "rimraf": "2.5.2" }, "dependencies": { - "file-stream-rotator": "^0.4.0", + "file-stream-rotator": "^0.4.1", "object-hash": "^1.3.0", - "semver": "^5.5.0", + "semver": "^5.6.0", "triple-beam": "^1.3.0", "winston-compat": "^0.1.4", "winston-transport": "^4.2.0"