Skip to content

Commit 4bbc067

Browse files
authored
support passing through timed frequencies, if desired (#208)
1 parent 508892e commit 4bbc067

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ npm install winston-daily-rotate-file
1414
## Options
1515
The DailyRotateFile transport can rotate files by minute, hour, day, month, year or weekday. In addition to the options accepted by the logger, `winston-daily-rotate-file` also accepts the following options:
1616

17+
* **frequency:** A string representing the frequency of rotation. This is useful if you want to have timed rotations, as opposed to rotations that happen at specific moments in time. Valid values are '#m' or '#h' (e.g., '5m' or '3h'). Leaving this null relies on `datePattern` for the rotation times. (default: null)
1718
* **datePattern:** A string representing the [moment.js date format](http://momentjs.com/docs/#/displaying/format/) to be used for rotating. The meta characters used in this string will dictate the frequency of the file rotation. For example, if your datePattern is simply 'HH' you will end up with 24 log files that are picked up and appended to every day. (default 'YYYY-MM-DD')
1819
* **zippedArchive:** A boolean to define whether or not to gzip archived log files. (default 'false')
1920
* **filename:** Filename to be used to log to. This filename can include the `%DATE%` placeholder which will include the formatted datePattern at that point in the filename. (default: 'winston.log.%DATE%)

daily-rotate-file.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var DailyRotateFile = function (options) {
8181

8282
this.logStream = require('file-stream-rotator').getStream({
8383
filename: path.join(this.dirname, this.filename),
84-
frequency: 'custom',
84+
frequency: options.frequency ? options.frequency : 'custom',
8585
date_format: options.datePattern ? options.datePattern : 'YYYY-MM-DD',
8686
verbose: false,
8787
size: getMaxSize(options.maxSize),

0 commit comments

Comments
 (0)