diff --git a/src/code-outline/index.ts b/src/code-outline/index.ts index 6b9ea51..b1f8b28 100644 --- a/src/code-outline/index.ts +++ b/src/code-outline/index.ts @@ -45,7 +45,7 @@ export default class CodeOutline implements Activatable, TreeDataProvider { if (this.config.codeOutline.isEnabled() && !this.disposables) { this.start(); @@ -61,10 +61,10 @@ export default class CodeOutline implements Activatable, TreeDataProvider(); this.disposables.push(window.registerTreeDataProvider('codeOutline', this)); this.disposables.push(this._onDidChangeTreeData); @@ -74,10 +74,10 @@ export default class CodeOutline implements Activatable, TreeDataProvider e.uri.scheme === 'file'); this.logger.info( - 'Workspaces changed, adjusting indices', + '[DeclarationManager] Workspaces changed, adjusting indices', { added: added.map(e => e.uri.fsPath), removed: removed.map(e => e.uri.fsPath) }, ); for (const add of event.added) { if (this.workspaces[add.uri.fsPath]) { this.logger.warn( - 'Workspace index already exists, skipping', + '[DeclarationManager] Workspace index already exists, skipping', { workspace: add.uri.fsPath }, ); continue; @@ -111,22 +111,22 @@ export default class DeclarationManager implements Disposable { return; } if (state === WorkspaceDeclarationsState.Error) { - this.logger.error('A workspace did encounter an error.'); + this.logger.error('[DeclarationManager] A workspace did encounter an error.'); this.statusBarItem.text = ResolverState.error; return; } if (state === WorkspaceDeclarationsState.Syncing) { - this.logger.debug('A workspace is syncing it\'s files.'); + this.logger.debug('[DeclarationManager] A workspace is syncing it\'s files.'); this.activeWorkspaces++; this.statusBarItem.text = ResolverState.syncing; return; } if (state === WorkspaceDeclarationsState.Idle) { - this.logger.debug('A workspace is done syncing it\'s files.'); + this.logger.debug('[DeclarationManager] A workspace is done syncing it\'s files.'); this.activeWorkspaces--; } if (this.activeWorkspaces <= 0) { - this.logger.debug('All workspaces are done syncing.'); + this.logger.debug('[DeclarationManager] All workspaces are done syncing.'); this.statusBarItem.text = ResolverState.ok; } } diff --git a/src/declarations/workspace-declarations.ts b/src/declarations/workspace-declarations.ts index 56aa82f..2f8c736 100644 --- a/src/declarations/workspace-declarations.ts +++ b/src/declarations/workspace-declarations.ts @@ -44,13 +44,19 @@ export default class WorkspaceDeclarations implements Disposable { constructor( private readonly folder: WorkspaceFolder, ) { - this.logger.debug('Creating workspace declarations index.', { workspace: this.folder.uri.fsPath }); + this.logger.debug( + '[WorkspaceDeclarations] Creating workspace declarations index.', + { workspace: this.folder.uri.fsPath }, + ); this.disposables.push(this._workspaceStateChanged); this.initialize(); } public dispose(): void { - this.logger.debug('Disposing workspace declarations index.', { workspace: this.folder.uri.fsPath }); + this.logger.debug( + '[WorkspaceDeclarations] Disposing workspace declarations index.', + { workspace: this.folder.uri.fsPath }, + ); for (const disposable of this.disposables) { disposable.dispose(); } @@ -63,7 +69,10 @@ export default class WorkspaceDeclarations implements Disposable { this._index = new DeclarationIndex(this.parser, this.folder.uri.fsPath); const files = await this.findFiles(); - this.logger.info(`Found ${files.length} files in workspace.`, { workspace: this.folder.uri.fsPath }); + this.logger.info( + `[WorkspaceDeclarations] Found ${files.length} files in workspace.`, + { workspace: this.folder.uri.fsPath }, + ); const watcher = workspace.createFileSystemWatcher( new RelativePattern( this.folder, @@ -82,13 +91,13 @@ export default class WorkspaceDeclarations implements Disposable { this._workspaceStateChanged.fire(WorkspaceDeclarationsState.Idle); profiler.done({ - message: 'Built index for workspace.', + message: '[WorkspaceDeclarations] Built index for workspace.', workspace: this.folder.uri.fsPath, }); } catch (error) { this._workspaceStateChanged.fire(WorkspaceDeclarationsState.Error); this.logger.error( - 'Error during indexing of workspacefiles.', + '[WorkspaceDeclarations] Error during indexing of workspacefiles.', { error: error.toString(), workspace: this.folder.uri.fsPath }, ); } @@ -151,7 +160,7 @@ export default class WorkspaceDeclarations implements Disposable { 'typings/**/*', ]; const moduleExcludes = this.config.index.moduleIgnorePatterns(this.folder.uri); - this.logger.debug('Calculated excludes for workspace.', { + this.logger.debug('[WorkspaceDeclarations] Calculated excludes for workspace.', { workspaceExcludes, moduleExcludes, workspace: this.folder.uri.fsPath, @@ -168,7 +177,7 @@ export default class WorkspaceDeclarations implements Disposable { const hasPackageJson = await exists(join(rootPath, 'package.json')); if (rootPath && hasPackageJson) { - this.logger.debug('Found package.json, calculate searchable node modules.', { + this.logger.debug('[WorkspaceDeclarations] Found package.json, calculate searchable node modules.', { workspace: this.folder.uri.fsPath, packageJson: join(rootPath, 'package.json'), }); @@ -194,7 +203,7 @@ export default class WorkspaceDeclarations implements Disposable { } } - this.logger.debug('Calculated node module search.', { + this.logger.debug('[WorkspaceDeclarations] Calculated node module search.', { globs, ignores, workspace: this.folder.uri.fsPath, diff --git a/src/import-organizer/import-manager.ts b/src/import-organizer/import-manager.ts index 0de1ed5..50c7a1c 100644 --- a/src/import-organizer/import-manager.ts +++ b/src/import-organizer/import-manager.ts @@ -100,7 +100,7 @@ export default class ImportManager { private readonly generatorFactory: TypescriptCodeGeneratorFactory, ) { this.logger.debug( - `Create import manager`, + `[ImportManager] Create import manager`, { file: document.fileName }, ); this.reset(); @@ -129,7 +129,7 @@ export default class ImportManager { */ public organizeImports(): this { this.logger.debug( - 'Organize the imports', + '[ImportManager] Organize the imports', { file: this.document.fileName }, ); this.organize = true; @@ -212,7 +212,7 @@ export default class ImportManager { */ public addDeclarationImport(declarationInfo: DeclarationInfo): this { this.logger.debug( - 'Add declaration as import', + '[ImportManager] Add declaration as import', { file: this.document.fileName, specifier: declarationInfo.declaration.name, library: declarationInfo.from }, ); // If there is something already imported, it must be a NamedImport @@ -272,7 +272,7 @@ export default class ImportManager { workspaceEdit.set(this.document.uri, edits); this.logger.debug( - 'Commit the file', + '[ImportManager] Commit the file', { file: this.document.fileName }, ); diff --git a/src/import-organizer/index.ts b/src/import-organizer/index.ts index 6930804..d34116a 100644 --- a/src/import-organizer/index.ts +++ b/src/import-organizer/index.ts @@ -24,7 +24,7 @@ export default class ImportOrganizer implements Activatable { ) { } public setup(): void { - this.logger.debug('Setting up ImportOrganizer.'); + this.logger.debug('[ImportOrganizer] Setting up ImportOrganizer.'); this.context.subscriptions.push( commands.registerTextEditorCommand('typescriptHero.imports.organize', () => this.organizeImports()), ); @@ -41,20 +41,20 @@ export default class ImportOrganizer implements Activatable { workspace.onWillSaveTextDocument((event) => { if (!this.config.imports.organizeOnSave(event.document.uri)) { this.logger.debug( - 'OrganizeOnSave is deactivated through config', + '[ImportOrganizer] OrganizeOnSave is deactivated through config', ); return; } if (this.config.parseableLanguages().indexOf(event.document.languageId) < 0) { this.logger.debug( - 'OrganizeOnSave not possible for given language', + '[ImportOrganizer] OrganizeOnSave not possible for given language', { language: event.document.languageId }, ); return; } this.logger.info( - 'OrganizeOnSave for file', + '[ImportOrganizer] OrganizeOnSave for file', { file: event.document.fileName }, ); event.waitUntil( @@ -65,15 +65,15 @@ export default class ImportOrganizer implements Activatable { } public start(): void { - this.logger.info('Starting up ImportOrganizer.'); + this.logger.info('[ImportOrganizer] Starting up ImportOrganizer.'); } public stop(): void { - this.logger.info('Stopping ImportOrganizer.'); + this.logger.info('[ImportOrganizer] Stopping ImportOrganizer.'); } public dispose(): void { - this.logger.debug('Disposing ImportOrganizer.'); + this.logger.debug('[ImportOrganizer] Disposing ImportOrganizer.'); } /** @@ -90,14 +90,14 @@ export default class ImportOrganizer implements Activatable { } try { this.logger.debug( - 'Organize the imports in the document', + '[ImportOrganizer] Organize the imports in the document', { file: window.activeTextEditor.document.fileName }, ); const ctrl = await this.importManagerProvider(window.activeTextEditor.document); await ctrl.organizeImports().commit(); } catch (e) { this.logger.error( - 'Imports could not be organized, error: %s', + '[ImportOrganizer] Imports could not be organized, error: %s', e, { file: window.activeTextEditor.document.fileName }, ); @@ -129,14 +129,14 @@ export default class ImportOrganizer implements Activatable { ); if (selectedItem) { this.logger.info( - 'Add import to document', + '[ImportOrganizer] Add import to document', { specifier: selectedItem.declarationInfo.declaration.name, library: selectedItem.declarationInfo.from }, ); this.addImportToDocument(selectedItem.declarationInfo); } } catch (e) { this.logger.error( - 'Import could not be added to document', + '[ImportOrganizer] Import could not be added to document', { file: window.activeTextEditor.document.fileName, error: e.toString() }, ); window.showErrorMessage('The import cannot be completed, there was an error during the process.'); @@ -163,7 +163,7 @@ export default class ImportOrganizer implements Activatable { } try { const selectedSymbol = this.getSymbolUnderCursor(); - this.logger.debug('Add import for symbol under cursor', { selectedSymbol }); + this.logger.debug('[ImportOrganizer] Add import for symbol under cursor', { selectedSymbol }); if (!!!selectedSymbol) { return; } @@ -175,7 +175,7 @@ export default class ImportOrganizer implements Activatable { if (resolveItems.length < 1) { this.logger.info( - 'The symbol was not found or is already imported', + '[ImportOrganizer] The symbol was not found or is already imported', { selectedSymbol }, ); window.showInformationMessage( @@ -183,7 +183,7 @@ export default class ImportOrganizer implements Activatable { ); } else if (resolveItems.length === 1 && resolveItems[0].declaration.name === selectedSymbol) { this.logger.info( - 'Add import to document', + '[ImportOrganizer] Add import to document', { specifier: resolveItems[0].declaration.name, library: resolveItems[0].from, @@ -196,7 +196,7 @@ export default class ImportOrganizer implements Activatable { ); if (selectedItem) { this.logger.info( - 'Add import to document', + '[ImportOrganizer] Add import to document', { specifier: selectedItem.declarationInfo.declaration.name, library: selectedItem.declarationInfo.from, @@ -207,7 +207,7 @@ export default class ImportOrganizer implements Activatable { } } catch (e) { this.logger.error( - 'Import could not be added to document.', + '[ImportOrganizer] Import could not be added to document.', { file: window.activeTextEditor.document.fileName, error: e.toString() }, ); window.showErrorMessage('The import cannot be completed, there was an error during the process.'); @@ -239,7 +239,7 @@ export default class ImportOrganizer implements Activatable { } this.logger.debug( - 'Calculate possible imports for document', + '[ImportOrganizer] Calculate possible imports for document', { cursorSymbol, file: documentPath }, ); @@ -303,7 +303,7 @@ export default class ImportOrganizer implements Activatable { */ private showCacheWarning(): void { this.logger.warn( - 'index was not ready or not index for this file found', + '[ImportOrganizer] Index was not ready or not index for this file found', ); window.showWarningMessage('Please wait a few seconds longer until the symbol cache has been build.'); } diff --git a/src/typescript-hero.ts b/src/typescript-hero.ts index b284621..17c7f92 100644 --- a/src/typescript-hero.ts +++ b/src/typescript-hero.ts @@ -14,7 +14,7 @@ export default class TypescriptHero implements Activatable { ) { } public setup(): void { - this.logger.debug('Setting up extension and activatables.'); + this.logger.debug('[TypescriptHero] Setting up extension and activatables.'); this.extendCodeGenerator(); for (const activatable of this.activatables) { activatable.setup(); @@ -22,21 +22,21 @@ export default class TypescriptHero implements Activatable { } public start(): void { - this.logger.debug('Starting up extension and activatables.'); + this.logger.debug('[TypescriptHero] Starting up extension and activatables.'); for (const activatable of this.activatables) { activatable.start(); } } public stop(): void { - this.logger.debug('Stopping extension and activatables.'); + this.logger.debug('[TypescriptHero] Stopping extension and activatables.'); for (const activatable of this.activatables) { activatable.stop(); } } public dispose(): void { - this.logger.debug('Disposing extension and activatables.'); + this.logger.debug('[TypescriptHero] Disposing extension and activatables.'); for (const activatable of this.activatables) { activatable.dispose(); } diff --git a/src/utilities/logger.ts b/src/utilities/logger.ts index 3cce418..6a49476 100644 --- a/src/utilities/logger.ts +++ b/src/utilities/logger.ts @@ -75,7 +75,6 @@ export default function winstonLogger(verbosity: keyof typeof levels, context: E if (!process.env.CI && !process.env.EXT_DEBUG && !process.env.LOCAL_TEST) { const channel = window.createOutputChannel('TypeScript Hero'); context.subscriptions.push(channel); - channel.show(); const fileHandler = new transports.File({ level: ['info', 'debug'].indexOf(level) >= 0 ? level : 'info', @@ -92,8 +91,6 @@ export default function winstonLogger(verbosity: keyof typeof levels, context: E loggerTransports.push(outputHandler); exceptions.handle(fileHandler); - // exceptions.handle(outputHandler); - // exceptions.handle(new HandleUncatchedException(context.extensionPath)); } const logger = createLogger({