Skip to content

Commit

Permalink
remove INFO log in production, but not ERROR logs
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolodavis committed Oct 23, 2019
1 parent 83810ea commit 1ad87d0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
7 changes: 3 additions & 4 deletions src/core/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
* https://opensource.org/licenses/MIT.
*/

const DEV =
process.env.NODE_ENV === 'development' || process.env.NODE_ENV == 'test';
const logfn = DEV ? console.log : () => {};
const errorfn = DEV ? console.error : () => {};
const production = process.env.NODE_ENV === 'production';
const logfn = production ? () => {} : console.log;
const errorfn = console.error;

export function info(msg) {
logfn(`INFO: ${msg}`);
Expand Down
10 changes: 5 additions & 5 deletions src/core/logger.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ describe('logging', () => {
logging = require('./logger');
});

test('error stripped', () => {
logging.error('msg1');
expect(console.error).not.toHaveBeenCalled();
});

test('info stripped', () => {
logging.info('msg2');
expect(console.log).not.toHaveBeenCalled();
});

test('error not stripped', () => {
logging.error('msg1');
expect(console.error).toHaveBeenCalled();
});
});
});

0 comments on commit 1ad87d0

Please sign in to comment.