From adea971ee17b6705b7a5d13a7d47a4c1699e8688 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Thu, 13 Sep 2018 13:21:40 +0200 Subject: [PATCH] Expose logger format (#216) --- packages/util/src/logger.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/util/src/logger.ts b/packages/util/src/logger.ts index b24adbd0b..29b2fcc0a 100644 --- a/packages/util/src/logger.ts +++ b/packages/util/src/logger.ts @@ -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) ) ); }