From ec9651b49d488058a756a3e0cd5952e3ec923e8d Mon Sep 17 00:00:00 2001 From: David Beitey Date: Mon, 1 Oct 2018 08:48:43 +0000 Subject: [PATCH] Simplify log file rotation example The rfs module will automatically create the log directory (https://www.npmjs.com/package/rotating-file-stream#function-filenameindex) so this example doesn't need to manually check for or create the directory. --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ba8b256..debf532 100644 --- a/README.md +++ b/README.md @@ -309,10 +309,11 @@ app.get('/', function (req, res) { Simple app that will log all requests in the Apache combined format to one log file per day in the `log/` directory using the [rotating-file-stream module](https://www.npmjs.com/package/rotating-file-stream). +The `rotating-file-stream` module will automatically create the log directory in +this example if it doesn't already exist. ```js var express = require('express') -var fs = require('fs') var morgan = require('morgan') var path = require('path') var rfs = require('rotating-file-stream') @@ -320,9 +321,6 @@ var rfs = require('rotating-file-stream') var app = express() var logDirectory = path.join(__dirname, 'log') -// ensure log directory exists -fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory) - // create a rotating write stream var accessLogStream = rfs('access.log', { interval: '1d', // rotate daily