From ec7d97fb49cbe75b4444536e46fac6899108b73c Mon Sep 17 00:00:00 2001 From: Neveh A Date: Sat, 11 May 2024 10:52:27 +0300 Subject: [PATCH 1/2] Update index.ts add option to provide additional custom console methods --- src/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index d4c8a92..2d1046d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -156,19 +156,26 @@ function pluginTerminal(options: Options = {}) { readline.cursorTo(process.stdout, 0, 0) readline.clearScreenDown(process.stdout) } + options?.customLogger?.clear?.(); } break } case 'table': { const obj = JSON.parse(message) const indent = 2 * (groupLevel + 1) - run = () => config.logger.info(`» ${table(obj, indent, 2)}`) + run = () => { + options?.customLogger?.info?.(`\xBB ${table(obj, indent, 2)}`); + config.logger.info(`\xBB ${table(obj, indent, 2)}`); + } break } default: { const color = colors[method] const groupedMessage = groupText(message, groupLevel) - run = () => config.logger.info(color(`» ${groupedMessage}`)) + run = () => { + options?.customLogger?.info?.(color(`\xBB ${groupedMessage}`)); + config.logger.info(color(`\xBB ${groupedMessage}`)); + }; break } } From 78cbae4172c6074ec03024458fb1197a66355ea1 Mon Sep 17 00:00:00 2001 From: Neveh A Date: Sat, 11 May 2024 10:59:36 +0300 Subject: [PATCH 2/2] add types --- src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/index.ts b/src/index.ts index 2d1046d..d11179b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -48,6 +48,11 @@ export interface Options { * Filter for modules to not be processed to remove logs */ exclude?: FilterPattern + + /** + * Custom logger to use in addition to the terminal + */ + customLogger?: Partial } interface Terminal {