Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

Commit

Permalink
only enabling morgan logger if config.log.format option was defined, …
Browse files Browse the repository at this point in the history
…and disabling the app.log file transport option for the test environment
  • Loading branch information
lirantal committed May 19, 2016
1 parent 1f75f9f commit 5b9b2fd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
16 changes: 8 additions & 8 deletions config/env/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ module.exports = {
log: {
// logging with Morgan - https://github.com/expressjs/morgan
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'combined',
fileLogger: {
directoryPath: process.cwd(),
fileName: 'app.log',
maxsize: 10485760,
maxFiles: 2,
json: false
}
format: 'dev'
// fileLogger: {
// directoryPath: process.cwd(),
// fileName: 'app.log',
// maxsize: 10485760,
// maxFiles: 2,
// json: false
// }
},
port: process.env.PORT || 3001,
app: {
Expand Down
7 changes: 5 additions & 2 deletions config/lib/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var config = require('../config'),
flash = require('connect-flash'),
consolidate = require('consolidate'),
path = require('path'),
_ = require('lodash'),
lusca = require('lusca');

/**
Expand Down Expand Up @@ -68,8 +69,10 @@ module.exports.initMiddleware = function (app) {
// Initialize favicon middleware
app.use(favicon(app.locals.favicon));

// Enable logger (morgan)
app.use(morgan(logger.getLogFormat(), logger.getMorganOptions()));
// Enable logger (morgan) if enabled in the configuration file
if (_.has(config, 'log.format')) {
app.use(morgan(logger.getLogFormat(), logger.getMorganOptions()));
}

// Environment dependent middleware
if (process.env.NODE_ENV === 'development') {
Expand Down

0 comments on commit 5b9b2fd

Please sign in to comment.