diff --git a/package.json b/package.json index 5b93928..8be90a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ztimson/utils", - "version": "0.27.6", + "version": "0.27.7", "description": "Utility library", "author": "Zak Timson", "license": "MIT", diff --git a/src/misc.ts b/src/misc.ts index 85e43de..befca9c 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -24,12 +24,13 @@ export function compareVersions(target: string, vs: string): -1 | 0 | 1 { export function consoleInterceptor( out: null | {debug: Function, log: Function, info: Function, warn: Function, error: Function} = console, map?: {[K in LogLevels]?: LogLevels | 'none'} -): {debug: Function, log: Function, info: Function, warn: Function, error: Function, stderr: string[], stdout: string[]} { - const stderr: any[] = [], stdout: any[] = []; +): {debug: Function, log: Function, info: Function, warn: Function, error: Function, output: {debug: any[], log: any[], info: any[], warn: any[], error: any[], stderr: any[], stdout: any[]}} { + const logs: any = {debug: [], log: [], info: [], warn: [], error: [], stderr: [], stdout: [],} const cWrapper = (type: 'debug' | 'log' | 'info' | 'warn' | 'error') => ((...args: any[]) => { if(out) out[type](...args); - if(type == 'error') stderr.push(...args); - else stdout.push(...args); + logs[type].push(...args); + if(type == 'error') logs.stderr.push(...args); + else logs.stdout.push(...args); }); return { debug: map?.debug != 'none' ? cWrapper(map?.debug || 'debug') : () => {}, @@ -37,8 +38,7 @@ export function consoleInterceptor( info: map?.info != 'none' ? cWrapper(map?.info || 'info') : () => {}, warn: map?.warn != 'none' ? cWrapper(map?.warn || 'warn') : () => {}, error: map?.error != 'none' ? cWrapper(map?.error || 'error') : () => {}, - stderr, - stdout, + output: logs } }