Skip to content
This repository has been archived by the owner on Oct 10, 2018. It is now read-only.

fix(logging): output panel does not pop up when tsh starts #401

Merged
merged 3 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/code-outline/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default class CodeOutline implements Activatable, TreeDataProvider<BaseSt
) { }

public setup(): void {
this.logger.debug('Setting up CodeOutline.');
this.logger.debug('[CodeOutline] Setting up CodeOutline.');
this.context.subscriptions.push(this.config.configurationChanged(() => {
if (this.config.codeOutline.isEnabled() && !this.disposables) {
this.start();
Expand All @@ -61,10 +61,10 @@ export default class CodeOutline implements Activatable, TreeDataProvider<BaseSt

public start(): void {
if (!this.config.codeOutline.isEnabled()) {
this.logger.info(`Not starting CodeOutline. It's disabled by config.`);
this.logger.info(`[CodeOutline] Not starting CodeOutline. It's disabled by config.`);
return;
}
this.logger.info('Starting up CodeOutline.');
this.logger.info('[CodeOutline] Starting up CodeOutline.');
this._onDidChangeTreeData = new EventEmitter<BaseStructureTreeItem | undefined>();
this.disposables.push(window.registerTreeDataProvider('codeOutline', this));
this.disposables.push(this._onDidChangeTreeData);
Expand All @@ -74,18 +74,18 @@ export default class CodeOutline implements Activatable, TreeDataProvider<BaseSt

public stop(): void {
if (this.config.codeOutline.isEnabled()) {
this.logger.info(`Not stopping CodeOutline. It's enabled by config.`);
this.logger.info(`[CodeOutline] Not stopping CodeOutline. It's enabled by config.`);
return;
}
this.logger.info('Stopping CodeOutline.');
this.logger.info('[CodeOutline] Stopping CodeOutline.');
for (const disposable of this.disposables) {
disposable.dispose();
}
this.disposables = [];
}

public dispose(): void {
this.logger.debug('Disposing CodeOutline.');
this.logger.debug('[CodeOutline] Disposing CodeOutline.');
for (const disposable of this.disposables) {
disposable.dispose();
}
Expand Down Expand Up @@ -119,7 +119,7 @@ export default class CodeOutline implements Activatable, TreeDataProvider<BaseSt
);
} catch (e) {
this.logger.error(
`[CodeOutline] document could not be parsed, error: ${e}`,
`[CodeOutline] Document could not be parsed, error: ${e}`,
);
return [];
}
Expand Down
18 changes: 9 additions & 9 deletions src/declarations/declaration-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class DeclarationManager implements Disposable {

@postConstruct()
public setup(): void {
this.logger.debug('Setting up DeclarationManager.');
this.logger.debug('[DeclarationManager] Setting up DeclarationManager.');
this.statusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 4);
this.statusBarItem.text = ResolverState.ok;
this.statusBarItem.show();
Expand All @@ -59,15 +59,15 @@ export default class DeclarationManager implements Disposable {
public getIndexForFile(fileUri: Uri): DeclarationIndex | undefined {
const workspaceFolder = workspace.getWorkspaceFolder(fileUri);
if (!workspaceFolder || !this.workspaces[workspaceFolder.uri.fsPath]) {
this.logger.debug('Did not find index for file', { file: fileUri.fsPath });
this.logger.debug('[DeclarationManager] Did not find index for file', { file: fileUri.fsPath });
return;
}

return this.workspaces[workspaceFolder.uri.fsPath].index;
}

public dispose(): void {
this.logger.debug('Disposing DeclarationManager.');
this.logger.debug('[DeclarationManager] Disposing DeclarationManager.');
for (const folder of Object.values(this.workspaces)) {
folder.dispose();
}
Expand All @@ -85,14 +85,14 @@ export default class DeclarationManager implements Disposable {
const removed = event.removed.filter(e => 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;
Expand All @@ -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;
}
}
Expand Down
25 changes: 17 additions & 8 deletions src/declarations/workspace-declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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,
Expand All @@ -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 },
);
}
Expand Down Expand Up @@ -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,
Expand All @@ -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'),
});
Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/import-organizer/import-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 },
);

Expand Down
36 changes: 18 additions & 18 deletions src/import-organizer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
);
Expand All @@ -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(
Expand All @@ -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.');
}

/**
Expand All @@ -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 },
);
Expand Down Expand Up @@ -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.');
Expand All @@ -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;
}
Expand All @@ -175,15 +175,15 @@ 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(
`The symbol '${selectedSymbol}' was not found in the index or is already imported.`,
);
} 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,
Expand All @@ -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,
Expand All @@ -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.');
Expand Down Expand Up @@ -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 },
);

Expand Down Expand Up @@ -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.');
}
Expand Down
Loading