Skip to content

Commit

Permalink
feat: env var to disable logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
morganney authored Dec 21, 2023
2 parents b34491a + 81646b0 commit 34e1312
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions lib/restbus.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ app.enable('trust proxy');

// Configuration & Middleware
if(app.get('env') === 'development') {
router.use(logger('dev'));
if (process.env.RESTBUS_LOGGER !== 'false') {
router.use(logger('dev'));
}

router.use(errorhandler({showStack: true, dumpExceptions: true}));
router.use(function(err, req, res, next) {
console.error(err.stack);
res.status(500).json(utils.errors.get(500, 'The server encountered an unexpected condition: ' + err.message));
});
} else {
router.use(logger('combined'));
if (process.env.RESTBUS_LOGGER !== 'false') {
router.use(logger('combined'));
}

router.use(function(err, req, res, next) {
res.status(500).json(utils.errors.get(500, 'The server encountered an unexpected condition: ' + err.message));
});
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "restbus",
"description": "RESTful JSON API for the NextBus Inc. public XML feed.",
"version": "2.2.0",
"version": "2.3.0",
"main": "index",
"dependencies": {
"compression": "1.7.4",
Expand Down

0 comments on commit 34e1312

Please sign in to comment.