Skip to content

Commit 9770c46

Browse files
author
Matt Berther
committed
add ability to pass custom options to address #184
1 parent 3958b81 commit 9770c46

File tree

4 files changed

+33
-37
lines changed

4 files changed

+33
-37
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The DailyRotateFile transport can rotate files by minute, hour, day, month, year
2121
* **stream:** Write directly to a custom stream and bypass the rotation capabilities. (default: null)
2222
* **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)
2323
* **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)
24+
* **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' }`)
2425

2526
## Usage
2627
``` js

daily-rotate-file.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ var DailyRotateFile = function (options) {
8787
size: getMaxSize(options.maxSize),
8888
max_logs: options.maxFiles,
8989
end_stream: true,
90-
audit_file: path.join(self.dirname, '.' + hash(options) + '-audit.json')
90+
audit_file: path.join(self.dirname, '.' + hash(options) + '-audit.json'),
91+
file_options: options.options ? options.options : {flags: 'a'}
9192
});
9293

9394
this.logStream.on('rotate', function (oldFile, newFile) {

package-lock.json

Lines changed: 26 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@
3535
"chai": "3.5.0",
3636
"eslint": "^4.19.1",
3737
"eslint-config-xo": "^0.19.0",
38-
"mocha": "^5.1.1",
39-
"moment": "^2.19.1",
38+
"mocha": "^5.2.0",
39+
"moment": "^2.22.2",
4040
"rimraf": "2.5.2"
4141
},
4242
"dependencies": {
43-
"file-stream-rotator": "^0.4.0",
43+
"file-stream-rotator": "^0.4.1",
4444
"object-hash": "^1.3.0",
45-
"semver": "^5.5.0",
45+
"semver": "^5.6.0",
4646
"triple-beam": "^1.3.0",
4747
"winston-compat": "^0.1.4",
4848
"winston-transport": "^4.2.0"

0 commit comments

Comments
 (0)