[local-sync] only enable logging in dev mode of N1

This commit is contained in:
Evan Morikawa 2016-12-02 17:33:51 -05:00
parent 9752eea9f7
commit 2ba326dfc6
2 changed files with 9 additions and 1 deletions

View file

@ -176,7 +176,6 @@ class SyncWorker {
return;
}
console.log(this._account)
this._logger.info({reason}, `SyncWorker: Account sync started`)
try {

View file

@ -1,6 +1,12 @@
const _ = require('underscore')
let ENABLE_LOGGING = true;
function Logger(boundArgs = {}) {
if (NylasEnv && !NylasEnv.inDevMode()) {
ENABLE_LOGGING = false
}
if (!_.isObject(boundArgs)) {
throw new Error('Logger: Bound arguments must be an object')
}
@ -8,6 +14,9 @@ function Logger(boundArgs = {}) {
const loggerFns = ['log', 'info', 'warn', 'error']
loggerFns.forEach((logFn) => {
logger[logFn] = (first, ...args) => {
if (!ENABLE_LOGGING && logFn !== "error") {
return () => {}
}
if (first instanceof Error || !_.isObject(first)) {
if (_.isEmpty(boundArgs)) {
return console[logFn](first, ...args)