From a2b6442fa4381347f7787a1a7c72738a0a6c7f34 Mon Sep 17 00:00:00 2001 From: Matt Berther Date: Sun, 13 Jan 2019 19:20:20 -0700 Subject: [PATCH] support passing through timed frequencies, if desired --- README.md | 1 + daily-rotate-file.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f39a272..c7f6ee5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ npm install winston-daily-rotate-file ## Options 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: +* **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) * **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') * **zippedArchive:** A boolean to define whether or not to gzip archived log files. (default 'false') * **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%) diff --git a/daily-rotate-file.js b/daily-rotate-file.js index 035259a..30ecd03 100644 --- a/daily-rotate-file.js +++ b/daily-rotate-file.js @@ -81,7 +81,7 @@ var DailyRotateFile = function (options) { this.logStream = require('file-stream-rotator').getStream({ filename: path.join(this.dirname, this.filename), - frequency: 'custom', + frequency: options.frequency ? options.frequency : 'custom', date_format: options.datePattern ? options.datePattern : 'YYYY-MM-DD', verbose: false, size: getMaxSize(options.maxSize),