diff --git a/src/sql/base/browser/ui/table/plugins/autoSizeColumns.plugin.ts b/src/sql/base/browser/ui/table/plugins/autoSizeColumns.plugin.ts index e111e61f86..aaddfe28aa 100644 --- a/src/sql/base/browser/ui/table/plugins/autoSizeColumns.plugin.ts +++ b/src/sql/base/browser/ui/table/plugins/autoSizeColumns.plugin.ts @@ -1,7 +1,8 @@ // Adapted from https://github.com/naresh-n/slickgrid-column-data-autosize/blob/master/src/slick.autocolumnsize.js -import { mixin, clone } from 'sql/base/common/objects'; +import { mixin } from 'sql/base/common/objects'; import { isInDOM } from 'vs/base/browser/dom'; +import { deepClone } from 'vs/base/common/objects'; export interface IAutoColumnSizeOptions extends Slick.PluginOptions { maxWidth?: number; @@ -71,7 +72,7 @@ export class AutoColumnSize implements Slick.Plugin { if (headerColumnsQuery && headerColumnsQuery.length) { let headerColumns = headerColumnsQuery[0]; let origCols = this._grid.getColumns(); - let allColumns = clone(origCols); + let allColumns = deepClone(origCols); allColumns.forEach((col, index) => { col.formatter = origCols[index].formatter; col.asyncPostRender = origCols[index].asyncPostRender; @@ -117,7 +118,7 @@ export class AutoColumnSize implements Slick.Plugin { let headerWidth = this.getElementWidth(headerEl[0]); let colIndex = this._grid.getColumnIndex(columnDef.id!); let origCols = this._grid.getColumns(); - let allColumns = clone(origCols); + let allColumns = deepClone(origCols); allColumns.forEach((col, index) => { col.formatter = origCols[index].formatter; col.asyncPostRender = origCols[index].asyncPostRender; diff --git a/src/sql/base/common/log.ts b/src/sql/base/common/log.ts deleted file mode 100644 index d9c4558bc4..0000000000 --- a/src/sql/base/common/log.ts +++ /dev/null @@ -1,16 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the Source EULA. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -export function log(...args: any[]): void { - console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args); -} - -export function warn(...args: any[]): void { - console.warn(`\x1b[93m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args); -} - -export function error(...args: any[]) { - console.error(`\x1b[91m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, ...args); -} diff --git a/src/sql/base/common/objects.ts b/src/sql/base/common/objects.ts index 2037d64d53..ceac97619f 100644 --- a/src/sql/base/common/objects.ts +++ b/src/sql/base/common/objects.ts @@ -5,25 +5,6 @@ import * as Types from 'vs/base/common/types'; -export function clone(obj: T): T { - if (!obj || typeof obj !== 'object') { - return obj; - } - if (obj instanceof RegExp) { - // See https://github.com/Microsoft/TypeScript/issues/10990 - return obj as any; - } - const result = (Array.isArray(obj)) ? [] : {}; - Object.keys(obj).forEach(key => { - if (obj[key] && typeof obj[key] === 'object') { - result[key] = clone(obj[key]); - } else { - result[key] = obj[key]; - } - }); - return result; -} - /** * A copy of the vs mixin that accepts a custom behavior function */ diff --git a/src/sql/platform/accounts/browser/accountDialog.ts b/src/sql/platform/accounts/browser/accountDialog.ts index 7446c8ddf2..aaaa554b8c 100644 --- a/src/sql/platform/accounts/browser/accountDialog.ts +++ b/src/sql/platform/accounts/browser/accountDialog.ts @@ -33,7 +33,8 @@ import { AccountListRenderer, AccountListDelegate } from 'sql/platform/accounts/ import { AccountProviderAddedEventParams, UpdateAccountListEventParams } from 'sql/platform/accounts/common/eventTypes'; import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService'; import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; class AccountPanel extends ViewletPanel { public index: number; @@ -113,7 +114,7 @@ export class AccountDialog extends Modal { public get onCloseEvent(): Event { return this._onCloseEmitter.event; } constructor( - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, + @ILayoutService layoutService: ILayoutService, @IThemeService themeService: IThemeService, @IInstantiationService private _instantiationService: IInstantiationService, @IContextMenuService private _contextMenuService: IContextMenuService, @@ -121,7 +122,8 @@ export class AccountDialog extends Modal { @IConfigurationService private _configurationService: IConfigurationService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { super( localize('linkedAccounts', 'Linked accounts'), @@ -130,6 +132,7 @@ export class AccountDialog extends Modal { layoutService, clipboardService, themeService, + logService, contextKeyService, { hasSpinner: true } ); diff --git a/src/sql/platform/accounts/browser/autoOAuthDialog.ts b/src/sql/platform/accounts/browser/autoOAuthDialog.ts index 7cd71d54d8..7e2ceadc4c 100644 --- a/src/sql/platform/accounts/browser/autoOAuthDialog.ts +++ b/src/sql/platform/accounts/browser/autoOAuthDialog.ts @@ -21,7 +21,8 @@ import { attachModalDialogStyler, attachButtonStyler } from 'sql/platform/theme/ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; export class AutoOAuthDialog extends Modal { private _copyAndOpenButton: Button; @@ -42,12 +43,13 @@ export class AutoOAuthDialog extends Modal { public get onCloseEvent(): Event { return this._onCloseEvent.event; } constructor( - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, + @ILayoutService layoutService: ILayoutService, @IThemeService themeService: IThemeService, @IContextViewService private _contextViewService: IContextViewService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { super( '', @@ -56,6 +58,7 @@ export class AutoOAuthDialog extends Modal { layoutService, clipboardService, themeService, + logService, contextKeyService, { isFlyout: true, diff --git a/src/sql/platform/accounts/browser/firewallRuleDialog.ts b/src/sql/platform/accounts/browser/firewallRuleDialog.ts index 472bb336aa..ae6a34d5e8 100644 --- a/src/sql/platform/accounts/browser/firewallRuleDialog.ts +++ b/src/sql/platform/accounts/browser/firewallRuleDialog.ts @@ -28,6 +28,7 @@ import { attachModalDialogStyler, attachButtonStyler } from 'sql/platform/theme/ import { InputBox } from 'sql/base/browser/ui/inputBox/inputBox'; import { IAccountPickerService } from 'sql/platform/accounts/common/accountPicker'; import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; +import { ILogService } from 'vs/platform/log/common/log'; // TODO: Make the help link 1) extensible (01/08/2018, https://github.com/Microsoft/azuredatastudio/issues/450) // in case that other non-Azure sign in is to be used @@ -69,7 +70,8 @@ export class FirewallRuleDialog extends Modal { @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IWindowsService private _windowsService: IWindowsService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { super( localize('createNewFirewallRule', "Create new firewall rule"), @@ -78,6 +80,7 @@ export class FirewallRuleDialog extends Modal { layoutService, clipboardService, themeService, + logService, contextKeyService, { isFlyout: true, diff --git a/src/sql/platform/accounts/common/accountActions.ts b/src/sql/platform/accounts/common/accountActions.ts index 1caabce8c7..fe121c928d 100644 --- a/src/sql/platform/accounts/common/accountActions.ts +++ b/src/sql/platform/accounts/common/accountActions.ts @@ -8,11 +8,11 @@ import { Event, Emitter } from 'vs/base/common/event'; import { localize } from 'vs/nls'; import { Action } from 'vs/base/common/actions'; -import { error } from 'sql/base/common/log'; import { IAccountManagementService } from 'sql/platform/accounts/common/interfaces'; import { IDialogService, IConfirmation, IConfirmationResult } from 'vs/platform/dialogs/common/dialogs'; import { INotificationService } from 'vs/platform/notification/common/notification'; import Severity from 'vs/base/common/severity'; +import { ILogService } from 'vs/platform/log/common/log'; /** * Actions to add a new account @@ -34,7 +34,8 @@ export class AddAccountAction extends Action { constructor( private _providerId: string, - @IAccountManagementService private _accountManagementService: IAccountManagementService + @IAccountManagementService private _accountManagementService: IAccountManagementService, + @ILogService private readonly logService: ILogService ) { super(AddAccountAction.ID, AddAccountAction.LABEL); this.class = 'add-linked-account-action'; @@ -54,7 +55,7 @@ export class AddAccountAction extends Action { this._addAccountCompleteEmitter.fire(); return true; }, err => { - error(`Error while adding account: ${err}`); + this.logService.error(`Error while adding account: ${err}`); this._addAccountErrorEmitter.fire(err); this._addAccountCompleteEmitter.fire(); })); @@ -132,7 +133,8 @@ export class RefreshAccountAction extends Action { public account: azdata.Account; constructor( - @IAccountManagementService private _accountManagementService: IAccountManagementService + @IAccountManagementService private _accountManagementService: IAccountManagementService, + @ILogService private readonly logService: ILogService ) { super(RefreshAccountAction.ID, RefreshAccountAction.LABEL, 'refresh-account-action icon refresh'); } @@ -141,7 +143,7 @@ export class RefreshAccountAction extends Action { return Promise.resolve(this._accountManagementService.refreshAccount(this.account) .then(() => true, err => { - error(`Error while refreshing account: ${err}`); + this.logService.error(`Error while refreshing account: ${err}`); return Promise.reject(err); } )); diff --git a/src/sql/platform/angularEventing/node/angularEventingService.ts b/src/sql/platform/angularEventing/node/angularEventingService.ts index b69c442ab6..bd0cb94cb4 100644 --- a/src/sql/platform/angularEventing/node/angularEventingService.ts +++ b/src/sql/platform/angularEventing/node/angularEventingService.ts @@ -6,13 +6,17 @@ import { Subject } from 'rxjs/Subject'; import { Subscription } from 'rxjs/Subscription'; -import { warn } from 'sql/base/common/log'; import { IAngularEventingService, IAngularEvent, AngularEventType } from 'sql/platform/angularEventing/common/angularEventingService'; +import { ILogService } from 'vs/platform/log/common/log'; export class AngularEventingService implements IAngularEventingService { public _serviceBrand: any; private _angularMap = new Map>(); + constructor( + @ILogService private readonly logService: ILogService + ) { } + public onAngularEvent(uri: string, cb: (event: IAngularEvent) => void): Subscription { let subject = this._angularMap.get(uri); if (!subject) { @@ -26,7 +30,7 @@ export class AngularEventingService implements IAngularEventingService { public sendAngularEvent(uri: string, event: AngularEventType, payload?: any): void { const subject = this._angularMap.get(uri); if (!subject) { - warn('Got request to send an event to a dashboard that has not started listening'); + this.logService.warn('Got request to send an event to a dashboard that has not started listening'); } else { subject.next({ event, payload }); } diff --git a/src/sql/platform/backup/common/backupServiceImp.ts b/src/sql/platform/backup/common/backupServiceImp.ts index 8c65c42fd5..4fb03c2604 100644 --- a/src/sql/platform/backup/common/backupServiceImp.ts +++ b/src/sql/platform/backup/common/backupServiceImp.ts @@ -10,6 +10,7 @@ import * as TelemetryUtils from 'sql/platform/telemetry/telemetryUtilities'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IBackupService, TaskExecutionMode } from 'sql/platform/backup/common/backupService'; import { invalidProvider } from 'sql/base/common/errors'; +import { ILogService } from 'vs/platform/log/common/log'; export class BackupService implements IBackupService { @@ -18,7 +19,8 @@ export class BackupService implements IBackupService { constructor( @IConnectionManagementService private _connectionService: IConnectionManagementService, - @ITelemetryService private _telemetryService: ITelemetryService + @ITelemetryService private _telemetryService: ITelemetryService, + @ILogService private logService: ILogService ) { } @@ -43,7 +45,7 @@ export class BackupService implements IBackupService { return new Promise((resolve, reject) => { const providerResult = this.getProvider(connectionUri); if (providerResult) { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.BackupCreated, { provider: providerResult.providerName }); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.BackupCreated, { provider: providerResult.providerName }); providerResult.provider.backup(connectionUri, backupInfo, taskExecutionMode).then(result => { resolve(result); }, error => { diff --git a/src/sql/platform/connection/common/connectionManagementService.ts b/src/sql/platform/connection/common/connectionManagementService.ts index 2106551381..f801ae9d85 100644 --- a/src/sql/platform/connection/common/connectionManagementService.ts +++ b/src/sql/platform/connection/common/connectionManagementService.ts @@ -23,7 +23,6 @@ import { ConnectionGlobalStatus } from 'sql/workbench/parts/connection/common/co import { ConnectionStatusbarItem } from 'sql/workbench/parts/connection/browser/connectionStatus'; import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; import * as TelemetryUtils from 'sql/platform/telemetry/telemetryUtilities'; -import { warn } from 'sql/base/common/log'; import { IResourceProviderService } from 'sql/workbench/services/resourceProvider/common/resourceProviderService'; import { IAngularEventingService, AngularEventType } from 'sql/platform/angularEventing/common/angularEventingService'; import * as QueryConstants from 'sql/workbench/parts/query/common/constants'; @@ -52,6 +51,7 @@ import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput'; import { IConnectionDialogService } from 'sql/workbench/services/connection/common/connectionDialogService'; import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { ILogService } from 'vs/platform/log/common/log'; export class ConnectionManagementService extends Disposable implements IConnectionManagementService { @@ -86,7 +86,8 @@ export class ConnectionManagementService extends Disposable implements IConnecti @IStatusbarService private _statusBarService: IStatusbarService, @IResourceProviderService private _resourceProviderService: IResourceProviderService, @IAngularEventingService private _angularEventing: IAngularEventingService, - @IAccountManagementService private _accountManagementService: IAccountManagementService + @IAccountManagementService private _accountManagementService: IAccountManagementService, + @ILogService private logService: ILogService ) { super(); @@ -192,7 +193,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti self._connectionDialogService.showDialog(self, params, model, connectionResult).then(() => { resolve(); }, dialogError => { - warn('failed to open the connection dialog. error: ' + dialogError); + this.logService.warn('failed to open the connection dialog. error: ' + dialogError); reject(dialogError); }); }); @@ -351,7 +352,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti if (uri !== input.uri) { //TODO: this should never happen. If the input is already passed, it should have the uri - warn(`the given uri is different that the input uri. ${uri}|${input.uri}`); + this.logService.warn(`the given uri is different that the input uri. ${uri}|${input.uri}`); } return this.tryConnect(connection, input, options); } @@ -628,7 +629,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti } public saveProfileGroup(profile: IConnectionProfileGroup): Promise { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.AddServerGroup); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.AddServerGroup); return new Promise((resolve, reject) => { this._connectionStore.saveProfileGroup(profile).then(groupId => { this._onAddConnectionProfile.fire(undefined); @@ -857,7 +858,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti } private addTelemetryForConnection(connection: ConnectionManagementInfo): void { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.DatabaseConnected, { + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.DatabaseConnected, { connectionType: connection.serverInfo ? (connection.serverInfo.isCloud ? 'Azure' : 'Standalone') : '', provider: connection.connectionProfile.providerName, serverVersion: connection.serverInfo ? connection.serverInfo.serverVersion : '', @@ -869,7 +870,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti } private addTelemetryForConnectionDisconnected(connection: IConnectionProfile): void { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.DatabaseDisconnected, { + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.DatabaseDisconnected, { provider: connection.providerName }); } @@ -914,13 +915,13 @@ export class ConnectionManagementService extends Disposable implements IConnecti } public changeGroupIdForConnectionGroup(source: ConnectionProfileGroup, target: ConnectionProfileGroup): Promise { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.MoveServerConnection); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.MoveServerConnection); return this._connectionStore.changeGroupIdForConnectionGroup(source, target); } public changeGroupIdForConnection(source: ConnectionProfile, targetGroupId: string): Promise { let id = Utils.generateUri(source); - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.MoveServerGroup); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.MoveServerGroup); return this._connectionStore.changeGroupIdForConnection(source, targetGroupId).then(result => { if (id && targetGroupId) { source.groupId = targetGroupId; @@ -1204,7 +1205,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti */ public deleteConnection(connection: ConnectionProfile): Promise { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.DeleteConnection, {}, connection); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.DeleteConnection, {}, connection); // Disconnect if connected let uri = Utils.generateUri(connection); if (this.isConnected(uri) || this.isConnecting(uri)) { @@ -1242,7 +1243,7 @@ export class ConnectionManagementService extends Disposable implements IConnecti * Disconnects a connection before removing from config. If disconnect fails, settings is not modified. */ public deleteConnectionGroup(group: ConnectionProfileGroup): Promise { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.DeleteServerGroup); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.DeleteServerGroup); // Get all connections for this group let connections = ConnectionProfileGroup.getConnectionsInGroup(group); diff --git a/src/sql/platform/connection/common/connectionProfile.ts b/src/sql/platform/connection/common/connectionProfile.ts index 252c8a812d..8bc7edc53c 100644 --- a/src/sql/platform/connection/common/connectionProfile.ts +++ b/src/sql/platform/connection/common/connectionProfile.ts @@ -3,17 +3,15 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import { ConnectionProfileGroup } from 'sql/platform/connection/common/connectionProfileGroup'; import * as azdata from 'azdata'; import { ProviderConnectionInfo } from 'sql/platform/connection/common/providerConnectionInfo'; import * as interfaces from 'sql/platform/connection/common/interfaces'; import { equalsIgnoreCase } from 'vs/base/common/strings'; import { generateUuid } from 'vs/base/common/uuid'; -import * as objects from 'sql/base/common/objects'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import { isString } from 'vs/base/common/types'; +import { deepClone } from 'vs/base/common/objects'; // Concrete implementation of the IConnectionProfile interface @@ -217,7 +215,7 @@ export class ConnectionProfile extends ProviderConnectionInfo implements interfa connectionInfo.options = profile.options; // append group ID and original display name to build unique OE session ID - connectionInfo.options = objects.clone(profile.options); + connectionInfo.options = deepClone(profile.options); connectionInfo.options['groupId'] = connectionInfo.groupId; connectionInfo.options['databaseDisplayName'] = connectionInfo.databaseName; diff --git a/src/sql/platform/dialog/dialogModal.ts b/src/sql/platform/dialog/dialogModal.ts index e139def20b..34b9c432c6 100644 --- a/src/sql/platform/dialog/dialogModal.ts +++ b/src/sql/platform/dialog/dialogModal.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'vs/css!./media/dialogModal'; import { Modal, IModalOptions } from 'sql/workbench/browser/modal/modal'; import { attachModalDialogStyler } from 'sql/platform/theme/common/styler'; @@ -24,6 +22,7 @@ import { DialogMessage } from '../../workbench/api/common/sqlExtHostTypes'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { append, $ } from 'vs/base/browser/dom'; +import { ILogService } from 'vs/platform/log/common/log'; export class DialogModal extends Modal { private _dialogPane: DialogPane; @@ -43,9 +42,10 @@ export class DialogModal extends Modal { @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService, @IInstantiationService private _instantiationService: IInstantiationService ) { - super(_dialog.title, name, telemetryService, layoutService, clipboardService, themeService, contextKeyService, options); + super(_dialog.title, name, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, options); } public layout(): void { diff --git a/src/sql/platform/dialog/wizardModal.ts b/src/sql/platform/dialog/wizardModal.ts index 3d58d5ac56..33dbef5974 100644 --- a/src/sql/platform/dialog/wizardModal.ts +++ b/src/sql/platform/dialog/wizardModal.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'vs/css!./media/dialogModal'; import { Modal, IModalOptions } from 'sql/workbench/browser/modal/modal'; import { attachModalDialogStyler } from 'sql/platform/theme/common/styler'; @@ -15,7 +13,6 @@ import { DialogMessage } from 'sql/workbench/api/common/sqlExtHostTypes'; import { DialogModule } from 'sql/platform/dialog/dialog.module'; import { Button } from 'vs/base/browser/ui/button/button'; import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { attachButtonStyler } from 'vs/platform/theme/common/styler'; @@ -23,8 +20,10 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { Emitter } from 'vs/base/common/event'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { append, $ } from 'vs/base/browser/dom'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; export class WizardModal extends Modal { private _dialogPanes = new Map(); @@ -48,14 +47,15 @@ export class WizardModal extends Modal { private _wizard: Wizard, name: string, options: IModalOptions, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @IWorkbenchThemeService themeService: IWorkbenchThemeService, + @ILayoutService layoutService: ILayoutService, + @IThemeService themeService: IThemeService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IInstantiationService private _instantiationService: IInstantiationService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { - super(_wizard.title, name, telemetryService, layoutService, clipboardService, themeService, contextKeyService, options); + super(_wizard.title, name, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, options); this._useDefaultMessageBoxLocation = false; } diff --git a/src/sql/platform/query/common/queryManagement.ts b/src/sql/platform/query/common/queryManagement.ts index 55a4f58e57..4986562249 100644 --- a/src/sql/platform/query/common/queryManagement.ts +++ b/src/sql/platform/query/common/queryManagement.ts @@ -13,6 +13,7 @@ import * as TelemetryUtils from 'sql/platform/telemetry/telemetryUtilities'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { Event, Emitter } from 'vs/base/common/event'; import { keys } from 'vs/base/common/map'; +import { ILogService } from 'vs/platform/log/common/log'; export const SERVICE_ID = 'queryManagementService'; @@ -98,7 +99,8 @@ export class QueryManagementService implements IQueryManagementService { constructor( @IConnectionManagementService private _connectionService: IConnectionManagementService, - @ITelemetryService private _telemetryService: ITelemetryService + @ITelemetryService private _telemetryService: ITelemetryService, + @ILogService private logService: ILogService ) { } @@ -172,7 +174,7 @@ export class QueryManagementService implements IQueryManagementService { displayActualQueryPlan: runOptions.displayActualQueryPlan }); } - TelemetryUtils.addTelemetry(this._telemetryService, eventName, data); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, eventName, data); } private _runAction(uri: string, action: (handler: IQueryRequestHandler) => Thenable): Thenable { diff --git a/src/sql/platform/restore/common/restoreServiceImpl.ts b/src/sql/platform/restore/common/restoreServiceImpl.ts index 7db1022d78..1f4482a1bc 100644 --- a/src/sql/platform/restore/common/restoreServiceImpl.ts +++ b/src/sql/platform/restore/common/restoreServiceImpl.ts @@ -25,6 +25,7 @@ import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; import * as TelemetryUtils from 'sql/platform/telemetry/telemetryUtilities'; import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; import { invalidProvider } from 'sql/base/common/errors'; +import { ILogService } from 'vs/platform/log/common/log'; export class RestoreService implements IRestoreService { @@ -33,7 +34,8 @@ export class RestoreService implements IRestoreService { constructor( @IConnectionManagementService private _connectionService: IConnectionManagementService, - @ITelemetryService private _telemetryService: ITelemetryService + @ITelemetryService private _telemetryService: ITelemetryService, + @ILogService private logService: ILogService ) { } @@ -62,7 +64,7 @@ export class RestoreService implements IRestoreService { return new Promise((resolve, reject) => { const providerResult = this.getProvider(connectionUri); if (providerResult) { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.RestoreRequested, { provider: providerResult.providerName }); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.RestoreRequested, { provider: providerResult.providerName }); providerResult.provider.restore(connectionUri, restoreInfo).then(result => { resolve(result); }, error => { diff --git a/src/sql/platform/scripting/common/scriptingService.ts b/src/sql/platform/scripting/common/scriptingService.ts index 0257584ef7..d1fd1b6c96 100644 --- a/src/sql/platform/scripting/common/scriptingService.ts +++ b/src/sql/platform/scripting/common/scriptingService.ts @@ -8,7 +8,7 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation' import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; import { ScriptOperation } from 'sql/workbench/common/taskUtilities'; import * as azdata from 'azdata'; -import { error } from 'sql/base/common/log'; +import { ILogService } from 'vs/platform/log/common/log'; export const SERVICE_ID = 'scriptingService'; export const IScriptingService = createDecorator(SERVICE_ID); @@ -48,7 +48,10 @@ export class ScriptingService implements IScriptingService { private _providers: { [handle: string]: azdata.ScriptingProvider; } = Object.create(null); private failedScriptingOperations: { [operationId: string]: azdata.ScriptingCompleteResult } = {}; - constructor(@IConnectionManagementService private _connectionService: IConnectionManagementService) { } + constructor( + @IConnectionManagementService private _connectionService: IConnectionManagementService, + @ILogService private readonly logService: ILogService + ) { } /** * Call the service for scripting based on provider and scripting operation @@ -70,7 +73,7 @@ export class ScriptingService implements IScriptingService { */ public onScriptingComplete(handle: number, scriptingCompleteResult: azdata.ScriptingCompleteResult): void { if (scriptingCompleteResult && scriptingCompleteResult.hasError && scriptingCompleteResult.errorMessage) { - error(`Scripting failed. error: ${scriptingCompleteResult.errorMessage}`); + this.logService.error(`Scripting failed. error: ${scriptingCompleteResult.errorMessage}`); if (scriptingCompleteResult.operationId) { this.failedScriptingOperations[scriptingCompleteResult.operationId] = scriptingCompleteResult; } diff --git a/src/sql/platform/telemetry/telemetryUtilities.ts b/src/sql/platform/telemetry/telemetryUtilities.ts index 7812026220..39aea48094 100644 --- a/src/sql/platform/telemetry/telemetryUtilities.ts +++ b/src/sql/platform/telemetry/telemetryUtilities.ts @@ -3,10 +3,9 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; import { ITelemetryService, ITelemetryData } from 'vs/platform/telemetry/common/telemetry'; import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; -import { warn } from 'sql/base/common/log'; +import { ILogService } from 'vs/platform/log/common/log'; export interface IConnectionTelemetryData extends ITelemetryData { provider?: string; @@ -23,9 +22,11 @@ export interface IConnectionTelemetryData extends ITelemetryData { */ export function addTelemetry( telemetryService: ITelemetryService, + logService: ILogService, telemetryEventName: string, data?: IConnectionTelemetryData, - connection?: IConnectionProfile): Promise { + connection?: IConnectionProfile +): Promise { return new Promise(resolve => { try { let telData: ITelemetryData = data === undefined ? {} : data; @@ -43,14 +44,18 @@ export function addTelemetry( telemetryService.publicLog(telemetryEventName, telData).then(() => { resolve(); }, telemetryServiceError => { - warn(`Failed to add telemetry. error: ${telemetryServiceError}`); + if (logService) { + logService.warn(`Failed to add telemetry. error: ${telemetryServiceError}`); + } resolve(); }); } else { resolve(); } } catch (error) { - warn(`Failed to add telemetry. error: ${error}`); + if (logService) { + logService.warn(`Failed to add telemetry. error: ${error}`); + } resolve(); } }); diff --git a/src/sql/workbench/api/node/extHostModalDialog.ts b/src/sql/workbench/api/node/extHostModalDialog.ts index 409ddd0971..7ac54884b4 100644 --- a/src/sql/workbench/api/node/extHostModalDialog.ts +++ b/src/sql/workbench/api/node/extHostModalDialog.ts @@ -98,7 +98,6 @@ export class ExtHostModalDialogs implements ExtHostModalDialogsShape { createDialog( title: string ): azdata.ModalDialog { - console.log(title); const handle = ExtHostModalDialogs._handlePool++; this._proxy.$createDialog(handle); diff --git a/src/sql/workbench/api/node/extHostTasks.ts b/src/sql/workbench/api/node/extHostTasks.ts index bbda511697..0d0edb3ceb 100644 --- a/src/sql/workbench/api/node/extHostTasks.ts +++ b/src/sql/workbench/api/node/extHostTasks.ts @@ -74,12 +74,6 @@ export class ExtHostTasks implements ExtHostTasksShape { let result = callback.apply(thisArg, args); return Promise.resolve(result); } catch (err) { - // console.log(err); - // try { - // console.log(toErrorMessage(err)); - // } catch (err) { - // // - // } return Promise.reject(new Error(`Running the contributed task:'${id}' failed.`)); } } diff --git a/src/sql/workbench/browser/modal/modal.ts b/src/sql/workbench/browser/modal/modal.ts index 98e6b2d860..817b459f16 100644 --- a/src/sql/workbench/browser/modal/modal.ts +++ b/src/sql/workbench/browser/modal/modal.ts @@ -24,6 +24,7 @@ import * as os from 'os'; import { IThemeService } from 'vs/platform/theme/common/themeService'; import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; import { isUndefinedOrNull } from 'vs/base/common/types'; +import { ILogService } from 'vs/platform/log/common/log'; export const MODAL_SHOWING_KEY = 'modalShowing'; export const MODAL_SHOWING_CONTEXT = new RawContextKey>(MODAL_SHOWING_KEY, []); @@ -145,6 +146,7 @@ export abstract class Modal extends Disposable implements IThemable { protected layoutService: ILayoutService, protected _clipboardService: IClipboardService, protected _themeService: IThemeService, + protected logService: ILogService, _contextKeyService: IContextKeyService, options?: IModalOptions ) { @@ -352,7 +354,7 @@ export abstract class Modal extends Disposable implements IThemable { }); this.layout(DOM.getTotalHeight(this._modalBodySection)); - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.ModalDialogOpened, { name: this._name }); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.ModalDialogOpened, { name: this._name }); } /** @@ -371,7 +373,7 @@ export abstract class Modal extends Disposable implements IThemable { } this._keydownListener.dispose(); this._resizeListener.dispose(); - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.ModalDialogClosed, { name: this._name }); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.ModalDialogClosed, { name: this._name }); } /** diff --git a/src/sql/workbench/browser/modal/optionsDialog.ts b/src/sql/workbench/browser/modal/optionsDialog.ts index fe59cd1d43..42cdc1ec7f 100644 --- a/src/sql/workbench/browser/modal/optionsDialog.ts +++ b/src/sql/workbench/browser/modal/optionsDialog.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'vs/css!./media/optionsDialog'; import * as DialogHelper from './dialogHelper'; import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox'; @@ -22,7 +20,6 @@ import { IContextViewService, IContextMenuService } from 'vs/platform/contextvie import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { localize } from 'vs/nls'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { IWorkbenchThemeService, IColorTheme } from 'vs/workbench/services/themes/common/workbenchThemeService'; import { contrastBorder } from 'vs/platform/theme/common/colorRegistry'; import * as styler from 'vs/platform/theme/common/styler'; import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox'; @@ -32,8 +29,10 @@ import { IViewletPanelOptions, ViewletPanel } from 'vs/workbench/browser/parts/v import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { append, $ } from 'vs/base/browser/dom'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; export class CategoryView extends ViewletPanel { @@ -88,15 +87,16 @@ export class OptionsDialog extends Modal { title: string, name: string, options: IOptionsDialogOptions, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @IWorkbenchThemeService private _workbenchThemeService: IWorkbenchThemeService, + @ILayoutService layoutService: ILayoutService, + @IThemeService themeService: IThemeService, @IContextViewService private _contextViewService: IContextViewService, @IInstantiationService private _instantiationService: IInstantiationService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { - super(title, name, telemetryService, layoutService, clipboardService, _workbenchThemeService, contextKeyService, options); + super(title, name, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, options); } public render() { @@ -111,8 +111,8 @@ export class OptionsDialog extends Modal { // Theme styler attachButtonStyler(okButton, this._themeService); attachButtonStyler(closeButton, this._themeService); - this._register(this._workbenchThemeService.onDidColorThemeChange(e => this.updateTheme(e))); - this.updateTheme(this._workbenchThemeService.getColorTheme()); + this._register(this._themeService.onThemeChange(e => this.updateTheme(e))); + this.updateTheme(this._themeService.getTheme()); } protected renderBody(container: HTMLElement) { @@ -130,7 +130,7 @@ export class OptionsDialog extends Modal { } // Update theming that is specific to options dialog flyout body - private updateTheme(theme: IColorTheme): void { + private updateTheme(theme: ITheme): void { let borderColor = theme.getColor(contrastBorder); let border = borderColor ? borderColor.toString() : null; if (this._dividerBuilder) { diff --git a/src/sql/workbench/electron-browser/modelComponents/modelComponentWrapper.component.ts b/src/sql/workbench/electron-browser/modelComponents/modelComponentWrapper.component.ts index 0325d83573..d4e2fb91eb 100644 --- a/src/sql/workbench/electron-browser/modelComponents/modelComponentWrapper.component.ts +++ b/src/sql/workbench/electron-browser/modelComponents/modelComponentWrapper.component.ts @@ -9,12 +9,10 @@ import { } from '@angular/core'; import { ComponentHostDirective } from 'sql/workbench/parts/dashboard/common/componentHost.directive'; -import { error } from 'sql/base/common/log'; import { AngularDisposable } from 'sql/base/node/lifecycle'; import { IComponent, IComponentConfig, IComponentDescriptor, IModelStore, COMPONENT_CONFIG } from './interfaces'; import { Extensions, IComponentRegistry } from 'sql/platform/dashboard/common/modelComponentRegistry'; -import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import * as colors from 'vs/platform/theme/common/colorRegistry'; import * as themeColors from 'vs/workbench/common/theme'; import { Registry } from 'vs/platform/registry/common/platform'; @@ -23,6 +21,8 @@ import { generateUuid } from 'vs/base/common/uuid'; import { IBootstrapParams } from 'sql/platform/bootstrap/node/bootstrapService'; import { Event } from 'vs/base/common/event'; import { LayoutRequestParams } from 'sql/platform/dialog/dialogContainer.component'; +import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; const componentRegistry = Registry.as(Extensions.ComponentContribution); @@ -58,13 +58,14 @@ export class ModelComponentWrapper extends AngularDisposable implements OnInit { @Inject(forwardRef(() => ElementRef)) private _ref: ElementRef, @Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef, @Inject(forwardRef(() => Injector)) private _injector: Injector, - @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, - @Inject(IBootstrapParams) private _params: ModelComponentParams + @Inject(IThemeService) private themeService: IThemeService, + @Inject(ILogService) private readonly logService: ILogService, + @Inject(IBootstrapParams) params: ModelComponentParams ) { super(); - if (_params && _params.onLayoutRequested) { - this._modelViewId = _params.modelViewId; - _params.onLayoutRequested(layoutParams => { + if (params && params.onLayoutRequested) { + this._modelViewId = params.modelViewId; + params.onLayoutRequested(layoutParams => { if (layoutParams && (layoutParams.alwaysRefresh || layoutParams.modelViewId === this._modelViewId)) { this.layout(); } @@ -73,14 +74,11 @@ export class ModelComponentWrapper extends AngularDisposable implements OnInit { } ngOnInit() { - let self = this; - this._register(self.themeService.onDidColorThemeChange((event: IColorTheme) => { - self.updateTheme(event); - })); + this._register(this.themeService.onThemeChange(event => this.updateTheme(event))); } ngAfterViewInit() { - this.updateTheme(this.themeService.getColorTheme()); + this.updateTheme(this.themeService.getTheme()); if (this.componentHost) { this.loadComponent(); } @@ -114,14 +112,14 @@ export class ModelComponentWrapper extends AngularDisposable implements OnInit { private loadComponent(): void { if (!this.descriptor || !this.descriptor.type) { - error('No descriptor or type defined for this component'); + this.logService.error('No descriptor or type defined for this component'); return; } let selector = componentRegistry.getCtorFromId(this.descriptor.type); if (selector === undefined) { - error('No selector defined for type {0}', this.descriptor.type); + this.logService.error('No selector defined for type {0}', this.descriptor.type); return; } @@ -139,7 +137,7 @@ export class ModelComponentWrapper extends AngularDisposable implements OnInit { this._componentInstance.modelStore = this.modelStore; this._changeref.detectChanges(); } catch (e) { - error('Error rendering component: {0}', e); + this.logService.error('Error rendering component: {0}', e); return; } let el = componentRef.location.nativeElement; @@ -149,13 +147,11 @@ export class ModelComponentWrapper extends AngularDisposable implements OnInit { el.style.position = 'relative'; } - private updateTheme(theme: IColorTheme): void { + private updateTheme(theme: ITheme): void { // TODO handle theming appropriately let el = this._ref.nativeElement; - let borderColor = theme.getColor(themeColors.SIDE_BAR_BACKGROUND, true); let backgroundColor = theme.getColor(colors.editorBackground, true); let foregroundColor = theme.getColor(themeColors.SIDE_BAR_FOREGROUND, true); - let border = theme.getColor(colors.contrastBorder, true); if (backgroundColor) { el.style.backgroundColor = backgroundColor.toString(); diff --git a/src/sql/workbench/parts/backup/electron-browser/backupDialog.ts b/src/sql/workbench/parts/backup/electron-browser/backupDialog.ts index 0b70b9af60..07d0132443 100644 --- a/src/sql/workbench/parts/backup/electron-browser/backupDialog.ts +++ b/src/sql/workbench/parts/backup/electron-browser/backupDialog.ts @@ -16,8 +16,9 @@ import { IThemeService } from 'vs/platform/theme/common/themeService'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { bootstrapAngular } from 'sql/platform/bootstrap/node/bootstrapService'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import { append, $ } from 'vs/base/browser/dom'; +import { ILogService } from 'vs/platform/log/common/log'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; export class BackupDialog extends Modal { private _body: HTMLElement; @@ -26,13 +27,14 @@ export class BackupDialog extends Modal { constructor( @IThemeService themeService: IThemeService, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, + @ILayoutService layoutService: ILayoutService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IInstantiationService private _instantiationService: IInstantiationService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { - super('', TelemetryKeys.Backup, telemetryService, layoutService, clipboardService, themeService, contextKeyService, { isAngular: true, hasErrors: true }); + super('', TelemetryKeys.Backup, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, { isAngular: true, hasErrors: true }); } protected renderBody(container: HTMLElement) { diff --git a/src/sql/workbench/parts/dashboard/common/dashboardHelper.ts b/src/sql/workbench/parts/dashboard/common/dashboardHelper.ts index 436f9bc747..edd7d5d110 100644 --- a/src/sql/workbench/parts/dashboard/common/dashboardHelper.ts +++ b/src/sql/workbench/parts/dashboard/common/dashboardHelper.ts @@ -9,7 +9,6 @@ import { Registry } from 'vs/platform/registry/common/platform'; import * as nls from 'vs/nls'; import { ContextKeyExpr, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; -import { error } from 'sql/base/common/log'; import { WidgetConfig } from 'sql/workbench/parts/dashboard/common/dashboardWidget'; import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry'; import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo'; @@ -23,6 +22,7 @@ import { NAV_SECTION } from 'sql/workbench/parts/dashboard/containers/dashboardN import { IDashboardContainerRegistry, Extensions as DashboardContainerExtensions } from 'sql/platform/dashboard/common/dashboardContainerRegistry'; import { SingleConnectionManagementService } from 'sql/platform/bootstrap/node/commonServiceInterface.service'; import * as Constants from 'sql/platform/connection/common/constants'; +import { ILogService } from 'vs/platform/log/common/log'; const dashboardcontainerRegistry = Registry.as(DashboardContainerExtensions.dashboardContainerContributions); const containerTypes = [ @@ -173,14 +173,14 @@ function hasCompatibleProvider(provider: string | string[], contextKeyService: I * Get registered container if it is specified as the key * @param container dashboard container */ -export function getDashboardContainer(container: object): { result: boolean, message: string, container: object } { +export function getDashboardContainer(container: object, logService: ILogService): { result: boolean, message: string, container: object } { const key = Object.keys(container)[0]; const containerTypeFound = containerTypes.find(c => (c === key)); if (!containerTypeFound) { const dashboardContainer = dashboardcontainerRegistry.getRegisteredContainer(key); if (!dashboardContainer) { const errorMessage = nls.localize('unknownDashboardContainerError', '{0} is an unknown container.', key); - error(errorMessage); + logService.error(errorMessage); return { result: false, message: errorMessage, container: undefined }; } else { container = dashboardContainer.container; diff --git a/src/sql/workbench/parts/dashboard/common/dashboardPage.component.ts b/src/sql/workbench/parts/dashboard/common/dashboardPage.component.ts index 8a9c98205c..b4dd11a2b7 100644 --- a/src/sql/workbench/parts/dashboard/common/dashboardPage.component.ts +++ b/src/sql/workbench/parts/dashboard/common/dashboardPage.component.ts @@ -36,6 +36,7 @@ import Severity from 'vs/base/common/severity'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { ILogService } from 'vs/platform/log/common/log'; const dashboardRegistry = Registry.as(DashboardExtensions.DashboardContributions); @@ -97,7 +98,8 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig @Inject(IInstantiationService) private instantiationService: IInstantiationService, @Inject(INotificationService) private notificationService: INotificationService, @Inject(IAngularEventingService) private angularEventingService: IAngularEventingService, - @Inject(IConfigurationService) private configurationService: IConfigurationService + @Inject(IConfigurationService) private configurationService: IConfigurationService, + @Inject(ILogService) private logService: ILogService ) { super(); } @@ -261,7 +263,7 @@ export abstract class DashboardPage extends AngularDisposable implements IConfig } private initTabComponents(value: IDashboardTab): { id: string; title: string; container: object; alwaysShow: boolean; } { - const containerResult = dashboardHelper.getDashboardContainer(value.container); + const containerResult = dashboardHelper.getDashboardContainer(value.container, this.logService); if (!containerResult.result) { return { id: value.id, title: value.title, container: { 'error-container': undefined }, alwaysShow: value.alwaysShow }; } diff --git a/src/sql/workbench/parts/dashboard/containers/dashboardNavSection.component.ts b/src/sql/workbench/parts/dashboard/containers/dashboardNavSection.component.ts index 1261cd543a..76a376e448 100644 --- a/src/sql/workbench/parts/dashboard/containers/dashboardNavSection.component.ts +++ b/src/sql/workbench/parts/dashboard/containers/dashboardNavSection.component.ts @@ -18,6 +18,7 @@ import * as dashboardHelper from 'sql/workbench/parts/dashboard/common/dashboard import { Event, Emitter } from 'vs/base/common/event'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; +import { ILogService } from 'vs/platform/log/common/log'; @Component({ selector: 'dashboard-nav-section', @@ -53,7 +54,8 @@ export class DashboardNavSection extends DashboardTab implements OnDestroy, OnCh @ViewChild(PanelComponent) private _panel: PanelComponent; constructor( @Inject(forwardRef(() => CommonServiceInterface)) protected dashboardService: CommonServiceInterface, - @Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef + @Inject(forwardRef(() => ChangeDetectorRef)) protected _cd: ChangeDetectorRef, + @Inject(ILogService) private logService: ILogService ) { super(); } @@ -91,7 +93,7 @@ export class DashboardNavSection extends DashboardTab implements OnDestroy, OnCh private loadNewTabs(dashboardTabs: NavSectionConfig[]) { if (dashboardTabs && dashboardTabs.length > 0) { dashboardTabs.map(v => { - const containerResult = dashboardHelper.getDashboardContainer(v.container); + const containerResult = dashboardHelper.getDashboardContainer(v.container, this.logService); if (!containerResult.result) { return { id: v.id, title: v.title, container: { 'error-container': undefined } }; } diff --git a/src/sql/workbench/parts/dashboard/contents/dashboardWidgetWrapper.component.ts b/src/sql/workbench/parts/dashboard/contents/dashboardWidgetWrapper.component.ts index 3ab841c93c..b3c109b306 100644 --- a/src/sql/workbench/parts/dashboard/contents/dashboardWidgetWrapper.component.ts +++ b/src/sql/workbench/parts/dashboard/contents/dashboardWidgetWrapper.component.ts @@ -14,7 +14,6 @@ import { import { ComponentHostDirective } from 'sql/workbench/parts/dashboard/common/componentHost.directive'; import { WidgetConfig, WIDGET_CONFIG, IDashboardWidget } from 'sql/workbench/parts/dashboard/common/dashboardWidget'; import { Extensions, IInsightRegistry } from 'sql/platform/dashboard/common/insightRegistry'; -import { error } from 'sql/base/common/log'; import { RefreshWidgetAction, ToggleMoreWidgetAction, DeleteWidgetAction, CollapseWidgetAction } from 'sql/workbench/parts/dashboard/common/actions'; import { AngularDisposable } from 'sql/base/node/lifecycle'; @@ -36,6 +35,7 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar'; import { memoize } from 'vs/base/common/decorators'; import { generateUuid } from 'vs/base/common/uuid'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; +import { ILogService } from 'vs/platform/log/common/log'; const componentMap: { [x: string]: Type } = { 'properties-widget': PropertiesWidgetComponent, @@ -92,7 +92,8 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit @Inject(forwardRef(() => ChangeDetectorRef)) private _changeref: ChangeDetectorRef, @Inject(forwardRef(() => Injector)) private _injector: Injector, @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, - @Inject(IInstantiationService) private instantiationService: IInstantiationService + @Inject(IInstantiationService) private instantiationService: IInstantiationService, + @Inject(ILogService) private logService: ILogService ) { super(); } @@ -146,13 +147,13 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit private loadWidget(): void { if (Object.keys(this._config.widget).length !== 1) { - error('Exactly 1 widget must be defined per space'); + this.logService.error('Exactly 1 widget must be defined per space'); return; } const key = Object.keys(this._config.widget)[0]; const selector = this.getOrCreateSelector(key); if (selector === undefined) { - error('Could not find selector', key); + this.logService.error('Could not find selector', key); return; } @@ -183,7 +184,7 @@ export class DashboardWidgetWrapper extends AngularDisposable implements OnInit this._changeref.detectChanges(); } } catch (e) { - error('Error rendering widget', key, e); + this.logService.error('Error rendering widget', key, e); return; } const el = componentRef.location.nativeElement; diff --git a/src/sql/workbench/parts/dashboard/dashboard.module.ts b/src/sql/workbench/parts/dashboard/dashboard.module.ts index dbf0f5d234..b36d8da9be 100644 --- a/src/sql/workbench/parts/dashboard/dashboard.module.ts +++ b/src/sql/workbench/parts/dashboard/dashboard.module.ts @@ -86,6 +86,7 @@ import { InsightsWidget } from 'sql/workbench/parts/dashboard/widgets/insights/i import { WebviewWidget } from 'sql/workbench/parts/dashboard/widgets/webview/webviewWidget.component'; import { JobStepsViewComponent } from 'sql/workbench/parts/jobManagement/electron-browser/jobStepsView.component'; import { IInstantiationService, _util } from 'vs/platform/instantiation/common/instantiation'; +import { ILogService } from 'vs/platform/log/common/log'; const widgetComponents = [ PropertiesWidgetComponent, @@ -156,6 +157,7 @@ export const DashboardModule = (params, selector: string, instantiationService: @Inject(forwardRef(() => ComponentFactoryResolver)) private _resolver: ComponentFactoryResolver, @Inject(forwardRef(() => Router)) private _router: Router, @Inject(ITelemetryService) private telemetryService: ITelemetryService, + @Inject(ILogService) private readonly logService: ILogService, @Inject(ISelector) private selector: string ) { } @@ -168,7 +170,7 @@ export const DashboardModule = (params, selector: string, instantiationService: this._router.events.subscribe(e => { if (e instanceof NavigationEnd) { this.navigations++; - TelemetryUtils.addTelemetry(this.telemetryService, TelemetryKeys.DashboardNavigated, { + TelemetryUtils.addTelemetry(this.telemetryService, this.logService, TelemetryKeys.DashboardNavigated, { numberOfNavigations: this.navigations }); } diff --git a/src/sql/workbench/parts/dashboard/pages/databaseDashboardPage.component.ts b/src/sql/workbench/parts/dashboard/pages/databaseDashboardPage.component.ts index 4dcf5775fb..178275e487 100644 --- a/src/sql/workbench/parts/dashboard/pages/databaseDashboardPage.component.ts +++ b/src/sql/workbench/parts/dashboard/pages/databaseDashboardPage.component.ts @@ -18,6 +18,7 @@ import * as nls from 'vs/nls'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { ILogService } from 'vs/platform/log/common/log'; export class DatabaseDashboardPage extends DashboardPage implements OnInit { protected propertiesWidget: WidgetConfig = { @@ -44,9 +45,10 @@ export class DatabaseDashboardPage extends DashboardPage implements OnInit { @Inject(IInstantiationService) instantiationService: IInstantiationService, @Inject(INotificationService) notificationService: INotificationService, @Inject(IAngularEventingService) angularEventingService: IAngularEventingService, - @Inject(IConfigurationService) configurationService: IConfigurationService + @Inject(IConfigurationService) configurationService: IConfigurationService, + @Inject(ILogService) logService: ILogService ) { - super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService, configurationService); + super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService, configurationService, logService); this._register(dashboardService.onUpdatePage(() => { this.refresh(true); this._cd.detectChanges(); diff --git a/src/sql/workbench/parts/dashboard/pages/serverDashboardPage.component.ts b/src/sql/workbench/parts/dashboard/pages/serverDashboardPage.component.ts index f1d2bf3c1f..47345d0b85 100644 --- a/src/sql/workbench/parts/dashboard/pages/serverDashboardPage.component.ts +++ b/src/sql/workbench/parts/dashboard/pages/serverDashboardPage.component.ts @@ -18,6 +18,7 @@ import * as nls from 'vs/nls'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; +import { ILogService } from 'vs/platform/log/common/log'; export class ServerDashboardPage extends DashboardPage implements OnInit { protected propertiesWidget: WidgetConfig = { @@ -45,9 +46,10 @@ export class ServerDashboardPage extends DashboardPage implements OnInit { @Inject(IInstantiationService) instantiationService: IInstantiationService, @Inject(INotificationService) notificationService: INotificationService, @Inject(IAngularEventingService) angularEventingService: IAngularEventingService, - @Inject(IConfigurationService) configurationService: IConfigurationService + @Inject(IConfigurationService) configurationService: IConfigurationService, + @Inject(ILogService) logService: ILogService ) { - super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService, configurationService); + super(dashboardService, el, _cd, instantiationService, notificationService, angularEventingService, configurationService, logService); // special-case handling for MSSQL data provider const connInfo = this.dashboardService.connectionManagementService.connectionInfo; diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.component.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.component.ts index edb591cb86..085d8ea871 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.component.ts @@ -3,7 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ElementRef, ViewChild } from '@angular/core'; +import { Component, Input, Inject, ChangeDetectorRef, forwardRef, ViewChild } from '@angular/core'; import { BaseChartDirective } from 'ng2-charts'; import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; @@ -16,9 +16,10 @@ import { LegendPosition, ChartType, defaultChartConfig, IChartConfig, IDataSet, import * as colors from 'vs/platform/theme/common/colorRegistry'; import * as types from 'vs/base/common/types'; import { Disposable } from 'vs/base/common/lifecycle'; -import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import * as nls from 'vs/nls'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; declare const Chart: any; @@ -52,16 +53,16 @@ export abstract class ChartInsight extends Disposable implements IInsightsView { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, - @Inject(forwardRef(() => ElementRef)) private _el: ElementRef, - @Inject(IWorkbenchThemeService) private themeService: IWorkbenchThemeService, - @Inject(ITelemetryService) private telemetryService: ITelemetryService + @Inject(IThemeService) private themeService: IThemeService, + @Inject(ITelemetryService) private telemetryService: ITelemetryService, + @Inject(ILogService) private readonly logService: ILogService ) { super(); } init() { - this._register(this.themeService.onDidColorThemeChange(e => this.updateTheme(e))); - this.updateTheme(this.themeService.getColorTheme()); + this._register(this.themeService.onThemeChange(e => this.updateTheme(e))); + this.updateTheme(this.themeService.getTheme()); // Note: must use a boolean to not render the canvas until all properties such as the labels and chart type are set. // This is because chart.js doesn't auto-update anything other than dataset when re-rendering so defaults are used // hence it's easier to not render until ready @@ -75,7 +76,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView { this._hasError = true; this._changeRef.detectChanges(); } - TelemetryUtils.addTelemetry(this.telemetryService, TelemetryKeys.ChartCreated, { type: this.chartType }); + TelemetryUtils.addTelemetry(this.telemetryService, this.logService, TelemetryKeys.ChartCreated, { type: this.chartType }); } /** @@ -93,7 +94,7 @@ export abstract class ChartInsight extends Disposable implements IInsightsView { return this._options; } - protected updateTheme(e: IColorTheme): void { + protected updateTheme(e: ITheme): void { const foregroundColor = e.getColor(colors.editorForeground); const foreground = foregroundColor ? foregroundColor.toString() : null; const backgroundColor = e.getColor(colors.editorBackground); diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/barChart.component.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/barChart.component.ts index fc6281926b..f00f902361 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/barChart.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/barChart.component.ts @@ -7,11 +7,12 @@ import { ChartInsight } from 'sql/workbench/parts/dashboard/widgets/insights/vie import { mixin } from 'sql/base/common/objects'; import { ChartType, IChartConfig, customMixin } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces'; -import { IColorTheme, IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; import * as colors from 'vs/platform/theme/common/colorRegistry'; import { editorLineNumbers } from 'vs/editor/common/view/editorColorRegistry'; -import { ChangeDetectorRef, Inject, ElementRef, forwardRef } from '@angular/core'; +import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; export interface IBarChartConfig extends IChartConfig { yAxisMin: number; @@ -27,11 +28,11 @@ export default class BarChart extends ChartInsight { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, - @Inject(forwardRef(() => ElementRef)) _el: ElementRef, - @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService + @Inject(IThemeService) themeService: IThemeService, + @Inject(ITelemetryService) telemetryService: ITelemetryService, + @Inject(ILogService) logService: ILogService ) { - super(_changeRef, _el, themeService, telemetryService); + super(_changeRef, themeService, telemetryService, logService); } public setConfig(config: IBarChartConfig): void { @@ -126,7 +127,7 @@ export default class BarChart extends ChartInsight { super.setConfig(config); } - protected updateTheme(e: IColorTheme): void { + protected updateTheme(e: ITheme): void { super.updateTheme(e); const foregroundColor = e.getColor(colors.editorForeground); const foreground = foregroundColor ? foregroundColor.toString() : null; diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/barChart.contribution.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/barChart.contribution.ts index f3c50b8234..4841159f15 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/barChart.contribution.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/barChart.contribution.ts @@ -3,8 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { mixin } from 'vs/base/common/objects'; -import { clone } from 'sql/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; import * as nls from 'vs/nls'; @@ -42,6 +41,6 @@ const properties: IJSONSchema = { } }; -export const barChartSchema = mixin(clone(chartInsightSchema), properties) as IJSONSchema; +export const barChartSchema = mixin(deepClone(chartInsightSchema), properties) as IJSONSchema; registerInsight('bar', '', barChartSchema, BarChart); diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/doughnutChart.component.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/doughnutChart.component.ts index 211d0c38b1..f9a98ae4aa 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/doughnutChart.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/doughnutChart.component.ts @@ -5,19 +5,20 @@ import PieChart from './pieChart.component'; import { ChartType } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces'; -import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { ILogService } from 'vs/platform/log/common/log'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; export default class DoughnutChart extends PieChart { protected readonly chartType: ChartType = ChartType.Doughnut; constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, - @Inject(forwardRef(() => ElementRef)) _el: ElementRef, - @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService + @Inject(IThemeService) themeService: IThemeService, + @Inject(ITelemetryService) telemetryService: ITelemetryService, + @Inject(ILogService) logService: ILogService ) { - super(_changeRef, _el, themeService, telemetryService); + super(_changeRef, themeService, telemetryService, logService); } } diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/doughnutChart.contribution.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/doughnutChart.contribution.ts index 69e74063a6..d3c603694c 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/doughnutChart.contribution.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/doughnutChart.contribution.ts @@ -3,8 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { clone } from 'sql/base/common/objects'; -import { mixin } from 'vs/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry'; import { chartInsightSchema } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.contribution'; @@ -15,6 +14,6 @@ const properties: IJSONSchema = { }; -const doughnutChartSchema = mixin(clone(chartInsightSchema), properties) as IJSONSchema; +const doughnutChartSchema = mixin(deepClone(chartInsightSchema), properties) as IJSONSchema; registerInsight('doughnut', '', doughnutChartSchema, DoughnutChart); diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/horizontalBarChart.component.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/horizontalBarChart.component.ts index 717ee33af2..83c050b626 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/horizontalBarChart.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/horizontalBarChart.component.ts @@ -5,19 +5,20 @@ import BarChart from './barChart.component'; import { ChartType } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces'; -import { forwardRef, Inject, ChangeDetectorRef, ElementRef } from '@angular/core'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { forwardRef, Inject, ChangeDetectorRef } from '@angular/core'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; export default class HorizontalBarChart extends BarChart { protected readonly chartType: ChartType = ChartType.HorizontalBar; constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, - @Inject(forwardRef(() => ElementRef)) _el: ElementRef, - @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService + @Inject(IThemeService) themeService: IThemeService, + @Inject(ITelemetryService) telemetryService: ITelemetryService, + @Inject(ILogService) logService: ILogService ) { - super(_changeRef, _el, themeService, telemetryService); + super(_changeRef, themeService, telemetryService, logService); } } diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/horizontalBarChart.contribution.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/horizontalBarChart.contribution.ts index a649a32e8e..46fe618928 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/horizontalBarChart.contribution.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/horizontalBarChart.contribution.ts @@ -3,8 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { clone } from 'sql/base/common/objects'; -import { mixin } from 'vs/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry'; @@ -16,6 +15,6 @@ const properties: IJSONSchema = { }; -const horizontalBarSchema = mixin(clone(barChartSchema), properties) as IJSONSchema; +const horizontalBarSchema = mixin(deepClone(barChartSchema), properties) as IJSONSchema; registerInsight('horizontalBar', '', horizontalBarSchema, HorizontalBarChart); diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/lineChart.component.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/lineChart.component.ts index aeb26e6c0c..331169fa14 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/lineChart.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/lineChart.component.ts @@ -3,21 +3,21 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { mixin } from 'vs/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import BarChart, { IBarChartConfig } from './barChart.component'; import { memoize, unmemoize } from 'sql/base/common/decorators'; -import { clone } from 'sql/base/common/objects'; import { ChartType, DataType, defaultChartConfig, IDataSet, IPointDataSet } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces'; -import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; export interface ILineConfig extends IBarChartConfig { dataType?: DataType; } -const defaultLineConfig = mixin(clone(defaultChartConfig), { dataType: 'number' }) as ILineConfig; +const defaultLineConfig = mixin(deepClone(defaultChartConfig), { dataType: 'number' }) as ILineConfig; export default class LineChart extends BarChart { protected readonly chartType: ChartType = ChartType.Line; @@ -26,11 +26,11 @@ export default class LineChart extends BarChart { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, - @Inject(forwardRef(() => ElementRef)) _el: ElementRef, - @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService + @Inject(IThemeService) themeService: IThemeService, + @Inject(ITelemetryService) telemetryService: ITelemetryService, + @Inject(ILogService) logService: ILogService ) { - super(_changeRef, _el, themeService, telemetryService); + super(_changeRef, themeService, telemetryService, logService); } public init() { diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/lineChart.contribution.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/lineChart.contribution.ts index acfe2be676..c67110251d 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/lineChart.contribution.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/lineChart.contribution.ts @@ -3,8 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { mixin } from 'vs/base/common/objects'; -import { clone } from 'sql/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; import * as nls from 'vs/nls'; @@ -25,6 +24,6 @@ const properties: IJSONSchema = { } }; -export const lineSchema = mixin(clone(barChartSchema), properties) as IJSONSchema; +export const lineSchema = mixin(deepClone(barChartSchema), properties) as IJSONSchema; registerInsight('line', '', lineSchema, LineChart); diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/pieChart.component.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/pieChart.component.ts index 2c2b61329f..ff8f523f32 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/pieChart.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/pieChart.component.ts @@ -5,19 +5,20 @@ import { ChartInsight } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.component'; import { ChartType } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces'; -import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; export default class PieChart extends ChartInsight { protected readonly chartType: ChartType = ChartType.Pie; constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, - @Inject(forwardRef(() => ElementRef)) _el: ElementRef, - @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService + @Inject(IThemeService) themeService: IThemeService, + @Inject(ITelemetryService) telemetryService: ITelemetryService, + @Inject(ILogService) logService: ILogService ) { - super(_changeRef, _el, themeService, telemetryService); + super(_changeRef, themeService, telemetryService, logService); } } diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/pieChart.contribution.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/pieChart.contribution.ts index e58e5fb207..ea533f6a90 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/pieChart.contribution.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/pieChart.contribution.ts @@ -3,8 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { mixin } from 'vs/base/common/objects'; -import { clone } from 'sql/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry'; import { chartInsightSchema } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/chartInsight.contribution'; @@ -15,6 +14,6 @@ const properties: IJSONSchema = { }; -const pieSchema = mixin(clone(chartInsightSchema), properties) as IJSONSchema; +const pieSchema = mixin(deepClone(chartInsightSchema), properties) as IJSONSchema; registerInsight('pie', '', pieSchema, PieChart); diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/scatterChart.component.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/scatterChart.component.ts index f45bd85549..1afbe1bc9d 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/scatterChart.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/scatterChart.component.ts @@ -4,15 +4,15 @@ *--------------------------------------------------------------------------------------------*/ import LineChart, { ILineConfig } from './lineChart.component'; -import { clone } from 'sql/base/common/objects'; import { ChartType, defaultChartConfig } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces'; -import { mixin } from 'vs/base/common/objects'; -import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { mixin, deepClone } from 'vs/base/common/objects'; +import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; -const defaultScatterConfig = mixin(clone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig; +const defaultScatterConfig = mixin(deepClone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig; export default class ScatterChart extends LineChart { protected readonly chartType: ChartType = ChartType.Scatter; @@ -20,10 +20,10 @@ export default class ScatterChart extends LineChart { constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, - @Inject(forwardRef(() => ElementRef)) _el: ElementRef, - @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService + @Inject(IThemeService) themeService: IThemeService, + @Inject(ITelemetryService) telemetryService: ITelemetryService, + @Inject(ILogService) logService: ILogService ) { - super(_changeRef, _el, themeService, telemetryService); + super(_changeRef, themeService, telemetryService, logService); } } diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/scatterChart.contribution.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/scatterChart.contribution.ts index 147d23946b..76feaa0830 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/scatterChart.contribution.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/scatterChart.contribution.ts @@ -3,8 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { mixin } from 'vs/base/common/objects'; -import { clone } from 'sql/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry'; @@ -15,6 +14,6 @@ import ScatterChart from './scatterChart.component'; const properties: IJSONSchema = { }; -const scatterSchema = mixin(clone(barChartSchema), properties) as IJSONSchema; +const scatterSchema = mixin(deepClone(barChartSchema), properties) as IJSONSchema; registerInsight('scatter', '', scatterSchema, ScatterChart); diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/timeSeriesChart.component.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/timeSeriesChart.component.ts index de85093f27..a01cd5c43c 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/timeSeriesChart.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/timeSeriesChart.component.ts @@ -4,27 +4,27 @@ *--------------------------------------------------------------------------------------------*/ import LineChart, { ILineConfig } from './lineChart.component'; -import { clone } from 'sql/base/common/objects'; import { ChartType, defaultChartConfig, IPointDataSet } from 'sql/workbench/parts/dashboard/widgets/insights/views/charts/interfaces'; -import { mixin } from 'vs/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import { Color } from 'vs/base/common/color'; -import { ChangeDetectorRef, Inject, forwardRef, ElementRef } from '@angular/core'; -import { IWorkbenchThemeService } from 'vs/workbench/services/themes/common/workbenchThemeService'; +import { ChangeDetectorRef, Inject, forwardRef } from '@angular/core'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; -const defaultTimeSeriesConfig = mixin(clone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig; +const defaultTimeSeriesConfig = mixin(deepClone(defaultChartConfig), { dataType: 'point', dataDirection: 'horizontal' }) as ILineConfig; export default class TimeSeriesChart extends LineChart { protected _defaultConfig = defaultTimeSeriesConfig; constructor( @Inject(forwardRef(() => ChangeDetectorRef)) _changeRef: ChangeDetectorRef, - @Inject(forwardRef(() => ElementRef)) _el: ElementRef, - @Inject(IWorkbenchThemeService) themeService: IWorkbenchThemeService, - @Inject(ITelemetryService) telemetryService: ITelemetryService + @Inject(IThemeService) themeService: IThemeService, + @Inject(ITelemetryService) telemetryService: ITelemetryService, + @Inject(ILogService) logService: ILogService ) { - super(_changeRef, _el, themeService, telemetryService); + super(_changeRef, themeService, telemetryService, logService); } protected addAxisLabels(): void { diff --git a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/timeSeriesChart.contribution.ts b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/timeSeriesChart.contribution.ts index 3bc12a9229..9fd6d65da4 100644 --- a/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/timeSeriesChart.contribution.ts +++ b/src/sql/workbench/parts/dashboard/widgets/insights/views/charts/types/timeSeriesChart.contribution.ts @@ -3,8 +3,7 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { mixin } from 'vs/base/common/objects'; -import { clone } from 'sql/base/common/objects'; +import { mixin, deepClone } from 'vs/base/common/objects'; import { IJSONSchema } from 'vs/base/common/jsonSchema'; import { registerInsight } from 'sql/platform/dashboard/common/insightRegistry'; @@ -15,6 +14,6 @@ import TimeSeriesChart from './timeSeriesChart.component'; const properties: IJSONSchema = { }; -const timeSeriesSchema = mixin(clone(barChartSchema), properties) as IJSONSchema; +const timeSeriesSchema = mixin(deepClone(barChartSchema), properties) as IJSONSchema; registerInsight('timeSeries', '', timeSeriesSchema, TimeSeriesChart); diff --git a/src/sql/workbench/parts/dashboard/widgets/properties/propertiesWidget.component.ts b/src/sql/workbench/parts/dashboard/widgets/properties/propertiesWidget.component.ts index 427743f1a1..40c291b207 100644 --- a/src/sql/workbench/parts/dashboard/widgets/properties/propertiesWidget.component.ts +++ b/src/sql/workbench/parts/dashboard/widgets/properties/propertiesWidget.component.ts @@ -9,7 +9,6 @@ import { DashboardWidget, IDashboardWidget, WidgetConfig, WIDGET_CONFIG } from ' import { CommonServiceInterface } from 'sql/platform/bootstrap/node/commonServiceInterface.service'; import { ConnectionManagementInfo } from 'sql/platform/connection/common/connectionManagementInfo'; import { toDisposableSubscription } from 'sql/base/node/rxjsUtils'; -import { error } from 'sql/base/common/log'; import { IDashboardRegistry, Extensions as DashboardExtensions } from 'sql/platform/dashboard/common/dashboardRegistry'; import { DatabaseInfo, ServerInfo } from 'azdata'; @@ -18,6 +17,7 @@ import { EventType, addDisposableListener } from 'vs/base/browser/dom'; import * as types from 'vs/base/common/types'; import * as nls from 'vs/nls'; import { Registry } from 'vs/platform/registry/common/platform'; +import { ILogService } from 'vs/platform/log/common/log'; export interface PropertiesConfig { properties: Array; @@ -72,12 +72,9 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @Inject(forwardRef(() => ElementRef)) private _el: ElementRef, @Inject(WIDGET_CONFIG) protected _config: WidgetConfig, - consoleError?: ((message?: any, ...optionalParams: any[]) => void) + @Inject(ILogService) private logService: ILogService ) { super(); - if (consoleError) { - this.consoleError = consoleError; - } this.init(); } @@ -127,7 +124,7 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb const providerProperties = dashboardRegistry.getProperties(provider as string); if (!providerProperties) { - this.consoleError('No property definitions found for provider', provider); + this.logService.error('No property definitions found for provider', provider); return; } @@ -137,7 +134,7 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb if (providerProperties.flavors.length === 1) { flavor = providerProperties.flavors[0]; } else if (providerProperties.flavors.length === 0) { - this.consoleError('No flavor definitions found for "', provider, + this.logService.error('No flavor definitions found for "', provider, '. If there are not multiple flavors of this provider, add one flavor without a condition'); return; } else { @@ -153,17 +150,17 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb case '<=': return condition <= item.condition.value; default: - this.consoleError('Could not parse operator: "', item.condition.operator, + this.logService.error('Could not parse operator: "', item.condition.operator, '" on item "', item, '"'); return false; } }); if (flavorArray.length === 0) { - this.consoleError('Could not determine flavor'); + this.logService.error('Could not determine flavor'); return; } else if (flavorArray.length > 1) { - this.consoleError('Multiple flavors matched correctly for this provider', provider); + this.logService.error('Multiple flavors matched correctly for this provider', provider); return; } @@ -173,17 +170,17 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb // determine what context we should be pulling from if (this._config.context === 'database') { if (!Array.isArray(flavor.databaseProperties)) { - this.consoleError('flavor', flavor.flavor, ' does not have a definition for database properties'); + this.logService.error('flavor', flavor.flavor, ' does not have a definition for database properties'); } if (!Array.isArray(flavor.serverProperties)) { - this.consoleError('flavor', flavor.flavor, ' does not have a definition for server properties'); + this.logService.error('flavor', flavor.flavor, ' does not have a definition for server properties'); } propertyArray = flavor.databaseProperties; } else { if (!Array.isArray(flavor.serverProperties)) { - this.consoleError('flavor', flavor.flavor, ' does not have a definition for server properties'); + this.logService.error('flavor', flavor.flavor, ' does not have a definition for server properties'); } propertyArray = flavor.serverProperties; @@ -237,9 +234,4 @@ export class PropertiesWidgetComponent extends DashboardWidget implements IDashb } return val; } - - // overwrittable console.error for testing - private consoleError(message?: any, ...optionalParams: any[]): void { - error(message, optionalParams); - } } diff --git a/src/sql/workbench/parts/grid/views/editData/editData.component.ts b/src/sql/workbench/parts/grid/views/editData/editData.component.ts index 37e26ea8b7..5a65e9be5d 100644 --- a/src/sql/workbench/parts/grid/views/editData/editData.component.ts +++ b/src/sql/workbench/parts/grid/views/editData/editData.component.ts @@ -15,8 +15,6 @@ import * as Services from 'sql/base/browser/ui/table/formatters'; import { IEditDataComponentParams } from 'sql/platform/bootstrap/node/bootstrapParams'; import { GridParentComponent } from 'sql/workbench/parts/grid/views/gridParentComponent'; import { EditDataGridActionProvider } from 'sql/workbench/parts/grid/views/editData/editDataGridActions'; -import { error } from 'sql/base/common/log'; -import { clone } from 'sql/base/common/objects'; import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService'; import { IBootstrapParams } from 'sql/platform/bootstrap/node/bootstrapService'; import { RowNumberColumn } from 'sql/base/browser/ui/table/plugins/rowNumberColumn.plugin'; @@ -35,6 +33,8 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService import { KeyCode } from 'vs/base/common/keyCodes'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { EditUpdateCellResult } from 'azdata'; +import { ILogService } from 'vs/platform/log/common/log'; +import { deepClone } from 'vs/base/common/objects'; export const EDITDATA_SELECTOR: string = 'editdata-component'; @Component({ @@ -96,9 +96,10 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On @Inject(IContextKeyService) contextKeyService: IContextKeyService, @Inject(IConfigurationService) configurationService: IConfigurationService, @Inject(IClipboardService) clipboardService: IClipboardService, - @Inject(IQueryEditorService) queryEditorService: IQueryEditorService + @Inject(IQueryEditorService) queryEditorService: IQueryEditorService, + @Inject(ILogService) logService: ILogService ) { - super(el, cd, contextMenuService, keybindingService, contextKeyService, configurationService, clipboardService, queryEditorService); + super(el, cd, contextMenuService, keybindingService, contextKeyService, configurationService, clipboardService, queryEditorService, logService); this._el.nativeElement.className = 'slickgridContainer'; this.dataService = params.dataService; this.actionProvider = this.instantiationService.createInstance(EditDataGridActionProvider, this.dataService, this.onGridSelectAll(), this.onDeleteRow(), this.onRevertRow()); @@ -133,7 +134,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On self.handleEditSessionReady(self, event); break; default: - error('Unexpected query event type "' + event.type + '" sent'); + this.logService.error('Unexpected query event type "' + event.type + '" sent'); break; } self._cd.detectChanges(); @@ -381,7 +382,7 @@ export class EditDataComponent extends GridParentComponent implements OnInit, On self.dataSet = dataSet; // Create a dataSet to render without rows to reduce DOM size - let undefinedDataSet = clone(dataSet); + let undefinedDataSet = deepClone(dataSet); undefinedDataSet.columnDefinitions = dataSet.columnDefinitions; undefinedDataSet.dataRows = undefined; undefinedDataSet.resized = new EventEmitter(); diff --git a/src/sql/workbench/parts/grid/views/gridParentComponent.ts b/src/sql/workbench/parts/grid/views/gridParentComponent.ts index 80d67a9e8f..45175ea881 100644 --- a/src/sql/workbench/parts/grid/views/gridParentComponent.ts +++ b/src/sql/workbench/parts/grid/views/gridParentComponent.ts @@ -19,7 +19,6 @@ import * as actions from 'sql/workbench/parts/grid/views/gridActions'; import * as Services from 'sql/base/browser/ui/table/formatters'; import * as GridContentEvents from 'sql/workbench/parts/grid/common/gridContentEvents'; import { ResultsVisibleContext, ResultsGridFocussedContext, ResultsMessagesFocussedContext, QueryEditorVisibleContext } from 'sql/workbench/parts/query/common/queryContext'; -import { error } from 'sql/base/common/log'; import { IQueryEditorService } from 'sql/workbench/services/queryEditor/common/queryEditorService'; import { CellSelectionModel } from 'sql/base/browser/ui/table/plugins/cellSelectionModel.plugin'; @@ -32,6 +31,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; +import { ILogService } from 'vs/platform/log/common/log'; export abstract class GridParentComponent { // CONSTANTS @@ -95,7 +95,8 @@ export abstract class GridParentComponent { protected contextKeyService: IContextKeyService, protected configurationService: IConfigurationService, protected clipboardService: IClipboardService, - protected queryEditorService: IQueryEditorService + protected queryEditorService: IQueryEditorService, + protected logService: ILogService ) { this.toDispose = []; } @@ -160,7 +161,7 @@ export abstract class GridParentComponent { self.goToNextGrid(); break; default: - error('Unexpected grid content event type "' + type + '" sent'); + this.logService.error('Unexpected grid content event type "' + type + '" sent'); break; } }); diff --git a/src/sql/workbench/parts/notebook/cellViews/code.component.ts b/src/sql/workbench/parts/notebook/cellViews/code.component.ts index f78c4d686e..5dd6d78646 100644 --- a/src/sql/workbench/parts/notebook/cellViews/code.component.ts +++ b/src/sql/workbench/parts/notebook/cellViews/code.component.ts @@ -32,6 +32,7 @@ import { OVERRIDE_EDITOR_THEMING_SETTING } from 'sql/workbench/services/notebook import * as notebookUtils from 'sql/workbench/parts/notebook/notebookUtils'; import { UntitledEditorModel } from 'vs/workbench/common/editor/untitledEditorModel'; import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; +import { ILogService } from 'vs/platform/log/common/log'; export const CODE_SELECTOR: string = 'code-component'; const MARKDOWN_CLASS = 'markdown'; @@ -102,7 +103,8 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange @Inject(IModelService) private _modelService: IModelService, @Inject(IModeService) private _modeService: IModeService, @Inject(IConfigurationService) private _configurationService: IConfigurationService, - @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef + @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, + @Inject(ILogService) private readonly logService: ILogService ) { super(); this._cellToggleMoreActions = this._instantiationService.createInstance(CellToggleMoreActions); @@ -141,9 +143,9 @@ export class CodeComponent extends AngularDisposable implements OnInit, OnChange let cellUri = this.cellModel.cellUri.toString(); let connectionService = this.connectionService; if (!shouldConnect && connectionService && connectionService.isConnected(cellUri)) { - connectionService.disconnect(cellUri).catch(e => console.log(e)); + connectionService.disconnect(cellUri).catch(e => this.logService.error(e)); } else if (shouldConnect && this._model.activeConnection && this._model.activeConnection.id !== '-1') { - connectionService.connect(this._model.activeConnection, cellUri).catch(e => console.log(e)); + connectionService.connect(this._model.activeConnection, cellUri).catch(e => this.logService.error(e)); } } } diff --git a/src/sql/workbench/parts/notebook/cellViews/codeActions.ts b/src/sql/workbench/parts/notebook/cellViews/codeActions.ts index 6a933e4dab..a0f01952c7 100644 --- a/src/sql/workbench/parts/notebook/cellViews/codeActions.ts +++ b/src/sql/workbench/parts/notebook/cellViews/codeActions.ts @@ -15,6 +15,7 @@ import { ICellModel, CellExecutionState } from 'sql/workbench/parts/notebook/mod import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement'; import { MultiStateAction, IMultiStateData } from 'sql/workbench/parts/notebook/notebookActions'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { ILogService } from 'vs/platform/log/common/log'; let notebookMoreActionMsg = localize('notebook.failed', "Please select active cell and try again"); const emptyExecutionCountLabel = '[ ]'; @@ -69,13 +70,15 @@ export class RunCellAction extends MultiStateAction { private _context: CellContext; constructor(context: CellContext, @INotificationService private notificationService: INotificationService, @IConnectionManagementService private connectionManagementService: IConnectionManagementService, - @IKeybindingService private keybindingService: IKeybindingService) { + @IKeybindingService keybindingService: IKeybindingService, + @ILogService logService: ILogService + ) { super(RunCellAction.ID, new IMultiStateData([ { key: CellExecutionState.Hidden, value: { label: emptyExecutionCountLabel, className: '', tooltip: '', hideIcon: true } }, { key: CellExecutionState.Stopped, value: { label: '', className: 'toolbarIconRun', tooltip: localize('runCell', "Run cell"), commandId: 'notebook.command.runactivecell' } }, { key: CellExecutionState.Running, value: { label: '', className: 'toolbarIconStop', tooltip: localize('stopCell', "Cancel execution") } }, { key: CellExecutionState.Error, value: { label: '', className: 'toolbarIconRunError', tooltip: localize('errorRunCell', "Error on last run. Click to run again") } }, - ], CellExecutionState.Hidden), keybindingService); + ], CellExecutionState.Hidden), keybindingService, logService); this.ensureContextIsUpdated(context); } diff --git a/src/sql/workbench/parts/notebook/models/notebookModel.ts b/src/sql/workbench/parts/notebook/models/notebookModel.ts index b0bca39829..2d96cc0399 100644 --- a/src/sql/workbench/parts/notebook/models/notebookModel.ts +++ b/src/sql/workbench/parts/notebook/models/notebookModel.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import { nb, connection } from 'azdata'; import { localize } from 'vs/nls'; @@ -24,6 +22,7 @@ import { ISingleNotebookEditOperation } from 'sql/workbench/api/common/sqlExtHos import { ConnectionProfile } from 'sql/platform/connection/common/connectionProfile'; import { uriPrefixes } from 'sql/platform/connection/common/utils'; import { keys } from 'vs/base/common/map'; +import { ILogService } from 'vs/platform/log/common/log'; /* * Used to control whether a message in a dialog/wizard is displayed as an error, @@ -74,7 +73,11 @@ export class NotebookModel extends Disposable implements INotebookModel { private _clientSessionListeners: IDisposable[] = []; private _connectionUrisToDispose: string[] = []; - constructor(private _notebookOptions: INotebookModelOptions, startSessionImmediately?: boolean, public connectionProfile?: IConnectionProfile) { + constructor( + private _notebookOptions: INotebookModelOptions, + public connectionProfile: IConnectionProfile | undefined, + @ILogService private readonly logService: ILogService + ) { super(); if (!_notebookOptions || !_notebookOptions.notebookUri || !_notebookOptions.notebookManagers) { throw new Error('path or notebook service not defined'); @@ -588,7 +591,7 @@ export class NotebookModel extends Disposable implements INotebookModel { await this.updateKernelInfoOnKernelChange(kernel); } catch (err2) { // TODO should we handle this in any way? - console.log(`doChangeKernel: ignoring error ${notebookUtils.getErrorMessage(err2)}`); + this.logService.error(`doChangeKernel: ignoring error ${notebookUtils.getErrorMessage(err2)}`); } } } @@ -777,7 +780,7 @@ export class NotebookModel extends Disposable implements INotebookModel { } await this.shutdownActiveSession(); } catch (err) { - console.log('An error occurred when closing the notebook: {0}', notebookUtils.getErrorMessage(err)); + this.logService.error('An error occurred when closing the notebook: {0}', notebookUtils.getErrorMessage(err)); } } @@ -895,14 +898,14 @@ export class NotebookModel extends Disposable implements INotebookModel { private async disconnectNotebookConnection(conn: ConnectionProfile): Promise { if (this.notebookOptions.connectionService.getConnectionUri(conn).includes(uriPrefixes.notebook)) { let uri = this._notebookOptions.connectionService.getConnectionUri(conn); - await this.notebookOptions.connectionService.disconnect(uri).catch(e => console.log(e)); + await this.notebookOptions.connectionService.disconnect(uri).catch(e => this.logService.error(e)); } } // Disconnect any connections that were added through the "Add new connection" functionality in the Attach To dropdown private async disconnectAttachToConnections(): Promise { notebookUtils.asyncForEach(this._connectionUrisToDispose, async conn => { - await this.notebookOptions.connectionService.disconnect(conn).catch(e => console.log(e)); + await this.notebookOptions.connectionService.disconnect(conn).catch(e => this.logService.error(e)); }); this._connectionUrisToDispose = []; } diff --git a/src/sql/workbench/parts/notebook/notebook.component.ts b/src/sql/workbench/parts/notebook/notebook.component.ts index 9194a4167c..39bce9b7e0 100644 --- a/src/sql/workbench/parts/notebook/notebook.component.ts +++ b/src/sql/workbench/parts/notebook/notebook.component.ts @@ -41,12 +41,12 @@ import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilit import { CellMagicMapper } from 'sql/workbench/parts/notebook/models/cellMagicMapper'; import { IExtensionsViewlet, VIEWLET_ID } from 'vs/workbench/contrib/extensions/common/extensions'; import { CellModel } from 'sql/workbench/parts/notebook/models/cell'; -import { ICommandService } from 'vs/platform/commands/common/commands'; import { FileOperationError, FileOperationResult } from 'vs/platform/files/common/files'; import { isValidBasename } from 'vs/base/common/extpath'; import { basename } from 'vs/base/common/resources'; -import { createErrorWithActions, isErrorWithActions } from 'vs/base/common/errorsWithActions'; +import { createErrorWithActions } from 'vs/base/common/errorsWithActions'; import { toErrorMessage } from 'vs/base/common/errorMessage'; +import { ILogService } from 'vs/platform/log/common/log'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; @@ -93,8 +93,8 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe @Inject(IKeybindingService) private keybindingService: IKeybindingService, @Inject(IViewletService) private viewletService: IViewletService, @Inject(ICapabilitiesService) private capabilitiesService: ICapabilitiesService, - @Inject(ICommandService) private commandService: ICommandService, - @Inject(ITextFileService) private textFileService: ITextFileService + @Inject(ITextFileService) private textFileService: ITextFileService, + @Inject(ILogService) private readonly logService: ILogService ) { super(); this.updateProfile(); @@ -292,7 +292,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe defaultKernel: this._notebookParams.input.defaultKernel, layoutChanged: this._notebookParams.input.layoutChanged, capabilitiesService: this.capabilitiesService - }, false, this.profile); + }, this.profile, this.logService); model.onError((errInfo: INotification) => this.handleModelError(errInfo)); await model.requestModelLoad(this._notebookParams.isTrusted); model.contentChanged((change) => this.handleContentChanged(change)); @@ -400,7 +400,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe let attachToContainer = document.createElement('div'); let attachToDropdown = new AttachToDropdown(attachToContainer, this.contextViewService, this.modelReady, - this.connectionManagementService, this.connectionDialogService, this.notificationService, this.capabilitiesService); + this.connectionManagementService, this.connectionDialogService, this.notificationService, this.capabilitiesService, this.logService); attachToDropdown.render(attachToContainer); attachSelectBoxStyler(attachToDropdown, this.themeService); diff --git a/src/sql/workbench/parts/notebook/notebookActions.ts b/src/sql/workbench/parts/notebook/notebookActions.ts index 3c96283b38..7fcdfd93e3 100644 --- a/src/sql/workbench/parts/notebook/notebookActions.ts +++ b/src/sql/workbench/parts/notebook/notebookActions.ts @@ -23,6 +23,7 @@ import { IConnectionDialogService } from 'sql/workbench/services/connection/comm import { NotebookModel } from 'sql/workbench/parts/notebook/models/notebookModel'; import { generateUri } from 'sql/platform/connection/common/utils'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; +import { ILogService } from 'vs/platform/log/common/log'; const msgLoading = localize('loading', "Loading kernels..."); const msgChanging = localize('changing', "Changing kernel..."); @@ -164,7 +165,11 @@ export class IMultiStateData { export abstract class MultiStateAction extends Action { - constructor(id: string, protected states: IMultiStateData, private _keybindingService: IKeybindingService) { + constructor( + id: string, + protected states: IMultiStateData, + private _keybindingService: IKeybindingService, + private readonly logService: ILogService) { super(id, ''); this.updateLabelAndIcon(); } @@ -178,7 +183,7 @@ export abstract class MultiStateAction extends Action { keyboardShortcut = binding ? binding.getLabel() : undefined; } } catch (error) { - console.log(error); + this.logService.error(error); } this.label = this.states.label; this.tooltip = keyboardShortcut ? this.states.tooltip + ` (${keyboardShortcut})` : this.states.tooltip; @@ -313,11 +318,14 @@ export class KernelsDropdown extends SelectBox { export class AttachToDropdown extends SelectBox { private model: NotebookModel; - constructor(container: HTMLElement, contextViewProvider: IContextViewProvider, modelReady: Promise, + constructor( + container: HTMLElement, contextViewProvider: IContextViewProvider, modelReady: Promise, @IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IConnectionDialogService private _connectionDialogService: IConnectionDialogService, @INotificationService private _notificationService: INotificationService, - @ICapabilitiesService private _capabilitiesService: ICapabilitiesService) { + @ICapabilitiesService private _capabilitiesService: ICapabilitiesService, + @ILogService private readonly logService: ILogService + ) { super([msgLoadingContexts], msgLoadingContexts, contextViewProvider, container, { labelText: attachToLabel, labelOnTop: false } as ISelectBoxOptionsWithLabel); if (modelReady) { modelReady @@ -366,7 +374,7 @@ export class AttachToDropdown extends SelectBox { this.openConnectionDialog(true); } }).catch(err => - console.log(err)); + this.logService.error(err)); } model.onValidConnectionSelected(validConnection => { this.handleContextsChanged(!validConnection); diff --git a/src/sql/workbench/parts/objectExplorer/browser/serverGroupDialog.ts b/src/sql/workbench/parts/objectExplorer/browser/serverGroupDialog.ts index 28c5287342..f3b58ea162 100644 --- a/src/sql/workbench/parts/objectExplorer/browser/serverGroupDialog.ts +++ b/src/sql/workbench/parts/objectExplorer/browser/serverGroupDialog.ts @@ -26,6 +26,7 @@ import { ServerGroupViewModel } from 'sql/workbench/parts/objectExplorer/common/ import { attachButtonStyler, attachModalDialogStyler } from 'sql/platform/theme/common/styler'; import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService'; +import { ILogService } from 'vs/platform/log/common/log'; export class ServerGroupDialog extends Modal { private _addServerButton: Button; @@ -53,9 +54,10 @@ export class ServerGroupDialog extends Modal { @IContextViewService private _contextViewService: IContextViewService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { - super(localize('ServerGroupsDialogTitle', 'Server Groups'), TelemetryKeys.ServerGroups, telemetryService, layoutService, clipboardService, themeService, contextKeyService); + super(localize('ServerGroupsDialogTitle', 'Server Groups'), TelemetryKeys.ServerGroups, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService); } public render() { diff --git a/src/sql/workbench/parts/profiler/browser/profilerColumnEditorDialog.ts b/src/sql/workbench/parts/profiler/browser/profilerColumnEditorDialog.ts index 95e727cf33..2bde7b496d 100644 --- a/src/sql/workbench/parts/profiler/browser/profilerColumnEditorDialog.ts +++ b/src/sql/workbench/parts/profiler/browser/profilerColumnEditorDialog.ts @@ -24,7 +24,8 @@ import { Event, Emitter } from 'vs/base/common/event'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; class EventItem { @@ -309,14 +310,15 @@ export class ProfilerColumnEditorDialog extends Modal { private _treeContainer: HTMLElement; constructor( - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, + @ILayoutService layoutService: ILayoutService, @IThemeService themeService: IThemeService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, @IContextViewService private _contextViewService: IContextViewService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { - super(nls.localize('profilerColumnDialog.profiler', 'Profiler'), TelemetryKeys.Profiler, telemetryService, layoutService, clipboardService, themeService, contextKeyService); + super(nls.localize('profilerColumnDialog.profiler', 'Profiler'), TelemetryKeys.Profiler, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService); } public render(): void { diff --git a/src/sql/workbench/parts/profiler/browser/profilerFilterDialog.ts b/src/sql/workbench/parts/profiler/browser/profilerFilterDialog.ts index 5d7093d2f8..7fda8a3029 100644 --- a/src/sql/workbench/parts/profiler/browser/profilerFilterDialog.ts +++ b/src/sql/workbench/parts/profiler/browser/profilerFilterDialog.ts @@ -23,7 +23,8 @@ import { generateUuid } from 'vs/base/common/uuid'; import * as DOM from 'vs/base/browser/dom'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { ProfilerFilter, ProfilerFilterClause, ProfilerFilterClauseOperator } from 'sql/workbench/services/profiler/common/interfaces'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; const ClearText: string = localize('profilerFilterDialog.clear', "Clear All"); @@ -70,12 +71,13 @@ export class ProfilerFilterDialog extends Modal { constructor( @IThemeService themeService: IThemeService, @IClipboardService clipboardService: IClipboardService, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, + @ILayoutService layoutService: ILayoutService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, + @ILogService logService: ILogService, @IContextViewService private contextViewService: IContextViewService ) { - super('', TelemetryKeys.ProfilerFilter, telemetryService, layoutService, clipboardService, themeService, contextKeyService, { isFlyout: false, hasTitleIcon: true }); + super('', TelemetryKeys.ProfilerFilter, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, { isFlyout: false, hasTitleIcon: true }); } public open(input: ProfilerInput) { diff --git a/src/sql/workbench/parts/query/electron-browser/gridPanel.ts b/src/sql/workbench/parts/query/electron-browser/gridPanel.ts index c824553280..21742e3cfd 100644 --- a/src/sql/workbench/parts/query/electron-browser/gridPanel.ts +++ b/src/sql/workbench/parts/query/electron-browser/gridPanel.ts @@ -21,7 +21,6 @@ import { hyperLinkFormatter, textFormatter } from 'sql/base/browser/ui/table/for import { CopyKeybind } from 'sql/base/browser/ui/table/plugins/copyKeybind.plugin'; import { AdditionalKeyBindings } from 'sql/base/browser/ui/table/plugins/additionalKeyBindings.plugin'; import { ITableStyles, ITableMouseEvent } from 'sql/base/browser/ui/table/interfaces'; -import { warn } from 'sql/base/common/log'; import * as azdata from 'azdata'; @@ -43,6 +42,7 @@ import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/un import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IAction } from 'vs/base/common/actions'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; +import { ILogService } from 'vs/platform/log/common/log'; const ROW_HEIGHT = 29; const HEADER_HEIGHT = 26; @@ -134,7 +134,8 @@ export class GridPanel extends ViewletPanel { @IContextMenuService contextMenuService: IContextMenuService, @IConfigurationService configurationService: IConfigurationService, @IThemeService private themeService: IThemeService, - @IInstantiationService private instantiationService: IInstantiationService + @IInstantiationService private instantiationService: IInstantiationService, + @ILogService private logService: ILogService ) { super(options, keybindingService, contextMenuService, configurationService); this.splitView = new ScrollableSplitView(this.container, { enableResizing: false, verticalScrollbarVisibility: ScrollbarVisibility.Visible }); @@ -257,7 +258,7 @@ export class GridPanel extends ViewletPanel { if (table) { table.updateResult(set); } else { - warn('Got result set update request for non-existant table'); + this.logService.warn('Got result set update request for non-existant table'); } } sizeChanges(); diff --git a/src/sql/workbench/parts/restore/browser/restoreDialog.ts b/src/sql/workbench/parts/restore/browser/restoreDialog.ts index ed64b9ed3d..d3ec78efce 100644 --- a/src/sql/workbench/parts/restore/browser/restoreDialog.ts +++ b/src/sql/workbench/parts/restore/browser/restoreDialog.ts @@ -42,6 +42,7 @@ import { TabbedPanel, PanelTabIdentifier } from 'sql/base/browser/ui/panel/panel import { ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes'; import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService'; import { IFileBrowserDialogController } from 'sql/workbench/services/fileBrowser/common/fileBrowserDialogController'; +import { ILogService } from 'vs/platform/log/common/log'; interface FileListElement { logicalFileName: string; @@ -135,8 +136,9 @@ export class RestoreDialog extends Modal { @IContextKeyService contextKeyService: IContextKeyService, @IFileBrowserDialogController private fileBrowserDialogService: IFileBrowserDialogController, @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { - super(localize('RestoreDialogTitle', "Restore database"), TelemetryKeys.Restore, telemetryService, layoutService, clipboardService, themeService, contextKeyService, { hasErrors: true, isWide: true, hasSpinner: true }); + super(localize('RestoreDialogTitle', "Restore database"), TelemetryKeys.Restore, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, { hasErrors: true, isWide: true, hasSpinner: true }); this._restoreTitle = localize('restoreDialog.restoreTitle', "Restore database"); this._databaseTitle = localize('restoreDialog.database', "Database"); this._backupFileTitle = localize('restoreDialog.backupFile', "Backup file"); diff --git a/src/sql/workbench/parts/webview/electron-browser/webViewDialog.ts b/src/sql/workbench/parts/webview/electron-browser/webViewDialog.ts index 4b76ed013f..23b3be8950 100644 --- a/src/sql/workbench/parts/webview/electron-browser/webViewDialog.ts +++ b/src/sql/workbench/parts/webview/electron-browser/webViewDialog.ts @@ -19,6 +19,8 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { WebviewElement } from 'vs/workbench/contrib/webview/electron-browser/webviewElement'; import { IWorkbenchLayoutService, Parts } from 'vs/workbench/services/layout/browser/layoutService'; import * as DOM from 'vs/base/browser/dom'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; export class WebViewDialog extends Modal { @@ -40,12 +42,13 @@ export class WebViewDialog extends Modal { constructor( @IThemeService themeService: IThemeService, @IClipboardService clipboardService: IClipboardService, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, + @ILayoutService layoutService: ILayoutService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, + @ILogService logService: ILogService, @IInstantiationService private _instantiationService: IInstantiationService ) { - super('', TelemetryKeys.WebView, telemetryService, layoutService, clipboardService, themeService, contextKeyService, { isFlyout: false, hasTitleIcon: true }); + super('', TelemetryKeys.WebView, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, { isFlyout: false, hasTitleIcon: true }); this._okLabel = localize('webViewDialog.ok', 'OK'); this._closeLabel = localize('webViewDialog.close', 'Close'); } diff --git a/src/sql/workbench/services/commandLine/common/commandLineService.ts b/src/sql/workbench/services/commandLine/common/commandLineService.ts index df5ed7a744..b97b5e4d53 100644 --- a/src/sql/workbench/services/commandLine/common/commandLineService.ts +++ b/src/sql/workbench/services/commandLine/common/commandLineService.ts @@ -19,7 +19,6 @@ import * as TaskUtilities from 'sql/workbench/common/taskUtilities'; import { IObjectExplorerService } from 'sql/workbench/services/objectExplorer/common/objectExplorerService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { ICommandService } from 'vs/platform/commands/common/commands'; -import { warn } from 'sql/base/common/log'; import { ipcRenderer as ipc } from 'electron'; import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -27,6 +26,7 @@ import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar'; import { localize } from 'vs/nls'; import { QueryInput } from 'sql/workbench/parts/query/common/queryInput'; import { URI } from 'vs/base/common/uri'; +import { ILogService } from 'vs/platform/log/common/log'; export class CommandLineService implements ICommandLineProcessing { public _serviceBrand: any; @@ -40,7 +40,8 @@ export class CommandLineService implements ICommandLineProcessing { @IEditorService private _editorService: IEditorService, @ICommandService private _commandService: ICommandService, @IConfigurationService private _configurationService: IConfigurationService, - @IStatusbarService private _statusBarService: IStatusbarService + @IStatusbarService private _statusBarService: IStatusbarService, + @ILogService private logService: ILogService ) { if (ipc) { ipc.on('ads:processCommandLine', (event: any, args: ParsedArgs) => this.onLaunched(args)); @@ -56,11 +57,11 @@ export class CommandLineService implements ICommandLineProcessing { let sqlProvider = registry.getProperties(Constants.mssqlProviderName); // We can't connect to object explorer until the MSSQL connection provider is registered if (sqlProvider) { - this.processCommandLine(args).catch(reason => { warn('processCommandLine failed: ' + reason); }); + this.processCommandLine(args).catch(reason => { this.logService.warn('processCommandLine failed: ' + reason); }); } else { registry.onNewProvider(e => { if (e.id === Constants.mssqlProviderName) { - this.processCommandLine(args).catch(reason => { warn('processCommandLine failed: ' + reason); }); + this.processCommandLine(args).catch(reason => { this.logService.warn('processCommandLine failed: ' + reason); }); } }); } @@ -101,7 +102,7 @@ export class CommandLineService implements ICommandLineProcessing { let updatedProfile = this._connectionManagementService.getConnectionProfileById(profile.id); connectedContext = { connectionProfile: new ConnectionProfile(this._capabilitiesService, updatedProfile).toIConnectionProfile() }; } catch (err) { - warn('Failed to connect due to error' + err.message); + this.logService.warn('Failed to connect due to error' + err.message); } } if (commandName) { @@ -128,7 +129,7 @@ export class CommandLineService implements ICommandLineProcessing { this._objectExplorerService, this._editorService); } catch (error) { - warn('unable to open query editor ' + error); + this.logService.warn('unable to open query editor ' + error); // Note: we are intentionally swallowing this error. // In part this is to accommodate unit testing where we don't want to set up the query stack } diff --git a/src/sql/workbench/services/connection/browser/connectionDialogWidget.ts b/src/sql/workbench/services/connection/browser/connectionDialogWidget.ts index afecdc53e5..6914cb3516 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogWidget.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogWidget.ts @@ -36,6 +36,7 @@ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService'; import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; export interface OnShowUIResponse { selectedProviderType: string; @@ -95,9 +96,10 @@ export class ConnectionDialogWidget extends Modal { @IContextKeyService contextKeyService: IContextKeyService, @IContextMenuService private _contextMenuService: IContextMenuService, @IContextViewService private _contextViewService: IContextViewService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILayoutService logService: ILogService ) { - super(localize('connection', "Connection"), TelemetryKeys.Connection, telemetryService, layoutService, clipboardService, themeService, contextKeyService, { hasSpinner: true, hasErrors: true }); + super(localize('connection', "Connection"), TelemetryKeys.Connection, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, { hasSpinner: true, hasErrors: true }); } /** diff --git a/src/sql/workbench/services/dashboard/browser/newDashboardTabDialog.ts b/src/sql/workbench/services/dashboard/browser/newDashboardTabDialog.ts index 06c16ae4f6..1745d38baf 100644 --- a/src/sql/workbench/services/dashboard/browser/newDashboardTabDialog.ts +++ b/src/sql/workbench/services/dashboard/browser/newDashboardTabDialog.ts @@ -25,7 +25,8 @@ import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; import { NewDashboardTabViewModel, IDashboardUITab } from 'sql/workbench/services/dashboard/common/newDashboardTabViewModel'; import { IDashboardTab } from 'sql/platform/dashboard/common/dashboardRegistry'; import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; class ExtensionListDelegate implements IListVirtualDelegate { @@ -110,11 +111,12 @@ export class NewDashboardTabDialog extends Modal { public get onCancel(): Event { return this._onCancel.event; } constructor( - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, + @ILayoutService layoutService: ILayoutService, @IThemeService themeService: IThemeService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { super( localize('newDashboardTab.openDashboardExtensions', 'Open dashboard extensions'), @@ -123,6 +125,7 @@ export class NewDashboardTabDialog extends Modal { layoutService, clipboardService, themeService, + logService, contextKeyService, { hasSpinner: true } ); diff --git a/src/sql/workbench/services/dashboard/common/newDashboardTabDialog.ts b/src/sql/workbench/services/dashboard/common/newDashboardTabDialog.ts index 2e58c4561d..f8adb218ab 100644 --- a/src/sql/workbench/services/dashboard/common/newDashboardTabDialog.ts +++ b/src/sql/workbench/services/dashboard/common/newDashboardTabDialog.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IDashboardTab } from 'sql/platform/dashboard/common/dashboardRegistry'; diff --git a/src/sql/workbench/services/errorMessage/browser/errorMessageDialog.ts b/src/sql/workbench/services/errorMessage/browser/errorMessageDialog.ts index 6ea9d85ea9..833e863e72 100644 --- a/src/sql/workbench/services/errorMessage/browser/errorMessageDialog.ts +++ b/src/sql/workbench/services/errorMessage/browser/errorMessageDialog.ts @@ -3,7 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; import 'vs/css!sql/media/icons/common-icons'; import 'vs/css!./media/errorMessageDialog'; import { Button } from 'sql/base/browser/ui/button/button'; @@ -20,8 +19,9 @@ import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService'; import { localize } from 'vs/nls'; import { IAction } from 'vs/base/common/actions'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; import * as DOM from 'vs/base/browser/dom'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; const maxActions = 1; @@ -44,11 +44,12 @@ export class ErrorMessageDialog extends Modal { constructor( @IThemeService themeService: IThemeService, @IClipboardService clipboardService: IClipboardService, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, + @ILayoutService layoutService: ILayoutService, @ITelemetryService telemetryService: ITelemetryService, - @IContextKeyService contextKeyService: IContextKeyService + @IContextKeyService contextKeyService: IContextKeyService, + @ILogService logService: ILogService ) { - super('', TelemetryKeys.ErrorMessage, telemetryService, layoutService, clipboardService, themeService, contextKeyService, { isFlyout: false, hasTitleIcon: true }); + super('', TelemetryKeys.ErrorMessage, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, { isFlyout: false, hasTitleIcon: true }); this._okLabel = localize('errorMessageDialog.ok', 'OK'); this._closeLabel = localize('errorMessageDialog.close', 'Close'); } diff --git a/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts b/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts index 8750505619..d04493182d 100644 --- a/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts +++ b/src/sql/workbench/services/fileBrowser/browser/fileBrowserDialog.ts @@ -3,8 +3,6 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; - import 'vs/css!sql/media/icons/common-icons'; import 'vs/css!./media/fileBrowserDialog'; import { Button } from 'sql/base/browser/ui/button/button'; @@ -31,7 +29,9 @@ import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme'; import * as DOM from 'vs/base/browser/dom'; import * as strings from 'vs/base/common/strings'; import { IClipboardService } from 'sql/platform/clipboard/common/clipboardService'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; +import { IThemeService } from 'vs/platform/theme/common/themeService'; +import { ILogService } from 'vs/platform/log/common/log'; export class FileBrowserDialog extends Modal { private _viewModel: FileBrowserViewModel; @@ -49,15 +49,16 @@ export class FileBrowserDialog extends Modal { private _isFolderSelected: boolean; constructor(title: string, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @IWorkbenchThemeService private _workbenchthemeService: IWorkbenchThemeService, + @ILayoutService layoutService: ILayoutService, + @IThemeService themeService: IThemeService, @IInstantiationService private _instantiationService: IInstantiationService, @IContextViewService private _contextViewService: IContextViewService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, - @IClipboardService clipboardService: IClipboardService + @IClipboardService clipboardService: IClipboardService, + @ILogService logService: ILogService ) { - super(title, TelemetryKeys.Backup, telemetryService, layoutService, clipboardService, _workbenchthemeService, contextKeyService, { isFlyout: true, hasTitleIcon: false, hasBackButton: true, hasSpinner: true }); + super(title, TelemetryKeys.Backup, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService, { isFlyout: true, hasTitleIcon: false, hasBackButton: true, hasSpinner: true }); this._viewModel = this._instantiationService.createInstance(FileBrowserViewModel); this._viewModel.onAddFileTree(args => this.handleOnAddFileTree(args.rootNode, args.selectedNode, args.expandedNodes)); this._viewModel.onPathValidate(args => this.handleOnValidate(args.succeeded, args.message)); @@ -228,7 +229,7 @@ export class FileBrowserDialog extends Modal { this._register(attachButtonStyler(this._okButton, this._themeService)); this._register(attachButtonStyler(this._cancelButton, this._themeService)); - this._register(this._workbenchthemeService.onDidColorThemeChange(e => this.updateTheme())); + this._register(this._themeService.onThemeChange(e => this.updateTheme())); } // Update theming that is specific to file browser diff --git a/src/sql/workbench/services/insights/browser/insightsDialogView.ts b/src/sql/workbench/services/insights/browser/insightsDialogView.ts index f9632dceea..f39b399106 100644 --- a/src/sql/workbench/services/insights/browser/insightsDialogView.ts +++ b/src/sql/workbench/services/insights/browser/insightsDialogView.ts @@ -15,7 +15,6 @@ import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; import { IInsightsDialogModel, ListResource, IInsightDialogActionContext, insertValueRegex } from 'sql/workbench/services/insights/common/insightsDialogService'; import { TableDataView } from 'sql/base/browser/ui/table/tableDataView'; import { RowSelectionModel } from 'sql/base/browser/ui/table/plugins/rowSelectionModel.plugin'; -import { error } from 'sql/base/common/log'; import { Table } from 'sql/base/browser/ui/table/table'; import { CopyInsightDialogSelectionAction } from 'sql/workbench/services/insights/common/insightDialogActions'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; @@ -40,7 +39,8 @@ import { SplitView, Orientation, Sizing } from 'vs/base/browser/ui/splitview/spl import { ViewletPanel, IViewletPanelOptions } from 'vs/workbench/browser/parts/views/panelViewlet'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService'; +import { ILogService } from 'vs/platform/log/common/log'; +import { ILayoutService } from 'vs/platform/layout/browser/layoutService'; const labelDisplay = nls.localize("insights.item", "Item"); const valueDisplay = nls.localize("insights.value", "Value"); @@ -156,17 +156,18 @@ export class InsightsDialogView extends Modal { constructor( private _model: IInsightsDialogModel, - @IInstantiationService private _instantiationService: IInstantiationService, @IThemeService themeService: IThemeService, - @IWorkbenchLayoutService layoutService: IWorkbenchLayoutService, - @IContextMenuService private _contextMenuService: IContextMenuService, + @IClipboardService clipboardService: IClipboardService, + @ILayoutService layoutService: ILayoutService, @ITelemetryService telemetryService: ITelemetryService, @IContextKeyService contextKeyService: IContextKeyService, - @ICommandService private _commandService: ICommandService, - @ICapabilitiesService private _capabilitiesService: ICapabilitiesService, - @IClipboardService clipboardService: IClipboardService + @ILogService logService: ILogService, + @IInstantiationService private readonly _instantiationService: IInstantiationService, + @IContextMenuService private readonly _contextMenuService: IContextMenuService, + @ICommandService private readonly _commandService: ICommandService, + @ICapabilitiesService private readonly _capabilitiesService: ICapabilitiesService ) { - super(nls.localize("InsightsDialogTitle", "Insights"), TelemetryKeys.Insights, telemetryService, layoutService, clipboardService, themeService, contextKeyService); + super(nls.localize("InsightsDialogTitle", "Insights"), TelemetryKeys.Insights, telemetryService, layoutService, clipboardService, themeService, logService, contextKeyService); this._model.onDataChange(e => this.build()); } @@ -411,7 +412,7 @@ export class InsightsDialogView extends Modal { if (match && match.length > 0) { let index = this._model.columns.indexOf(match[1]); if (index === -1) { - error('Could not find column', match[1]); + this.logService.error('Could not find column', match[1]); } else { database = database.replace(match[0], element.data[index]); } @@ -421,7 +422,7 @@ export class InsightsDialogView extends Modal { if (match && match.length > 0) { let index = this._model.columns.indexOf(match[1]); if (index === -1) { - error('Could not find column', match[1]); + this.logService.error('Could not find column', match[1]); } else { server = server.replace(match[0], element.data[index]); } @@ -431,7 +432,7 @@ export class InsightsDialogView extends Modal { if (match && match.length > 0) { let index = this._model.columns.indexOf(match[1]); if (index === -1) { - error('Could not find column', match[1]); + this.logService.error('Could not find column', match[1]); } else { user = user.replace(match[0], element.data[index]); } diff --git a/src/sql/workbench/services/insights/node/insightsDialogController.ts b/src/sql/workbench/services/insights/node/insightsDialogController.ts index 98d29e7b10..4c9ee8ce9b 100644 --- a/src/sql/workbench/services/insights/node/insightsDialogController.ts +++ b/src/sql/workbench/services/insights/node/insightsDialogController.ts @@ -9,7 +9,6 @@ import { IInsightsConfigDetails } from 'sql/workbench/parts/dashboard/widgets/in import QueryRunner, { EventType as QREvents } from 'sql/platform/query/common/queryRunner'; import * as Utils from 'sql/platform/connection/common/utils'; import { IInsightsDialogModel } from 'sql/workbench/services/insights/common/insightsDialogService'; -import { error } from 'sql/base/common/log'; import { IErrorMessageService } from 'sql/platform/errorMessage/common/errorMessageService'; import { resolveQueryFilePath } from '../common/insightsUtils'; @@ -23,6 +22,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { INotificationService } from 'vs/platform/notification/common/notification'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; +import { ILogService } from 'vs/platform/log/common/log'; export class InsightsDialogController { private _queryRunner: QueryRunner; @@ -38,7 +38,8 @@ export class InsightsDialogController { @IInstantiationService private _instantiationService: IInstantiationService, @IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @IWorkspaceContextService private _workspaceContextService: IWorkspaceContextService, - @IConfigurationResolverService private _configurationResolverService: IConfigurationResolverService + @IConfigurationResolverService private _configurationResolverService: IConfigurationResolverService, + @ILogService private logService: ILogService ) { } public async update(input: IInsightsConfigDetails, connectionProfile: IConnectionProfile): Promise { @@ -87,7 +88,7 @@ export class InsightsDialogController { }); } } else { - error('Error reading details Query: ', input); + this.logService.error('Error reading details Query: ', input); this._notificationService.notify({ severity: Severity.Error, message: nls.localize("insightsConfigError", "There was an error parsing the insight config; could not find query array/string or queryfile") diff --git a/src/sql/workbench/services/notebook/sql/sqlSessionManager.ts b/src/sql/workbench/services/notebook/sql/sqlSessionManager.ts index 6bc40db9b9..57687e3adc 100644 --- a/src/sql/workbench/services/notebook/sql/sqlSessionManager.ts +++ b/src/sql/workbench/services/notebook/sql/sqlSessionManager.ts @@ -22,6 +22,7 @@ import { elapsedTimeLabel } from 'sql/workbench/parts/query/common/localizedCons import * as notebookUtils from 'sql/workbench/parts/notebook/notebookUtils'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; +import { ILogService } from 'vs/platform/log/common/log'; export const sqlKernelError: string = localize("sqlKernelError", "SQL kernel error"); export const MAX_ROWS = 5000; @@ -166,7 +167,8 @@ class SqlKernel extends Disposable implements nb.IKernel { @ICapabilitiesService private _capabilitiesService: ICapabilitiesService, @IInstantiationService private _instantiationService: IInstantiationService, @IErrorMessageService private _errorMessageService: IErrorMessageService, - @IConfigurationService private _configurationService: IConfigurationService + @IConfigurationService private _configurationService: IConfigurationService, + @ILogService private readonly logService: ILogService ) { super(); this.initMagics(); @@ -261,7 +263,7 @@ class SqlKernel extends Disposable implements nb.IKernel { // TODO verify this is "canonical" behavior let count = canRun ? ++this._executionCount : undefined; - this._future = new SQLFuture(this._queryRunner, count, this._configurationService); + this._future = new SQLFuture(this._queryRunner, count, this._configurationService, this.logService); if (!canRun) { // Complete early this._future.handleDone(new Error(localize('connectionRequired', "A connection must be chosen to run notebook cells"))); @@ -333,7 +335,7 @@ class SqlKernel extends Disposable implements nb.IKernel { try { await this._connectionManagementService.disconnect(this._path); } catch (err) { - console.log(err); + this.logService.error(err); } } } @@ -348,7 +350,12 @@ export class SQLFuture extends Disposable implements FutureInternal { private doneDeferred = new Deferred(); private configuredMaxRows: number = MAX_ROWS; private _outputAddedPromises: Promise[] = []; - constructor(private _queryRunner: QueryRunner, private _executionCount: number | undefined, private configurationService: IConfigurationService) { + constructor( + private _queryRunner: QueryRunner, + private _executionCount: number | undefined, + configurationService: IConfigurationService, + private readonly logService: ILogService + ) { super(); let config = configurationService.getValue(NotebookConfigSectionName); if (config) { @@ -450,7 +457,7 @@ export class SQLFuture extends Disposable implements FutureInternal { } } catch (err) { // TODO should we output this somewhere else? - console.log(`Error outputting result sets from Notebook query: ${err}`); + this.logService.error(`Error outputting result sets from Notebook query: ${err}`); } } diff --git a/src/sql/workbench/services/objectExplorer/common/objectExplorerService.ts b/src/sql/workbench/services/objectExplorer/common/objectExplorerService.ts index 68e31c7b78..e59ec6dacc 100644 --- a/src/sql/workbench/services/objectExplorer/common/objectExplorerService.ts +++ b/src/sql/workbench/services/objectExplorer/common/objectExplorerService.ts @@ -16,11 +16,11 @@ import * as nls from 'vs/nls'; import * as TelemetryKeys from 'sql/platform/telemetry/telemetryKeys'; import * as TelemetryUtils from 'sql/platform/telemetry/telemetryUtilities'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; -import { warn, error } from 'sql/base/common/log'; import { ServerTreeView } from 'sql/workbench/parts/objectExplorer/browser/serverTreeView'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; import * as Utils from 'sql/platform/connection/common/utils'; import { entries } from 'sql/base/common/objects'; +import { ILogService } from 'vs/platform/log/common/log'; export const SERVICE_ID = 'ObjectExplorerService'; @@ -146,7 +146,8 @@ export class ObjectExplorerService implements IObjectExplorerService { constructor( @IConnectionManagementService private _connectionManagementService: IConnectionManagementService, @ITelemetryService private _telemetryService: ITelemetryService, - @ICapabilitiesService private _capabilitiesService: ICapabilitiesService + @ICapabilitiesService private _capabilitiesService: ICapabilitiesService, + @ILogService private logService: ILogService ) { this._onUpdateObjectExplorerNodes = new Emitter(); this._activeObjectExplorerNodes = {}; @@ -206,7 +207,7 @@ export class ObjectExplorerService implements IObjectExplorerService { public onNodeExpanded(expandResponse: NodeExpandInfoWithProviderId) { if (expandResponse.errorMessage) { - error(expandResponse.errorMessage); + this.logService.error(expandResponse.errorMessage); } let sessionStatus = this._sessions[expandResponse.sessionId]; @@ -219,7 +220,7 @@ export class ObjectExplorerService implements IObjectExplorerService { } } if (!foundSession) { - warn(`Cannot find node status for session: ${expandResponse.sessionId} and node path: ${expandResponse.nodePath}`); + this.logService.warn(`Cannot find node status for session: ${expandResponse.sessionId} and node path: ${expandResponse.nodePath}`); } } @@ -232,7 +233,7 @@ export class ObjectExplorerService implements IObjectExplorerService { } else { let errorMessage = session && session.errorMessage ? session.errorMessage : nls.localize('OeSessionFailedError', 'Failed to create Object Explorer session'); - error(errorMessage); + this.logService.error(errorMessage); } } @@ -252,7 +253,7 @@ export class ObjectExplorerService implements IObjectExplorerService { else { errorMessage = session && session.errorMessage ? session.errorMessage : nls.localize('OeSessionFailedError', 'Failed to create Object Explorer session'); - error(errorMessage); + this.logService.error(errorMessage); } // Send on session created about the session to all node providers so they can prepare for node expansion let nodeProviders = this._nodeProviders[connection.providerName]; @@ -262,12 +263,12 @@ export class ObjectExplorerService implements IObjectExplorerService { } } else { - warn(`cannot find session ${session.sessionId}`); + this.logService.warn(`cannot find session ${session.sessionId}`); } this.sendUpdateNodeEvent(connection, errorMessage); } catch (error) { - warn(`cannot handle the session ${session.sessionId} in all nodeProviders`); + this.logService.warn(`cannot handle the session ${session.sessionId} in all nodeProviders`); } } @@ -290,7 +291,7 @@ export class ObjectExplorerService implements IObjectExplorerService { } } } else { - warn(`Cannot find session ${session.sessionId}`); + this.logService.warn(`Cannot find session ${session.sessionId}`); } } @@ -348,7 +349,7 @@ export class ObjectExplorerService implements IObjectExplorerService { return new Promise((resolve, reject) => { let provider = this._providers[providerId]; if (provider) { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.ObjectExplorerExpand, { refresh: 0, provider: providerId }); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.ObjectExplorerExpand, { refresh: 0, provider: providerId }); this.expandOrRefreshNode(providerId, session, nodePath).then(result => { resolve(result); }, error => { @@ -398,7 +399,7 @@ export class ObjectExplorerService implements IObjectExplorerService { if (expandResult && expandResult.providerId) { resultMap.set(expandResult.providerId, expandResult); } else { - error('OE provider returns empty result or providerId'); + this.logService.error('OE provider returns empty result or providerId'); } // When get all responses from all providers, merge results @@ -486,7 +487,7 @@ export class ObjectExplorerService implements IObjectExplorerService { public refreshNode(providerId: string, session: azdata.ObjectExplorerSession, nodePath: string): Thenable { let provider = this._providers[providerId]; if (provider) { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.ObjectExplorerExpand, { refresh: 1, provider: providerId }); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.ObjectExplorerExpand, { refresh: 1, provider: providerId }); return this.expandOrRefreshNode(providerId, session, nodePath, true); } return Promise.resolve(undefined); diff --git a/src/sql/workbench/services/resourceProvider/browser/resourceProviderService.ts b/src/sql/workbench/services/resourceProvider/browser/resourceProviderService.ts index c1d4916563..29d4c41d60 100644 --- a/src/sql/workbench/services/resourceProvider/browser/resourceProviderService.ts +++ b/src/sql/workbench/services/resourceProvider/browser/resourceProviderService.ts @@ -14,6 +14,7 @@ import { FirewallRuleDialogController } from 'sql/platform/accounts/browser/fire import * as azdata from 'azdata'; import { invalidProvider } from 'sql/base/common/errors'; +import { ILogService } from 'vs/platform/log/common/log'; export class ResourceProviderService implements IResourceProviderService { @@ -24,6 +25,7 @@ export class ResourceProviderService implements IResourceProviderService { constructor( @ITelemetryService private _telemetryService: ITelemetryService, @IInstantiationService private _instantiationService: IInstantiationService, + @ILogService private readonly logService: ILogService ) { } @@ -47,7 +49,7 @@ export class ResourceProviderService implements IResourceProviderService { return new Promise((resolve, reject) => { const provider = this._providers[resourceProviderId]; if (provider) { - TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.FirewallRuleRequested, { provider: resourceProviderId }); + TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.FirewallRuleRequested, { provider: resourceProviderId }); provider.createFirewallRule(selectedAccount, firewallruleInfo).then(result => { resolve(result); }, error => { diff --git a/src/sqltest/common/telemetryUtilities.test.ts b/src/sqltest/common/telemetryUtilities.test.ts index db960fad07..119b090123 100644 --- a/src/sqltest/common/telemetryUtilities.test.ts +++ b/src/sqltest/common/telemetryUtilities.test.ts @@ -3,12 +3,12 @@ * Licensed under the Source EULA. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -'use strict'; import * as TelemetryUtils from 'sql/platform/telemetry/telemetryUtilities'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { TelemetryServiceStub } from 'sqltest/stubs/telemetryServiceStub'; import * as TypeMoq from 'typemoq'; import * as assert from 'assert'; +import { TestLogService } from 'vs/workbench/test/workbenchTestServices'; suite('SQL Telemetry Utilities tests', () => { let telemetryService: TypeMoq.Mock; @@ -42,8 +42,8 @@ suite('SQL Telemetry Utilities tests', () => { test('addTelemetry should add provider id using the connection', (done) => { let data: TelemetryUtils.IConnectionTelemetryData = { }; - - TelemetryUtils.addTelemetry(telemetryService.object, telemetryKey, data, connectionProfile).then(() => { + const logService = new TestLogService(); + TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { telemetryService.verify(x => x.publicLog(TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b.provider === providerName)), TypeMoq.Times.once()); done(); }).catch(err => { @@ -59,7 +59,8 @@ suite('SQL Telemetry Utilities tests', () => { }; data.test1 = '1'; - TelemetryUtils.addTelemetry(telemetryService.object, telemetryKey, data, connectionProfile).then(() => { + const logService = new TestLogService(); + TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { telemetryService.verify(x => x.publicLog( TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b.provider === providerName @@ -75,7 +76,9 @@ suite('SQL Telemetry Utilities tests', () => { }); test('addTelemetry should not crash not given data', (done) => { - TelemetryUtils.addTelemetry(telemetryService.object, telemetryKey).then(() => { + + const logService = new TestLogService(); + TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey).then(() => { telemetryService.verify(x => x.publicLog( TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b !== undefined)), TypeMoq.Times.once()); @@ -92,7 +95,8 @@ suite('SQL Telemetry Utilities tests', () => { }; data.provider = providerName + '1'; - TelemetryUtils.addTelemetry(telemetryService.object, telemetryKey, data, connectionProfile).then(() => { + const logService = new TestLogService(); + TelemetryUtils.addTelemetry(telemetryService.object, logService, telemetryKey, data, connectionProfile).then(() => { telemetryService.verify(x => x.publicLog(TypeMoq.It.is(a => a === telemetryKey), TypeMoq.It.is(b => b.provider === data.provider)), TypeMoq.Times.once()); done(); }).catch(err => { diff --git a/src/sqltest/parts/accountManagement/accountDialogController.test.ts b/src/sqltest/parts/accountManagement/accountDialogController.test.ts index ea23d259ea..0af02ceff8 100644 --- a/src/sqltest/parts/accountManagement/accountDialogController.test.ts +++ b/src/sqltest/parts/accountManagement/accountDialogController.test.ts @@ -88,7 +88,7 @@ function createInstantiationService(addAccountFailureEmitter?: Emitter): .returns(() => undefined); // Create a mock account dialog - let accountDialog = new AccountDialog(null, null, instantiationService.object, null, null, null, null, new ContextKeyServiceStub(), null); + let accountDialog = new AccountDialog(null, null, instantiationService.object, null, null, null, null, new ContextKeyServiceStub(), null, undefined); let mockAccountDialog = TypeMoq.Mock.ofInstance(accountDialog); mockAccountDialog.setup(x => x.onAddAccountErrorEvent) .returns(() => { return addAccountFailureEmitter ? addAccountFailureEmitter.event : mockEvent.event; }); diff --git a/src/sqltest/parts/accountManagement/autoOAuthDialogController.test.ts b/src/sqltest/parts/accountManagement/autoOAuthDialogController.test.ts index a3dafe1383..ca2bb0ffd3 100644 --- a/src/sqltest/parts/accountManagement/autoOAuthDialogController.test.ts +++ b/src/sqltest/parts/accountManagement/autoOAuthDialogController.test.ts @@ -38,7 +38,7 @@ suite('auto OAuth dialog controller tests', () => { mockOnCloseEvent = new Emitter(); // Create a mock auto OAuth dialog - let autoOAuthDialog = new AutoOAuthDialog(null, null, null, null, new ContextKeyServiceStub(), null); + let autoOAuthDialog = new AutoOAuthDialog(null, null, null, null, new ContextKeyServiceStub(), null, undefined); mockAutoOAuthDialog = TypeMoq.Mock.ofInstance(autoOAuthDialog); mockAutoOAuthDialog.setup(x => x.onCancel).returns(() => mockOnCancelEvent.event); diff --git a/src/sqltest/parts/accountManagement/firewallRuleDialogController.test.ts b/src/sqltest/parts/accountManagement/firewallRuleDialogController.test.ts index 03f491da8d..e4f3ceac73 100644 --- a/src/sqltest/parts/accountManagement/firewallRuleDialogController.test.ts +++ b/src/sqltest/parts/accountManagement/firewallRuleDialogController.test.ts @@ -60,7 +60,7 @@ suite('Firewall rule dialog controller tests', () => { .returns(() => mockFirewallRuleViewModel.object); // Create a mock account picker - let firewallRuleDialog = new FirewallRuleDialog(null, null, null, instantiationService.object, null, null, new ContextKeyServiceStub(), null, null); + let firewallRuleDialog = new FirewallRuleDialog(null, null, null, instantiationService.object, null, null, new ContextKeyServiceStub(), null, null, undefined); mockFirewallRuleDialog = TypeMoq.Mock.ofInstance(firewallRuleDialog); let mockEvent = new Emitter(); diff --git a/src/sqltest/parts/commandLine/commandLineService.test.ts b/src/sqltest/parts/commandLine/commandLineService.test.ts index 87a7956b6a..d8103a144f 100644 --- a/src/sqltest/parts/commandLine/commandLineService.test.ts +++ b/src/sqltest/parts/commandLine/commandLineService.test.ts @@ -22,9 +22,10 @@ import { WorkspaceConfigurationTestService } from 'sqltest/stubs/workspaceConfig import { IConnectionProfile } from 'sql/platform/connection/common/interfaces'; import { assertThrowsAsync } from 'sqltest/utils/testUtils'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; -import { TestEditorService } from 'vs/workbench/test/workbenchTestServices'; +import { TestEditorService, TestLogService } from 'vs/workbench/test/workbenchTestServices'; import { QueryInput } from 'sql/workbench/parts/query/common/queryInput'; import { URI } from 'vs/base/common/uri'; +import { ILogService } from 'vs/platform/log/common/log'; class TestParsedArgs implements ParsedArgs { [arg: string]: any; @@ -101,7 +102,8 @@ suite('commandLineService tests', () => { configurationService: IConfigurationService, capabilitiesService?: ICapabilitiesService, commandService?: ICommandService, - editorService?: IEditorService + editorService?: IEditorService, + logService?: ILogService ): CommandLineService { let service = new CommandLineService( capabilitiesService, @@ -112,7 +114,8 @@ suite('commandLineService tests', () => { editorService, commandService, configurationService, - undefined + undefined, + logService ); return service; } @@ -196,7 +199,8 @@ suite('commandLineService tests', () => { .verifiable(TypeMoq.Times.once()); connectionManagementService.setup(c => c.getConnectionProfileById(TypeMoq.It.isAnyString())).returns(() => originalProfile); const configurationService = getConfigurationServiceMock(true); - let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService); + const logService = new TestLogService(); + let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService); await service.processCommandLine(args); connectionManagementService.verifyAll(); }); @@ -300,7 +304,8 @@ suite('commandLineService tests', () => { connectionManagementService.setup(c => c.getConnectionProfileById(TypeMoq.It.isAnyString())).returns(() => originalProfile); connectionManagementService.setup(c => c.getConnectionGroups(TypeMoq.It.isAny())).returns(() => []); const configurationService = getConfigurationServiceMock(true); - let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService); + const logService = new TestLogService(); + let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService); await service.processCommandLine(args); connectionManagementService.verifyAll(); }); @@ -342,7 +347,8 @@ suite('commandLineService tests', () => { connectionManagementService.setup(c => c.getConnectionProfileById('testID')).returns(() => originalProfile).verifiable(TypeMoq.Times.once()); connectionManagementService.setup(x => x.getConnectionGroups(TypeMoq.It.isAny())).returns(() => [conProfGroup]); const configurationService = getConfigurationServiceMock(true); - let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService); + const logService = new TestLogService(); + let service = getCommandLineService(connectionManagementService.object, configurationService.object, capabilitiesService, undefined, undefined, logService); await service.processCommandLine(args); connectionManagementService.verifyAll(); }); diff --git a/src/sqltest/parts/connection/connectionManagementService.test.ts b/src/sqltest/parts/connection/connectionManagementService.test.ts index 629c5591b8..a24f103887 100644 --- a/src/sqltest/parts/connection/connectionManagementService.test.ts +++ b/src/sqltest/parts/connection/connectionManagementService.test.ts @@ -159,7 +159,8 @@ suite('SQL ConnectionManagementService tests', () => { undefined, resourceProviderStubMock.object, undefined, - accountManagementService.object + accountManagementService.object, + undefined ); return connectionManagementService; } diff --git a/src/sqltest/parts/connection/objectExplorerService.test.ts b/src/sqltest/parts/connection/objectExplorerService.test.ts index 55545fd0f7..867178b71f 100644 --- a/src/sqltest/parts/connection/objectExplorerService.test.ts +++ b/src/sqltest/parts/connection/objectExplorerService.test.ts @@ -18,6 +18,7 @@ import { ServerTreeView } from 'sql/workbench/parts/objectExplorer/browser/serve import { ConnectionOptionSpecialType, ServiceOptionType } from 'sql/workbench/api/common/sqlExtHostTypes'; import { Event, Emitter } from 'vs/base/common/event'; import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService'; +import { TestLogService } from 'vs/workbench/test/workbenchTestServices'; suite('SQL Object Explorer Service tests', () => { let sqlOEProvider: TypeMoq.Mock; @@ -269,7 +270,8 @@ suite('SQL Object Explorer Service tests', () => { } }; - objectExplorerService = new ObjectExplorerService(connectionManagementService.object, undefined, capabilitiesService); + const logService = new TestLogService(); + objectExplorerService = new ObjectExplorerService(connectionManagementService.object, undefined, capabilitiesService, logService); objectExplorerService.registerProvider('MSSQL', sqlOEProvider.object); sqlOEProvider.setup(x => x.createNewSession(TypeMoq.It.is(x => x.options['serverName'] === connection.serverName))).returns(() => new Promise((resolve) => { resolve(response); diff --git a/src/sqltest/parts/dashboard/widgets/propertiesWidget.component.test.ts b/src/sqltest/parts/dashboard/widgets/propertiesWidget.component.test.ts index 34806e4f7c..26b9c316ec 100644 --- a/src/sqltest/parts/dashboard/widgets/propertiesWidget.component.test.ts +++ b/src/sqltest/parts/dashboard/widgets/propertiesWidget.component.test.ts @@ -15,6 +15,7 @@ import { ConnectionManagementInfo } from 'sql/platform/connection/common/connect import * as TypeMoq from 'typemoq'; import * as assert from 'assert'; +import { TestLogService } from 'vs/workbench/test/workbenchTestServices'; class TestChangeDetectorRef extends ChangeDetectorRef { reattach(): void { @@ -96,11 +97,13 @@ suite('Dashboard Properties Widget Tests', () => { dashboardService.setup(x => x.connectionManagementService).returns(() => singleConnectionService.object); - let consoleError = (message?: any, ...optionalParams: any[]): void => { - assert.fail('Called console Error unexpectedly'); + const testLogService = new class extends TestLogService { + error() { + assert.fail('Called console Error unexpectedly'); + } }; - let testComponent = new PropertiesWidgetComponent(dashboardService.object, new TestChangeDetectorRef(), undefined, widgetConfig, consoleError); + let testComponent = new PropertiesWidgetComponent(dashboardService.object, new TestChangeDetectorRef(), undefined, widgetConfig, testLogService); // because config parsing is done async we need to put our asserts on the thread stack setTimeout(() => { diff --git a/src/sqltest/parts/insights/insightsDialogController.test.ts b/src/sqltest/parts/insights/insightsDialogController.test.ts index b6067dff41..763070a088 100644 --- a/src/sqltest/parts/insights/insightsDialogController.test.ts +++ b/src/sqltest/parts/insights/insightsDialogController.test.ts @@ -50,6 +50,7 @@ suite('Insights Dialog Controller Tests', () => { instMoq.object, connMoq.object, undefined, + undefined, undefined ); diff --git a/src/sqltest/parts/notebook/model/notebookModel.test.ts b/src/sqltest/parts/notebook/model/notebookModel.test.ts index 1d012515bf..52ac771bb1 100644 --- a/src/sqltest/parts/notebook/model/notebookModel.test.ts +++ b/src/sqltest/parts/notebook/model/notebookModel.test.ts @@ -24,7 +24,7 @@ import { Memento } from 'vs/workbench/common/memento'; import { Emitter } from 'vs/base/common/event'; import { CapabilitiesTestService } from 'sqltest/stubs/capabilitiesTestService'; import { ICapabilitiesService } from 'sql/platform/capabilities/common/capabilitiesService'; -import { TestStorageService } from 'vs/workbench/test/workbenchTestServices'; +import { TestStorageService, TestLogService } from 'vs/workbench/test/workbenchTestServices'; let expectedNotebookContent: nb.INotebookContents = { cells: [{ @@ -129,9 +129,9 @@ suite('notebook model', function (): void { let mockContentManager = TypeMoq.Mock.ofType(LocalContentManager); mockContentManager.setup(c => c.getNotebookContents(TypeMoq.It.isAny())).returns(() => Promise.resolve(emptyNotebook)); notebookManagers[0].contentManager = mockContentManager.object; - + const logService = new TestLogService(); // When I initialize the model - let model = new NotebookModel(defaultModelOptions); + let model = new NotebookModel(defaultModelOptions, undefined, logService); await model.requestModelLoad(); // Then I expect to have 0 code cell as the contents @@ -218,7 +218,8 @@ suite('notebook model', function (): void { let options: INotebookModelOptions = Object.assign({}, defaultModelOptions, >{ factory: mockModelFactory.object }); - let model = new NotebookModel(options, undefined); + const logService = new TestLogService(); + let model = new NotebookModel(options, undefined, logService); model.onClientSessionReady((session) => actualSession = session); await model.requestModelLoad(); await model.startSession(notebookManagers[0]); @@ -236,14 +237,16 @@ suite('notebook model', function (): void { }); test('Should sanitize kernel display name when IP is included', async function (): Promise { - let model = new NotebookModel(defaultModelOptions); + const logService = new TestLogService(); + let model = new NotebookModel(defaultModelOptions, undefined, logService); let displayName = 'PySpark (1.1.1.1)'; let sanitizedDisplayName = model.sanitizeDisplayName(displayName); should(sanitizedDisplayName).equal('PySpark'); }); test('Should sanitize kernel display name properly when IP is not included', async function (): Promise { - let model = new NotebookModel(defaultModelOptions); + const logService = new TestLogService(); + let model = new NotebookModel(defaultModelOptions, undefined, logService); let displayName = 'PySpark'; let sanitizedDisplayName = model.sanitizeDisplayName(displayName); should(sanitizedDisplayName).equal('PySpark');