Skip to content

Commit

Permalink
minor logging changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ntotten committed Jan 28, 2020
1 parent 85e18af commit c5a04f6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/LoggingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,16 @@ export class LoggingService {
}
}

public logError(message: string, error?: Error | string) {
public logError(message: string, error?: Error) {
if (this.logLevel === "NONE") {
return;
}
this.logMessage(message, "ERROR");
if (error instanceof Error) {
if (error.message) {
this.outputChannel.appendLine(error.message);
}
if (error.stack) {
this.outputChannel.appendLine(error.stack);
}
} else if (error) {
this.outputChannel.appendLine(error);
if (error?.message) {
this.logMessage(error.message, "ERROR");
}
if (error?.stack) {
this.outputChannel.appendLine(error.stack);
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/ModuleResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ export class ModuleResolver implements Disposable {
return { moduleInstance, modulePath };
}
} catch (error) {
this.loggingService.logError(`Failed to load ${pkgName}.`, error);
this.loggingService.logError(
`Failed to load local module ${pkgName}.`,
error
);
if (options?.showNotifications) {
this.notificationService.showErrorMessage(
FAILED_TO_LOAD_MODULE_MESSAGE,
Expand Down Expand Up @@ -245,7 +248,7 @@ export class ModuleResolver implements Disposable {
}
} catch (error) {
this.loggingService.logError(
`Failed to load ${pkgName} from '${modulePath}'`,
`Failed to load global module ${pkgName}.`,
error
);
return { moduleInstance: undefined, modulePath };
Expand Down

0 comments on commit c5a04f6

Please sign in to comment.