| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | import { workUnitAsyncStorage } from '../app-render/work-unit-async-storage.external' |
| |
|
| | type ConsoleMethodName = keyof Console |
| |
|
| | function patchConsoleMethod(methodName: ConsoleMethodName): void { |
| | const descriptor = Object.getOwnPropertyDescriptor(console, methodName) |
| | if ( |
| | descriptor && |
| | (descriptor.configurable || descriptor.writable) && |
| | typeof descriptor.value === 'function' |
| | ) { |
| | const originalMethod = descriptor.value |
| | const originalName = Object.getOwnPropertyDescriptor(originalMethod, 'name') |
| | let wrapperMethod = function (...args: any[]) { |
| | return workUnitAsyncStorage.exit(() => |
| | originalMethod.apply(console, args) |
| | ) |
| | } |
| | if (originalName) { |
| | Object.defineProperty(wrapperMethod, 'name', originalName) |
| | } |
| | Object.defineProperty(console, methodName, { |
| | value: wrapperMethod, |
| | }) |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | patchConsoleMethod('error') |
| | patchConsoleMethod('assert') |
| | patchConsoleMethod('debug') |
| | patchConsoleMethod('dir') |
| | patchConsoleMethod('dirxml') |
| | patchConsoleMethod('group') |
| | patchConsoleMethod('groupCollapsed') |
| | patchConsoleMethod('groupEnd') |
| | patchConsoleMethod('info') |
| | patchConsoleMethod('log') |
| | patchConsoleMethod('table') |
| | patchConsoleMethod('trace') |
| | patchConsoleMethod('warn') |
| |
|