| 38 | private _debuggers = new Map<string, debug.IDebugger>(); |
| 39 | |
| 40 | constructor() { |
| 41 | if (process.env.DEBUG_FILE) { |
| 42 | const ansiRegex = new RegExp([ |
| 43 | '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', |
| 44 | '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))' |
| 45 | ].join('|'), 'g'); |
| 46 | const stream = fs.createWriteStream(process.env.DEBUG_FILE); |
| 47 | (debug as any).log = (data: string) => { |
| 48 | stream.write(data.replace(ansiRegex, '')); |
| 49 | stream.write('\n'); |
| 50 | }; |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | log(name: LogName, message: string | Error | object) { |
| 55 | let cachedDebugger = this._debuggers.get(name); |