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

Commit

Permalink
adding support for logger handling which allows for saving the reques…
Browse files Browse the repository at this point in the history
…ts to a logfile, useful for production systems
  • Loading branch information
lirantal committed Nov 6, 2014
1 parent 0f4a585 commit bf7bcc6
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 3 deletions.
7 changes: 6 additions & 1 deletion config/env/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ module.exports = {
sessionCollection: 'sessions',
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'combined'
format: 'combined',
// Stream defaults to process.stdout
// Uncomment to enable logging to a log on the file system
options: {
stream: 'access.log'
}
},
assets: {
lib: {
Expand Down
7 changes: 6 additions & 1 deletion config/env/development.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ module.exports = {
db: 'mongodb://localhost/mean-dev',
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'dev'
format: 'dev',
// Stream defaults to process.stdout
// Uncomment to enable logging to a log on the file system
options: {
//stream: 'access.log'
}
},
app: {
title: 'MEAN.JS - Development Environment'
Expand Down
9 changes: 9 additions & 0 deletions config/env/production.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

module.exports = {
db: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || 'localhost') + '/mean',
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'combined',
// Stream defaults to process.stdout
// Uncomment to enable logging to a log on the file system
options: {
stream: 'access.log'
}
},
assets: {
lib: {
css: [
Expand Down
9 changes: 9 additions & 0 deletions config/env/secure.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
module.exports = {
port: 443,
db: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://localhost/mean',
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'combined',
// Stream defaults to process.stdout
// Uncomment to enable logging to a log on the file system
options: {
stream: 'access.log'
}
},
assets: {
lib: {
css: [
Expand Down
9 changes: 9 additions & 0 deletions config/env/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
module.exports = {
db: 'mongodb://localhost/mean-test',
port: 3001,
log: {
// Can specify one of 'combined', 'common', 'dev', 'short', 'tiny'
format: 'dev',
// Stream defaults to process.stdout
// Uncomment to enable logging to a log on the file system
options: {
//stream: 'access.log'
}
},
app: {
title: 'MEAN.JS - Test Environment'
},
Expand Down
3 changes: 2 additions & 1 deletion config/express.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var fs = require('fs'),
https = require('https'),
express = require('express'),
morgan = require('morgan'),
logger = require('./logger'),
bodyParser = require('body-parser'),
session = require('express-session'),
compress = require('compression'),
Expand Down Expand Up @@ -65,7 +66,7 @@ module.exports = function(db) {
app.set('views', './app/views');

// Enable logger (morgan)
app.use(morgan(config.log.format));
app.use(morgan(logger.getLogFormat(), logger.getLogOptions()));

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

0 comments on commit bf7bcc6

Please sign in to comment.