From d3a15a699ecccb873b9a902c9ac39e91b6b59438 Mon Sep 17 00:00:00 2001 From: Siddharth Singh Date: Sun, 6 Apr 2025 15:33:36 +0530 Subject: [PATCH] fmt --- packages/ditto/utils/logi.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/ditto/utils/logi.ts b/packages/ditto/utils/logi.ts index 18305459..f977da3b 100644 --- a/packages/ditto/utils/logi.ts +++ b/packages/ditto/utils/logi.ts @@ -37,10 +37,10 @@ const prettyPrint = (msg: LogiValue): string => { case 'undefined': return `<${type}>`; case 'object': - if (message === null) return ""; + if (message === null) return ''; return JSON.stringify(message, (_, v) => { if (Array.isArray(v)) { - return `[${v.map(itm => JSON.stringify(itm)).join(', ')}]`; + return `[${v.map((itm) => JSON.stringify(itm)).join(', ')}]`; } if (typeof v === 'string') return `\`${v}\``; return v; @@ -49,11 +49,11 @@ const prettyPrint = (msg: LogiValue): string => { .replace(/^"/, '') .replace(/"$/, ''); } -} +}; const pair = (key: string, value: LogiValue | undefined) => { - return `${key} => ${prettyPrint(value || '')}` -} + return `${key} => ${prettyPrint(value || '')}`; +}; export const createLogiHandler = (conf: DittoConf, defaultHandler: LogiHandler) => (log: LogiLog) => { const { fmt, level, scopes } = conf.logConfig; @@ -65,7 +65,13 @@ export const createLogiHandler = (conf: DittoConf, defaultHandler: LogiHandler) const remaining = Object.entries(log) .filter(([key]) => !['ns', 'level', 'message', 'msg'].includes(key)); - console.group(`%c${log.level.toUpperCase()} %c${log.ns} %c${message || ''}`, `color: ${colors[log.level]}; font-weight: bold`, 'font-weight: normal; color: yellow', 'color: unset'); - console.log(remaining.map(itm => pair(...itm)).join('\n')); + console.group( + `%c${log.level.toUpperCase()} %c${log.ns} %c${message || ''}`, + `color: ${colors[log.level]}; font-weight: bold`, + 'font-weight: normal; color: yellow', + 'color: unset', + ); + + console.log(remaining.map((itm) => pair(...itm)).join('\n')); console.groupEnd(); };