Remove logging and clone utlities (#5309)

* remove log utility functions; remove custom mixin

* fix tests

* add log service as required by telemetry utils

* remove unused code

* replace some console.logs with logservice
This commit is contained in:
Anthony Dresser
2019-05-04 22:37:15 -07:00
committed by GitHub
parent df7645e4e5
commit ab0cd71d10
80 changed files with 439 additions and 383 deletions

View File

@@ -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<void> { 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 }
);

View File

@@ -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<void> { 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,

View File

@@ -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,

View File

@@ -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);
}
));

View File

@@ -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<string, Subject<IAngularEvent>>();
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 });
}

View File

@@ -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<azdata.BackupResponse>((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 => {

View File

@@ -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<string> {
TelemetryUtils.addTelemetry(this._telemetryService, TelemetryKeys.AddServerGroup);
TelemetryUtils.addTelemetry(this._telemetryService, this.logService, TelemetryKeys.AddServerGroup);
return new Promise<string>((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<void> {
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<void> {
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<boolean> {
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<boolean> {
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);

View File

@@ -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;

View File

@@ -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 {

View File

@@ -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<WizardPage, DialogPane>();
@@ -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;
}

View File

@@ -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<T>(uri: string, action: (handler: IQueryRequestHandler) => Thenable<T>): Thenable<T> {

View File

@@ -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<azdata.RestoreResponse>((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 => {

View File

@@ -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<IScriptingService>(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;
}

View File

@@ -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<void> {
connection?: IConnectionProfile
): Promise<void> {
return new Promise<void>(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();
}
});