11import { commands , Disposable } from "vscode" ;
22import { CommandFunction , CommandManager } from "../../packages/commands" ;
3- import { extLogger , OutputChannelLogger } from "../logging" ;
3+ import {
4+ extLogger ,
5+ NotificationLogger ,
6+ showAndLogWarningMessage ,
7+ } from "../logging" ;
48import {
59 asError ,
610 getErrorMessage ,
@@ -9,20 +13,17 @@ import {
913import { redactableError } from "../../pure/errors" ;
1014import { UserCancellationException } from "./progress" ;
1115import { telemetryListener } from "../../telemetry" ;
12- import {
13- showAndLogExceptionWithTelemetry ,
14- showAndLogWarningMessage ,
15- } from "./log" ;
16+ import { showAndLogExceptionWithTelemetry } from "./logging" ;
1617
1718/**
1819 * Create a command manager for VSCode, wrapping registerCommandWithErrorHandling
1920 * and vscode.executeCommand.
2021 */
2122export function createVSCodeCommandManager <
2223 Commands extends Record < string , CommandFunction > ,
23- > ( outputLogger ?: OutputChannelLogger ) : CommandManager < Commands > {
24+ > ( logger ?: NotificationLogger ) : CommandManager < Commands > {
2425 return new CommandManager ( ( commandId , task ) => {
25- return registerCommandWithErrorHandling ( commandId , task , outputLogger ) ;
26+ return registerCommandWithErrorHandling ( commandId , task , logger ) ;
2627 } , wrapExecuteCommand ) ;
2728}
2829
@@ -32,11 +33,12 @@ export function createVSCodeCommandManager<
3233 * @param commandId The ID of the command to register.
3334 * @param task The task to run. It is passed directly to `commands.registerCommand`. Any
3435 * arguments to the command handler are passed on to the task.
36+ * @param logger The logger to use for error reporting.
3537 */
3638export function registerCommandWithErrorHandling (
3739 commandId : string ,
3840 task : ( ...args : any [ ] ) => Promise < any > ,
39- outputLogger = extLogger ,
41+ logger : NotificationLogger = extLogger ,
4042) : Disposable {
4143 return commands . registerCommand ( commandId , async ( ...args : any [ ] ) => {
4244 const startTime = Date . now ( ) ;
@@ -52,20 +54,17 @@ export function registerCommandWithErrorHandling(
5254 if ( e instanceof UserCancellationException ) {
5355 // User has cancelled this action manually
5456 if ( e . silent ) {
55- void outputLogger . log ( errorMessage . fullMessage ) ;
57+ void logger . log ( errorMessage . fullMessage ) ;
5658 } else {
57- void showAndLogWarningMessage ( errorMessage . fullMessage , {
58- outputLogger,
59- } ) ;
59+ void showAndLogWarningMessage ( logger , errorMessage . fullMessage ) ;
6060 }
6161 } else {
6262 // Include the full stack in the error log only.
6363 const errorStack = getErrorStack ( e ) ;
6464 const fullMessage = errorStack
6565 ? `${ errorMessage . fullMessage } \n${ errorStack } `
6666 : errorMessage . fullMessage ;
67- void showAndLogExceptionWithTelemetry ( errorMessage , {
68- outputLogger,
67+ void showAndLogExceptionWithTelemetry ( logger , errorMessage , {
6968 fullMessage,
7069 extraTelemetryProperties : {
7170 command : commandId ,
0 commit comments