(type: LogLevelStrings, str: string)
| 112 | } |
| 113 | |
| 114 | public writeLog(type: LogLevelStrings, str: string): void { |
| 115 | const level = LOG_LEVEL[type]; |
| 116 | |
| 117 | // Drop log |
| 118 | if (level < this.logLevel) { |
| 119 | return; |
| 120 | } |
| 121 | |
| 122 | const logStr = Logger.formatStr(str, type, { |
| 123 | levelLimit: this.logLevel |
| 124 | }); |
| 125 | |
| 126 | // Store log |
| 127 | Logger.fillBuffer(type, logStr); |
| 128 | |
| 129 | if (this.winstonLogger) { |
| 130 | const winstonLogType = Logger.getWinstonType(type); |
| 131 | this.winstonLogger.log(`${winstonLogType}`, logStr); |
| 132 | } |
| 133 | |
| 134 | if (isInspect()) { |
| 135 | // When started with inspect, log will send to 2 places |
| 136 | // 1. Local stdout |
| 137 | // 2. Remote(maybe chrome inspect window) inspect window |
| 138 | |
| 139 | // Here for remote window |
| 140 | Logger.fillInspect(logStr, level); |
| 141 | |
| 142 | const logWithColor = Logger.formatStr(str, type, { |
| 143 | levelLimit: this.logLevel, |
| 144 | color: true |
| 145 | }); |
| 146 | |
| 147 | // Here for local stdout, with color |
| 148 | Logger.fillStdout(logWithColor); |
| 149 | } else { |
| 150 | // Send to local stdout |
| 151 | Logger.fillStdout(logStr); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Convert TSW log level to winston log level |
no test coverage detected