()
| 16 | let consoleHacked = false; |
| 17 | |
| 18 | export const consoleHack = (): void => { |
| 19 | if (!consoleHacked) { |
| 20 | consoleHacked = true; |
| 21 | |
| 22 | console.originDebug = console.debug; |
| 23 | console.originLog = console.log; |
| 24 | console.originInfo = console.info; |
| 25 | console.originDir = console.dir; |
| 26 | console.originWarn = console.warn; |
| 27 | console.originError = console.error; |
| 28 | |
| 29 | console.debug = ( |
| 30 | message?: any, |
| 31 | ...optionalParams: any[] |
| 32 | ): void => { |
| 33 | if (getCurrentContext() === null) { |
| 34 | return console.originDebug(message, ...optionalParams); |
| 35 | } |
| 36 | |
| 37 | return logger.writeLog( |
| 38 | "DEBUG", |
| 39 | `${util.format(message, ...optionalParams)}` |
| 40 | ); |
| 41 | }; |
| 42 | |
| 43 | console.log = ( |
| 44 | message?: any, |
| 45 | ...optionalParams: any[] |
| 46 | ): void => { |
| 47 | if (getCurrentContext() === null) { |
| 48 | return console.originLog(message, ...optionalParams); |
| 49 | } |
| 50 | |
| 51 | return logger.writeLog( |
| 52 | "DEBUG", |
| 53 | `${util.format(message, ...optionalParams)}` |
| 54 | ); |
| 55 | }; |
| 56 | |
| 57 | console.info = ( |
| 58 | message?: any, |
| 59 | ...optionalParams: any[] |
| 60 | ): void => { |
| 61 | if (getCurrentContext() === null) { |
| 62 | return console.originInfo(message, ...optionalParams); |
| 63 | } |
| 64 | |
| 65 | return logger.writeLog( |
| 66 | "INFO", |
| 67 | `${util.format(message, ...optionalParams)}` |
| 68 | ); |
| 69 | }; |
| 70 | |
| 71 | console.dir = ( |
| 72 | obj: any, |
| 73 | options?: InspectOptions |
| 74 | ): void => { |
| 75 | if (getCurrentContext() === null) { |
no test coverage detected