| 114 | }; |
| 115 | |
| 116 | const log = (rawLog: (...args: any[]) => void, ...args: any[]) => { |
| 117 | try { |
| 118 | const fixWidth = 20; |
| 119 | const stack = Error().stack!.split("\n"); |
| 120 | const match = stack[3].match(pathRegex)!; |
| 121 | const fileName = match[1].replace(/\?.*$/, "").split("/").pop() ?? ""; |
| 122 | const spaces = fileName.length < fixWidth ? " ".repeat(fixWidth - fileName.length) : ""; |
| 123 | rawLog(t(), `[${fileName}]${spaces}\t`, ...args); |
| 124 | } catch (e) { |
| 125 | rawLog(t(), ...args); |
| 126 | } |
| 127 | }; |
| 128 | |
| 129 | // @ts-ignore |
| 130 | console.rawInfo = console.info.bind(console); |