forwarding: fix log format again (#191941)

Fixes #191759
This commit is contained in:
Connor Peet
2023-09-01 09:38:20 -07:00
committed by GitHub
parent 67e9d1be31
commit a8b8e3a143
2 changed files with 13 additions and 13 deletions

View File

@@ -323,8 +323,8 @@ fn format(level: Level, prefix: &str, message: &str, use_colors: bool) -> String
} }
pub fn emit(level: Level, prefix: &str, message: &str) { pub fn emit(level: Level, prefix: &str, message: &str) {
let line = format(level, prefix, message, true); let line = format(level, prefix, message, *COLORS_ENABLED);
if level == Level::Trace { if level == Level::Trace && *COLORS_ENABLED {
print!("\x1b[2m{}\x1b[0m", line); print!("\x1b[2m{}\x1b[0m", line);
} else { } else {
print!("{}", line); print!("{}", line);

View File

@@ -231,8 +231,8 @@ class TunnelProvider implements vscode.TunnelProvider {
]; ];
this.logger.log('info', '[forwarding] starting CLI'); this.logger.log('info', '[forwarding] starting CLI');
const process = spawn(cliPath, args, { stdio: 'pipe' }); const child = spawn(cliPath, args, { stdio: 'pipe', env: { ...process.env, NO_COLOR: '1' } });
this.state = { state: State.Starting, process }; this.state = { state: State.Starting, process: child };
const progressP = new DeferredPromise<void>(); const progressP = new DeferredPromise<void>();
vscode.window.withProgress( vscode.window.withProgress(
@@ -248,29 +248,29 @@ class TunnelProvider implements vscode.TunnelProvider {
); );
let lastPortFormat: string | undefined; let lastPortFormat: string | undefined;
process.on('exit', status => { child.on('exit', status => {
const msg = `[forwarding] exited with code ${status}`; const msg = `[forwarding] exited with code ${status}`;
this.logger.log('info', msg); this.logger.log('info', msg);
progressP.complete(); // make sure to clear progress on unexpected exit progressP.complete(); // make sure to clear progress on unexpected exit
if (this.isInStateWithProcess(process)) { if (this.isInStateWithProcess(child)) {
this.state = { state: State.Error, error: msg }; this.state = { state: State.Error, error: msg };
} }
}); });
process.on('error', err => { child.on('error', err => {
this.logger.log('error', `[forwarding] ${err}`); this.logger.log('error', `[forwarding] ${err}`);
progressP.complete(); // make sure to clear progress on unexpected exit progressP.complete(); // make sure to clear progress on unexpected exit
if (this.isInStateWithProcess(process)) { if (this.isInStateWithProcess(child)) {
this.state = { state: State.Error, error: String(err) }; this.state = { state: State.Error, error: String(err) };
} }
}); });
process.stdout child.stdout
.pipe(splitNewLines()) .pipe(splitNewLines())
.on('data', line => this.logger.log('info', `[forwarding] ${line}`)) .on('data', line => this.logger.log('info', `[forwarding] ${line}`))
.resume(); .resume();
process.stderr child.stderr
.pipe(splitNewLines()) .pipe(splitNewLines())
.on('data', line => { .on('data', line => {
try { try {
@@ -278,7 +278,7 @@ class TunnelProvider implements vscode.TunnelProvider {
if (l.port_format && l.port_format !== lastPortFormat) { if (l.port_format && l.port_format !== lastPortFormat) {
this.state = { this.state = {
state: State.Active, state: State.Active,
portFormat: l.port_format, process, portFormat: l.port_format, process: child,
cleanupTimeout: 'cleanupTimeout' in this.state ? this.state.cleanupTimeout : undefined, cleanupTimeout: 'cleanupTimeout' in this.state ? this.state.cleanupTimeout : undefined,
}; };
progressP.complete(); progressP.complete();
@@ -290,8 +290,8 @@ class TunnelProvider implements vscode.TunnelProvider {
.resume(); .resume();
await new Promise((resolve, reject) => { await new Promise((resolve, reject) => {
process.on('spawn', resolve); child.on('spawn', resolve);
process.on('error', reject); child.on('error', reject);
}); });
} }
} }