()
| 52 | } |
| 53 | |
| 54 | function instrumentConsole(): void { |
| 55 | if (!('console' in GLOBAL_OBJ)) { |
| 56 | return; |
| 57 | } |
| 58 | |
| 59 | CONSOLE_LEVELS.forEach(function (level: ConsoleLevel): void { |
| 60 | if (!(level in GLOBAL_OBJ.console)) { |
| 61 | return; |
| 62 | } |
| 63 | |
| 64 | fill(GLOBAL_OBJ.console, level, function (originalConsoleMethod: () => any): Function { |
| 65 | originalConsoleMethods[level] = originalConsoleMethod; |
| 66 | |
| 67 | return function (...args: any[]): void { |
| 68 | const firstArg = args[0]; |
| 69 | const log = originalConsoleMethods[level]; |
| 70 | |
| 71 | const isFiltered = _filter.size && typeof firstArg === 'string' && stringMatchesSomePattern(firstArg, _filter); |
| 72 | |
| 73 | // Only trigger handlers for non-filtered messages |
| 74 | if (!isFiltered) { |
| 75 | triggerHandlers('console', { args, level } as HandlerDataConsole); |
| 76 | } |
| 77 | |
| 78 | // Only log filtered messages in debug mode |
| 79 | if (!isFiltered || (DEBUG_BUILD && debug.isEnabled())) { |
| 80 | // Call original console method |
| 81 | log?.apply(GLOBAL_OBJ.console, args); |
| 82 | } |
| 83 | }; |
| 84 | }); |
| 85 | }); |
| 86 | } |
nothing calls this directly
no test coverage detected