mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-09-13 08:04:40 +08:00
[local-sync] only enable logging in dev mode of N1
This commit is contained in:
parent
9752eea9f7
commit
2ba326dfc6
2 changed files with 9 additions and 1 deletions
|
@ -176,7 +176,6 @@ class SyncWorker {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(this._account)
|
|
||||||
this._logger.info({reason}, `SyncWorker: Account sync started`)
|
this._logger.info({reason}, `SyncWorker: Account sync started`)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
const _ = require('underscore')
|
const _ = require('underscore')
|
||||||
|
|
||||||
|
let ENABLE_LOGGING = true;
|
||||||
|
|
||||||
function Logger(boundArgs = {}) {
|
function Logger(boundArgs = {}) {
|
||||||
|
if (NylasEnv && !NylasEnv.inDevMode()) {
|
||||||
|
ENABLE_LOGGING = false
|
||||||
|
}
|
||||||
|
|
||||||
if (!_.isObject(boundArgs)) {
|
if (!_.isObject(boundArgs)) {
|
||||||
throw new Error('Logger: Bound arguments must be an object')
|
throw new Error('Logger: Bound arguments must be an object')
|
||||||
}
|
}
|
||||||
|
@ -8,6 +14,9 @@ function Logger(boundArgs = {}) {
|
||||||
const loggerFns = ['log', 'info', 'warn', 'error']
|
const loggerFns = ['log', 'info', 'warn', 'error']
|
||||||
loggerFns.forEach((logFn) => {
|
loggerFns.forEach((logFn) => {
|
||||||
logger[logFn] = (first, ...args) => {
|
logger[logFn] = (first, ...args) => {
|
||||||
|
if (!ENABLE_LOGGING && logFn !== "error") {
|
||||||
|
return () => {}
|
||||||
|
}
|
||||||
if (first instanceof Error || !_.isObject(first)) {
|
if (first instanceof Error || !_.isObject(first)) {
|
||||||
if (_.isEmpty(boundArgs)) {
|
if (_.isEmpty(boundArgs)) {
|
||||||
return console[logFn](first, ...args)
|
return console[logFn](first, ...args)
|
||||||
|
|
Loading…
Add table
Reference in a new issue