All files / src/domain/log index.js

100% Statements 11/11
100% Branches 8/8
100% Functions 4/4
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28        40x   40x 200x       200x 200x 45x   3x 2x           155x 155x        
import buildLogToRaven from './buildLogToRaven';
import Config from 'domain/Config';
 
class log {}
const methods = ['error', 'info', 'log', 'warn', 'debug'];
 
methods.forEach((method) => {
  log[method] = buildLogMethod(method); // eslint-disable-line no-param-reassign
});
 
function buildLogMethod(method) {
  const sentry = Config.get('sentry');
  if (sentry && sentry.disabled === true) {
    return (...args) => {
      /* eslint-disable no-console */
      if (window.console && console[method]) {
        return console[method](...args);
      }
      /* eslint-enable no-console */
    };
  }
 
  const logToRaven = buildLogToRaven(method);
  return (...args) => logToRaven(...args);
}
 
export default log;