Packager: Print Debug Fields on Separate Lines

Summary:
When printing fields in the packager server debug output, this revision breaks the fields up onto multiple lines.

As it currently exists, the fields are printed immediately after the log entry label which can seem unnecessarily repetitive and unintuitive.

Reviewed By: davidaurelio

Differential Revision: D4235038

fbshipit-source-id: 2d59afa70c74f19afab221dfa58f437913c6dc2c
This commit is contained in:
Tim Yung 2016-11-28 13:06:27 -08:00 committed by Facebook Github Bot
parent 368ef3ef4b
commit 90197e919b
1 changed files with 23 additions and 23 deletions

View File

@ -89,40 +89,40 @@ function print(
if (!PRINT_LOG_ENTRIES) { if (!PRINT_LOG_ENTRIES) {
return logEntry; return logEntry;
} }
const {
log_entry_label: logEntryLabel,
action_phase: actionPhase,
duration_ms: duration,
} = logEntry;
const {log_entry_label, action_phase, duration_ms} = logEntry;
const timeStamp = new Date().toLocaleString(); const timeStamp = new Date().toLocaleString();
const logEntryDataList = []; let logEntryString;
let logEntryString, logEntryDataString;
for (let i = 0, len = printFields.length; i < len; i++) { switch (actionPhase) {
const field = printFields[i];
const value = logEntry[field];
if (value === undefined) {
continue;
}
logEntryDataList.push(`${field}: ${value.toString()}`);
}
logEntryDataString = logEntryDataList.join(' | ');
if (logEntryDataString) {
logEntryDataString = ` ${logEntryDataString}`;
}
switch (action_phase) {
case 'start': case 'start':
logEntryString = chalk.dim(`[${timeStamp}] <START> ${log_entry_label}${logEntryDataString}`); logEntryString = chalk.dim(`[${timeStamp}] <START> ${logEntryLabel}`);
break; break;
case 'end': case 'end':
logEntryString = chalk.dim(`[${timeStamp}] <END> ${log_entry_label}${logEntryDataString}`) + logEntryString = chalk.dim(`[${timeStamp}] <END> ${logEntryLabel}`) +
chalk.cyan(` (${+duration_ms}ms)`); chalk.cyan(` (${+duration}ms)`);
break; break;
default: default:
logEntryString = chalk.dim(`[${timeStamp}] ${log_entry_label}${logEntryDataString}`); logEntryString = chalk.dim(`[${timeStamp}] ${logEntryLabel}`);
break; break;
} }
if (printFields.length) {
const indent = ' '.repeat(timeStamp.length + 11);
for (const field of printFields) {
const value = logEntry[field];
if (value === undefined) {
continue;
}
logEntryString += chalk.dim(`\n${indent}${field}: ${value.toString()}`);
}
}
// eslint-disable-next-line no-console-disallow // eslint-disable-next-line no-console-disallow
console.log(logEntryString); console.log(logEntryString);