mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
add logging for data workspace extension (#20601)
* add logging for data workspace extension * Addressing comments * adding back getProjectsInWorkspace() in constructor * Add more logging in activate()
This commit is contained in:
@@ -33,6 +33,7 @@ export const Select = localize('dataworkspace.select', "Select");
|
||||
export const WorkspaceFileExtension = '.code-workspace';
|
||||
export const DefaultInputWidth = '400px';
|
||||
export const DefaultButtonWidth = '80px';
|
||||
export const DataWorkspaceOutputChannel = 'Data Workspace';
|
||||
|
||||
// New Project Dialog
|
||||
export const NewProjectDialogTitle = localize('dataworkspace.NewProjectDialogTitle', "Create new database project");
|
||||
|
||||
@@ -2,10 +2,37 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as vscode from 'vscode';
|
||||
import { DataWorkspaceOutputChannel } from './constants';
|
||||
|
||||
export class Log {
|
||||
error(msg: string): void {
|
||||
console.error(msg);
|
||||
private output: vscode.OutputChannel;
|
||||
|
||||
constructor() {
|
||||
this.output = vscode.window.createOutputChannel(DataWorkspaceOutputChannel);
|
||||
}
|
||||
|
||||
error(message: string): void {
|
||||
this.output.appendLine(`[Error - ${this.now()}] ${message}`);
|
||||
console.error(message);
|
||||
}
|
||||
|
||||
log(message: string): void {
|
||||
this.output.appendLine(`[Info - ${this.now()}] ${message}`);
|
||||
}
|
||||
|
||||
private now(): string {
|
||||
const now = new Date();
|
||||
return this.padLeft(now.getUTCFullYear() + '', 2, '0')
|
||||
+ '-' + this.padLeft(now.getUTCMonth() + '', 2, '0')
|
||||
+ '-' + this.padLeft(now.getUTCDate() + '', 2, '0')
|
||||
+ ' ' + this.padLeft(now.getUTCHours() + '', 2, '0')
|
||||
+ ':' + this.padLeft(now.getMinutes() + '', 2, '0')
|
||||
+ ':' + this.padLeft(now.getUTCSeconds() + '', 2, '0') + '.' + now.getMilliseconds();
|
||||
}
|
||||
|
||||
private padLeft(s: string, n: number, pad = ' ') {
|
||||
return pad.repeat(Math.max(0, n - s.length)) + s;
|
||||
}
|
||||
}
|
||||
const Logger = new Log();
|
||||
|
||||
@@ -9,6 +9,7 @@ import { IWorkspaceService } from './interfaces';
|
||||
import { ProjectsFailedToLoad, UnknownProjectsError } from './constants';
|
||||
import { WorkspaceTreeItem } from 'dataworkspace';
|
||||
import { TelemetryReporter } from './telemetry';
|
||||
import Logger from './logger';
|
||||
|
||||
/**
|
||||
* Tree data provider for the workspace main view
|
||||
@@ -24,6 +25,7 @@ export class WorkspaceTreeDataProvider implements vscode.TreeDataProvider<Worksp
|
||||
readonly onDidChangeTreeData?: vscode.Event<void | WorkspaceTreeItem | null | undefined> | undefined = this._onDidChangeTreeData?.event;
|
||||
|
||||
async refresh(): Promise<void> {
|
||||
Logger.log(`Refreshing projects tree`);
|
||||
await this._workspaceService.getProjectsInWorkspace(undefined, true);
|
||||
this._onDidChangeTreeData?.fire();
|
||||
}
|
||||
@@ -39,6 +41,7 @@ export class WorkspaceTreeDataProvider implements vscode.TreeDataProvider<Worksp
|
||||
}
|
||||
else {
|
||||
// if the element is undefined return the project tree items
|
||||
Logger.log(`Calling getProjectsInWorkspace() from getChildren()`);
|
||||
const projects = await this._workspaceService.getProjectsInWorkspace(undefined, false);
|
||||
await vscode.commands.executeCommand('setContext', 'isProjectsViewEmpty', projects.length === 0);
|
||||
const unknownProjects: string[] = [];
|
||||
|
||||
Reference in New Issue
Block a user