Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
`Running app on ${chunk.deviceName} in ${devEnabled ? 'development' : 'production'} mode\n`
)
return
}
if (chunk.msg === 'Dependency graph loaded.') {
packagerReady = true
onReady()
return
}
if (packagerReady) {
const message = `${chunk.msg.trim()}\n`
logWithLevel(chunk)
if (chunk.level === bunyan.ERROR) {
// if you run into a syntax error then we should clear log output on reload
needsClear = message.indexOf('SyntaxError') >= 0
}
} else {
if (chunk.level >= bunyan.ERROR) {
log(chalk.yellow('***ERROR STARTING PACKAGER***'))
log(logBuffer)
log(chalk.red(chunk.msg))
logBuffer = ''
} else {
logBuffer += chunk.msg + '\n'
}
}
}
write(rec) {
if (rec.level < bunyan.INFO) {
console.log(rec);
} else if (rec.level < bunyan.WARN) {
console.info(rec);
} else if (rec.level < bunyan.ERROR) {
console.warn(rec);
} else {
console.error(rec);
}
}
}
write(record: any) {
if (record.level < bunyan.INFO) {
console.log(record);
} else if (record.level < bunyan.WARN) {
console.info(record);
} else if (record.level < bunyan.ERROR) {
console.warn(record);
} else {
console.error(record);
}
}
}
case NotificationCode.START_LOADING:
simpleSpinner.start();
return;
case NotificationCode.STOP_LOADING:
simpleSpinner.stop();
return;
case NotificationCode.DOWNLOAD_CLI_PROGRESS:
return;
}
}
if (chunk.level === bunyan.INFO) {
log(chunk.msg);
} else if (chunk.level === bunyan.WARN) {
log.warn(chunk.msg);
} else if (chunk.level >= bunyan.ERROR) {
log.error(chunk.msg);
}
},
},
case NotificationCode.START_LOADING:
simpleSpinner.start();
return;
case NotificationCode.STOP_LOADING:
simpleSpinner.stop();
return;
case NotificationCode.DOWNLOAD_CLI_PROGRESS:
return;
}
}
if (chunk.level === bunyan.INFO) {
log(chunk.msg);
} else if (chunk.level === bunyan.WARN) {
log.warn(chunk.msg);
} else if (chunk.level >= bunyan.ERROR) {
log.error(chunk.msg);
}
},
},
render() {
let { notifications } = this.props;
let logs = [];
if (notifications) {
this._addLogsForArray(
logs,
notifications.error,
bunyan.ERROR,
'Error',
StyleConstants.colorError
);
this._addLogsForArray(
logs,
notifications.warn,
bunyan.WARN,
'Warning',
StyleConstants.colorWarning
);
this._addLogsForArray(logs, notifications.info, bunyan.INFO, 'Info');
}
if (logs.length === 0) {
logs.push({
level: bunyan.INFO,
},
]
: [],
});
export type LogStream = bunyan.Stream;
export type Log = bunyan;
export default {
child: (options: object) => logger.child(options),
notifications: logger.child({ type: 'notifications' }),
global: logger.child({ type: 'global' }),
DEBUG: bunyan.DEBUG,
INFO: bunyan.INFO,
WARN: bunyan.WARN,
ERROR: bunyan.ERROR,
};
case NotificationCode.START_LOADING:
simpleSpinner.start();
return;
case NotificationCode.STOP_LOADING:
simpleSpinner.stop();
return;
case NotificationCode.DOWNLOAD_CLI_PROGRESS:
return;
}
}
if (chunk.level === bunyan.INFO) {
log(chunk.msg);
} else if (chunk.level === bunyan.WARN) {
log.warn(chunk.msg);
} else if (chunk.level >= bunyan.ERROR) {
log.error(chunk.msg);
}
},
},
const logWithLevel = chunk => {
if (!chunk.msg) {
return;
}
let colorFn = str => str;
if (chunk.level === bunyan.WARN) {
colorFn = chalk.yellow;
} else if (chunk.level === bunyan.ERROR) {
colorFn = chalk.red;
}
if (chunk.includesStack) {
logStackTrace(chunk, log.withTimestamp, log, colorFn);
} else {
logLines(chunk.msg, log.withTimestamp, colorFn);
}
};
type: 'raw',
stream: new ConsoleRawStream(),
closeOnExit: false,
level: 'debug',
},
]
: []),
],
});
logger.notifications = logger.child({ type: 'notifications' });
logger.global = logger.child({ type: 'global' });
logger.DEBUG = bunyan.DEBUG;
logger.INFO = bunyan.INFO;
logger.WARN = bunyan.WARN;
logger.ERROR = bunyan.ERROR;
export default logger;