diff --git a/config.json.example b/config.json.example index 6aeb8ac74a..9fa012240d 100644 --- a/config.json.example +++ b/config.json.example @@ -1,5 +1,6 @@ { "PORT":3000, + "ENABLE_CONSOLE_LOGS_IN_PROD":"false", "IP":"0.0.0.0", "CORES":1, "BASE_URL":"http://localhost:3000", @@ -33,7 +34,7 @@ "EMAIL_SERVER": { "url": "http://example.com", "authUser": "user", - "authPassword": "password" + "authPassword": "password" }, "S3":{ "bucket":"bucket", @@ -60,7 +61,7 @@ "subdomain": "subdomain", "token": "token", "username": "username", - "password": "password" + "password": "password" }, "PUSH_CONFIGS": { "GCM_SERVER_API_KEY": "", diff --git a/test/api/v3/unit/libs/cron.test.js b/test/api/v3/unit/libs/cron.test.js index d4a83634f3..382246a3c8 100644 --- a/test/api/v3/unit/libs/cron.test.js +++ b/test/api/v3/unit/libs/cron.test.js @@ -298,19 +298,19 @@ describe('cron', () => { expect(tasksByType.dailys[0].completed).to.be.false; }); - it('should set task checklist to completed for completed dailys', () => { + it('should reset task checklist for completed dailys', () => { tasksByType.dailys[0].checklist.push({title: 'test', completed: false}); tasksByType.dailys[0].completed = true; cron({user, tasksByType, daysMissed, analytics}); - expect(tasksByType.dailys[0].checklist[0].completed).to.be.true; + expect(tasksByType.dailys[0].checklist[0].completed).to.be.false; }); - it('should set task checklist to completed for dailys with scheduled misses', () => { + it('should reset task checklist for dailys with scheduled misses', () => { daysMissed = 10; tasksByType.dailys[0].checklist.push({title: 'test', completed: false}); tasksByType.dailys[0].startDate = moment(new Date()).subtract({days: 1}); cron({user, tasksByType, daysMissed, analytics}); - expect(tasksByType.dailys[0].checklist[0].completed).to.be.true; + expect(tasksByType.dailys[0].checklist[0].completed).to.be.false; }); it('should do damage for missing a daily', () => { diff --git a/website/src/libs/api-v3/cron.js b/website/src/libs/api-v3/cron.js index a8270c4bc8..25fcf9bd98 100644 --- a/website/src/libs/api-v3/cron.js +++ b/website/src/libs/api-v3/cron.js @@ -182,7 +182,7 @@ export function cron (options = {}) { task.completed = false; if (completed || scheduleMisses > 0) { - task.checklist.forEach(i => i.completed = true); // FIXME this should not happen for grey tasks unless they are completed + task.checklist.forEach(i => i.completed = false); // FIXME this should not happen for grey tasks unless they are completed } }); diff --git a/website/src/libs/api-v3/logger.js b/website/src/libs/api-v3/logger.js index a840f279dd..143b7afb67 100644 --- a/website/src/libs/api-v3/logger.js +++ b/website/src/libs/api-v3/logger.js @@ -5,17 +5,19 @@ import _ from 'lodash'; const IS_PROD = nconf.get('IS_PROD'); const IS_TEST = nconf.get('IS_TEST'); +const ENABLE_CONSOLE_LOGS_IN_PROD = nconf.get('ENABLE_CONSOLE_LOGS_IN_PROD') === 'true'; const logger = new winston.Logger(); if (IS_PROD) { // TODO production logging, use loggly and new relic too - // log errors to console too - logger - .add(winston.transports.Console, { + + if (ENABLE_CONSOLE_LOGS_IN_PROD) { + logger.add(winston.transports.Console, { colorize: true, prettyPrint: true, }); + } } else if (IS_TEST) { // Do not log anything when testing } else { @@ -53,10 +55,8 @@ let loggerInterface = { // Logs unhandled promises errors // when no catch is attached to a promise a unhandledRejection event will be triggered -process.on('unhandledRejection', function handlePromiseRejection (reason, promise) { - loggerInterface.error(reason, { - promise, - }); +process.on('unhandledRejection', function handlePromiseRejection (reason) { + loggerInterface.error(reason); }); module.exports = loggerInterface;