Expose logger format (#216)

This commit is contained in:
Jaco Greeff
2018-09-13 13:21:40 +02:00
committed by GitHub
parent 0743d1231a
commit adea971ee1
+4 -4
View File
@@ -33,7 +33,7 @@ const chalked = {
warn: chalk.yellow
};
function formatValue (value: any): any {
export function format (value: any): any {
if (isNull(value)) {
return null;
} else if (isUndefined(value)) {
@@ -41,7 +41,7 @@ function formatValue (value: any): any {
}
if (Array.isArray(value)) {
return value.map(formatValue);
return value.map(format);
}
if (isBn(value)) {
@@ -58,7 +58,7 @@ function formatValue (value: any): any {
if (isObject(value) && value.constructor === Object) {
return Object.keys(value).reduce((result, key) => {
result[key] = formatValue(value[key]);
result[key] = format(value[key]);
return result;
}, {} as { [index: string]: any });
@@ -82,7 +82,7 @@ function apply (log: LogType, type: string, values: Logger$Data): void {
console, [
chalk(moment().format('YYYY-MM-DD HH:mm:ss')), chalk(type)
].concat(
values.map(formatValue)
values.map(format)
)
);
}