mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 18:46:40 -05:00
Use vscode log path (#6599)
* use vscode log file * remove log * remove sqltools output log and add command to open log
This commit is contained in:
@@ -115,6 +115,11 @@
|
|||||||
{
|
{
|
||||||
"command": "mssql.clearSearchServerResult",
|
"command": "mssql.clearSearchServerResult",
|
||||||
"title": "%title.clearSearchServerResult%"
|
"title": "%title.clearSearchServerResult%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"command": "mssql.showLogFile",
|
||||||
|
"category": "MSSQL",
|
||||||
|
"title": "%title.showLogFile%"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"outputChannels": [
|
"outputChannels": [
|
||||||
@@ -943,4 +948,4 @@
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,8 @@
|
|||||||
"title.endpoints": "Service Endpoints",
|
"title.endpoints": "Service Endpoints",
|
||||||
"title.books": "Notebooks",
|
"title.books": "Notebooks",
|
||||||
|
|
||||||
|
"title.showLogFile": "Show Log File",
|
||||||
|
|
||||||
"mssql.configuration.title": "MSSQL configuration",
|
"mssql.configuration.title": "MSSQL configuration",
|
||||||
"mssql.query.displayBitAsNumber": "Should BIT columns be displayed as numbers (1 or 0)? If false, BIT columns will be displayed as 'true' or 'false'",
|
"mssql.query.displayBitAsNumber": "Should BIT columns be displayed as numbers (1 or 0)? If false, BIT columns will be displayed as 'true' or 'false'",
|
||||||
"mssql.format.alignColumnDefinitionsInColumns": "Should column definitions be aligned?",
|
"mssql.format.alignColumnDefinitionsInColumns": "Should column definitions be aligned?",
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export class CredentialStore {
|
|||||||
private _client: SqlOpsDataClient;
|
private _client: SqlOpsDataClient;
|
||||||
private _config: IConfig;
|
private _config: IConfig;
|
||||||
|
|
||||||
constructor(baseConfig: IConfig) {
|
constructor(private logPath: string, baseConfig: IConfig) {
|
||||||
if (baseConfig) {
|
if (baseConfig) {
|
||||||
this._config = JSON.parse(JSON.stringify(baseConfig));
|
this._config = JSON.parse(JSON.stringify(baseConfig));
|
||||||
this._config.executableFiles = ['MicrosoftSqlToolsCredentials.exe', 'MicrosoftSqlToolsCredentials'];
|
this._config.executableFiles = ['MicrosoftSqlToolsCredentials.exe', 'MicrosoftSqlToolsCredentials'];
|
||||||
@@ -97,7 +97,7 @@ export class CredentialStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private generateServerOptions(executablePath: string): ServerOptions {
|
private generateServerOptions(executablePath: string): ServerOptions {
|
||||||
let launchArgs = Utils.getCommonLaunchArgsAndCleanupOldLogFiles('credentialstore', executablePath);
|
let launchArgs = Utils.getCommonLaunchArgsAndCleanupOldLogFiles(this.logPath, 'credentialstore.log', executablePath);
|
||||||
return { command: executablePath, args: launchArgs, transport: TransportKind.stdio };
|
return { command: executablePath, args: launchArgs, transport: TransportKind.stdio };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,13 +53,17 @@ export async function activate(context: vscode.ExtensionContext): Promise<MssqlE
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(await Utils.pfs.exists(context.logPath))) {
|
||||||
|
await Utils.pfs.mkdir(context.logPath);
|
||||||
|
}
|
||||||
|
|
||||||
let config: IConfig = JSON.parse(JSON.stringify(baseConfig));
|
let config: IConfig = JSON.parse(JSON.stringify(baseConfig));
|
||||||
config.installDirectory = path.join(__dirname, config.installDirectory);
|
config.installDirectory = path.join(__dirname, config.installDirectory);
|
||||||
config.proxy = vscode.workspace.getConfiguration('http').get('proxy');
|
config.proxy = vscode.workspace.getConfiguration('http').get('proxy');
|
||||||
config.strictSSL = vscode.workspace.getConfiguration('http').get('proxyStrictSSL') || true;
|
config.strictSSL = vscode.workspace.getConfiguration('http').get('proxyStrictSSL') || true;
|
||||||
|
|
||||||
const credentialsStore = new CredentialStore(config);
|
const credentialsStore = new CredentialStore(context.logPath, config);
|
||||||
const resourceProvider = new AzureResourceProvider(config);
|
const resourceProvider = new AzureResourceProvider(context.logPath, config);
|
||||||
let languageClient: SqlOpsDataClient;
|
let languageClient: SqlOpsDataClient;
|
||||||
let cmsService: CmsService;
|
let cmsService: CmsService;
|
||||||
|
|
||||||
@@ -75,7 +79,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<MssqlE
|
|||||||
const installationStart = Date.now();
|
const installationStart = Date.now();
|
||||||
let serverPromise = serverdownloader.getOrDownloadServer().then(e => {
|
let serverPromise = serverdownloader.getOrDownloadServer().then(e => {
|
||||||
const installationComplete = Date.now();
|
const installationComplete = Date.now();
|
||||||
let serverOptions = generateServerOptions(e);
|
let serverOptions = generateServerOptions(context.logPath, e);
|
||||||
languageClient = new SqlOpsDataClient(Constants.serviceName, serverOptions, clientOptions);
|
languageClient = new SqlOpsDataClient(Constants.serviceName, serverOptions, clientOptions);
|
||||||
const processStart = Date.now();
|
const processStart = Date.now();
|
||||||
languageClient.onReady().then(() => {
|
languageClient.onReady().then(() => {
|
||||||
@@ -118,6 +122,8 @@ export async function activate(context: vscode.ExtensionContext): Promise<MssqlE
|
|||||||
registerHdfsCommands(context, prompter, appContext);
|
registerHdfsCommands(context, prompter, appContext);
|
||||||
context.subscriptions.push({ dispose: () => languageClient.stop() });
|
context.subscriptions.push({ dispose: () => languageClient.stop() });
|
||||||
|
|
||||||
|
registerLogCommand(context);
|
||||||
|
|
||||||
registerServiceEndpoints(context);
|
registerServiceEndpoints(context);
|
||||||
// Get book contributions - in the future this will be integrated with the Books/Notebook widget to show as a dashboard widget
|
// Get book contributions - in the future this will be integrated with the Books/Notebook widget to show as a dashboard widget
|
||||||
const bookContributionProvider = getBookExtensionContributions(context);
|
const bookContributionProvider = getBookExtensionContributions(context);
|
||||||
@@ -141,6 +147,19 @@ export async function activate(context: vscode.ExtensionContext): Promise<MssqlE
|
|||||||
return api;
|
return api;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const logFiles = ['resourceprovider.log', 'sqltools.log', 'credentialstore.log'];
|
||||||
|
function registerLogCommand(context: vscode.ExtensionContext) {
|
||||||
|
context.subscriptions.push(vscode.commands.registerCommand('mssql.showLogFile', async () => {
|
||||||
|
const choice = await vscode.window.showQuickPick(logFiles);
|
||||||
|
if (choice) {
|
||||||
|
const document = await vscode.workspace.openTextDocument(vscode.Uri.file(path.join(context.logPath, choice)));
|
||||||
|
if (document) {
|
||||||
|
vscode.window.showTextDocument(document);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
function getClientOptions(): ClientOptions {
|
function getClientOptions(): ClientOptions {
|
||||||
return {
|
return {
|
||||||
documentSelector: ['sql'],
|
documentSelector: ['sql'],
|
||||||
@@ -287,8 +306,8 @@ async function handleOpenClusterStatusNotebookTask(profile: azdata.IConnectionPr
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function generateServerOptions(executablePath: string): ServerOptions {
|
function generateServerOptions(logPath: string, executablePath: string): ServerOptions {
|
||||||
let launchArgs = Utils.getCommonLaunchArgsAndCleanupOldLogFiles('sqltools', executablePath);
|
let launchArgs = Utils.getCommonLaunchArgsAndCleanupOldLogFiles(logPath, 'sqltools.log', executablePath);
|
||||||
return { command: executablePath, args: launchArgs, transport: TransportKind.stdio };
|
return { command: executablePath, args: launchArgs, transport: TransportKind.stdio };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ export class AzureResourceProvider {
|
|||||||
private _client: SqlOpsDataClient;
|
private _client: SqlOpsDataClient;
|
||||||
private _config: IConfig;
|
private _config: IConfig;
|
||||||
|
|
||||||
constructor(baseConfig: IConfig) {
|
constructor(private logPath: string, baseConfig: IConfig) {
|
||||||
if (baseConfig) {
|
if (baseConfig) {
|
||||||
this._config = JSON.parse(JSON.stringify(baseConfig));
|
this._config = JSON.parse(JSON.stringify(baseConfig));
|
||||||
this._config.executableFiles = ['SqlToolsResourceProviderService.exe', 'SqlToolsResourceProviderService'];
|
this._config.executableFiles = ['SqlToolsResourceProviderService.exe', 'SqlToolsResourceProviderService'];
|
||||||
@@ -102,7 +102,7 @@ export class AzureResourceProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private generateServerOptions(executablePath: string): ServerOptions {
|
private generateServerOptions(executablePath: string): ServerOptions {
|
||||||
let launchArgs = Utils.getCommonLaunchArgsAndCleanupOldLogFiles('resourceprovider', executablePath);
|
let launchArgs = Utils.getCommonLaunchArgsAndCleanupOldLogFiles(this.logPath, 'resourceprovider.log', executablePath);
|
||||||
return { command: executablePath, args: launchArgs, transport: TransportKind.stdio };
|
return { command: executablePath, args: launchArgs, transport: TransportKind.stdio };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import * as os from 'os';
|
|||||||
import * as findRemoveSync from 'find-remove';
|
import * as findRemoveSync from 'find-remove';
|
||||||
import * as constants from './constants';
|
import * as constants from './constants';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
import { promisify } from 'util';
|
||||||
|
|
||||||
const configTracingLevel = 'tracingLevel';
|
const configTracingLevel = 'tracingLevel';
|
||||||
const configLogRetentionMinutes = 'logRetentionMinutes';
|
const configLogRetentionMinutes = 'logRetentionMinutes';
|
||||||
@@ -30,6 +31,17 @@ export function getAppDataPath() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export namespace pfs {
|
||||||
|
|
||||||
|
export function exists(path: string): Promise<boolean> {
|
||||||
|
return promisify(fs.exists)(path);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function mkdir(path: string, mode?: number): Promise<void> {
|
||||||
|
return promisify(fs.mkdir)(path, mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a file name that is not already used in the target directory
|
* Get a file name that is not already used in the target directory
|
||||||
* @param filePath source notebook file name
|
* @param filePath source notebook file name
|
||||||
@@ -57,8 +69,8 @@ export function copyFile(source: string, target: string): void {
|
|||||||
fs.copyFileSync(source, target);
|
fs.copyFileSync(source, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function removeOldLogFiles(prefix: string): JSON {
|
export function removeOldLogFiles(logPath: string, prefix: string): JSON {
|
||||||
return findRemoveSync(getDefaultLogDir(), { prefix: `${prefix}_`, age: { seconds: getConfigLogRetentionSeconds() }, limit: getConfigLogFilesRemovalLimit() });
|
return findRemoveSync(logPath, { age: { seconds: getConfigLogRetentionSeconds() }, limit: getConfigLogFilesRemovalLimit() });
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getConfiguration(config: string = extensionConfigSectionName): vscode.WorkspaceConfiguration {
|
export function getConfiguration(config: string = extensionConfigSectionName): vscode.WorkspaceConfiguration {
|
||||||
@@ -95,24 +107,20 @@ export function getConfigTracingLevel(): string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDefaultLogDir(): string {
|
export function getLogFileName(prefix: string, pid: number): string {
|
||||||
return path.join(process.env['ADS_LOGS'], '..', '..', 'mssql');
|
return `${prefix}_${pid}.log`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getDefaultLogFile(prefix: string, pid: number): string {
|
export function getCommonLaunchArgsAndCleanupOldLogFiles(logPath: string, fileName: string, executablePath: string): string[] {
|
||||||
return path.join(getDefaultLogDir(), `${prefix}_${pid}.log`);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getCommonLaunchArgsAndCleanupOldLogFiles(prefix: string, executablePath: string): string[] {
|
|
||||||
let launchArgs = [];
|
let launchArgs = [];
|
||||||
launchArgs.push('--log-file');
|
launchArgs.push('--log-file');
|
||||||
let logFile = getDefaultLogFile(prefix, process.pid);
|
let logFile = path.join(logPath, fileName);
|
||||||
launchArgs.push(logFile);
|
launchArgs.push(logFile);
|
||||||
|
|
||||||
console.log(`logFile for ${path.basename(executablePath)} is ${logFile}`);
|
console.log(`logFile for ${path.basename(executablePath)} is ${logFile}`);
|
||||||
console.log(`This process (ui Extenstion Host) is pid: ${process.pid}`);
|
console.log(`This process (ui Extenstion Host) is pid: ${process.pid}`);
|
||||||
// Delete old log files
|
// Delete old log files
|
||||||
let deletedLogFiles = removeOldLogFiles(prefix);
|
let deletedLogFiles = removeOldLogFiles(logPath, fileName);
|
||||||
console.log(`Old log files deletion report: ${JSON.stringify(deletedLogFiles)}`);
|
console.log(`Old log files deletion report: ${JSON.stringify(deletedLogFiles)}`);
|
||||||
launchArgs.push('--tracing-level');
|
launchArgs.push('--tracing-level');
|
||||||
launchArgs.push(getConfigTracingLevel());
|
launchArgs.push(getConfigTracingLevel());
|
||||||
|
|||||||
@@ -8,5 +8,3 @@ export const sharedLogChannelId = 'sharedLog';
|
|||||||
export const rendererLogChannelId = 'rendererLog';
|
export const rendererLogChannelId = 'rendererLog';
|
||||||
export const extHostLogChannelId = 'extHostLog';
|
export const extHostLogChannelId = 'extHostLog';
|
||||||
export const telemetryLogChannelId = 'telemetryLog';
|
export const telemetryLogChannelId = 'telemetryLog';
|
||||||
// {{SQL CARBON EDIT}}
|
|
||||||
export const sqlToolsLogChannellId = 'sqlToolsLog';
|
|
||||||
|
|||||||
@@ -32,12 +32,6 @@ class LogOutputChannels extends Disposable implements IWorkbenchContribution {
|
|||||||
this.registerLogChannel(Constants.sharedLogChannelId, nls.localize('sharedLog', "Shared"), URI.file(join(environmentService.logsPath, `sharedprocess.log`)));
|
this.registerLogChannel(Constants.sharedLogChannelId, nls.localize('sharedLog', "Shared"), URI.file(join(environmentService.logsPath, `sharedprocess.log`)));
|
||||||
this.registerLogChannel(Constants.rendererLogChannelId, nls.localize('rendererLog', "Window"), URI.file(join(environmentService.logsPath, `renderer${environmentService.configuration.windowId}.log`)));
|
this.registerLogChannel(Constants.rendererLogChannelId, nls.localize('rendererLog', "Window"), URI.file(join(environmentService.logsPath, `renderer${environmentService.configuration.windowId}.log`)));
|
||||||
|
|
||||||
// {{SQL CARBON EDIT}} @anthonydresser 05/19/19 investigate, this should be in the extension
|
|
||||||
let toolsServiceLogFile: string = join(environmentService.logsPath, '..', '..', 'mssql', `sqltools_${Date.now()}.log`);
|
|
||||||
console.log(`SqlTools Log file is: ${toolsServiceLogFile}`);
|
|
||||||
this.registerLogChannel(Constants.sqlToolsLogChannellId, nls.localize('sqlToolsLog', "Log (SqlTools)"), URI.file(toolsServiceLogFile));
|
|
||||||
// {{SQL CARBON EDIT}} - End
|
|
||||||
|
|
||||||
const registerTelemetryChannel = (level: LogLevel) => {
|
const registerTelemetryChannel = (level: LogLevel) => {
|
||||||
if (level === LogLevel.Trace && !Registry.as<IOutputChannelRegistry>(OutputExt.OutputChannels).getChannel(Constants.telemetryLogChannelId)) {
|
if (level === LogLevel.Trace && !Registry.as<IOutputChannelRegistry>(OutputExt.OutputChannels).getChannel(Constants.telemetryLogChannelId)) {
|
||||||
this.registerLogChannel(Constants.telemetryLogChannelId, nls.localize('telemetryLog', "Telemetry"), URI.file(join(environmentService.logsPath, `telemetry.log`)));
|
this.registerLogChannel(Constants.telemetryLogChannelId, nls.localize('telemetryLog', "Telemetry"), URI.file(join(environmentService.logsPath, `telemetry.log`)));
|
||||||
@@ -71,4 +65,4 @@ class LogOutputChannels extends Disposable implements IWorkbenchContribution {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(LogOutputChannels, LifecyclePhase.Restored);
|
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench).registerWorkbenchContribution(LogOutputChannels, LifecyclePhase.Restored);
|
||||||
|
|||||||
Reference in New Issue
Block a user