Skip to content

Commit

Permalink
add ability to pass custom options to address #184
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Berther committed Oct 28, 2018
1 parent 3958b81 commit 9770c46
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 37 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion daily-rotate-file.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
58 changes: 26 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 9770c46

Please sign in to comment.