diff --git a/package.json b/package.json index fab0a11ecdca984a0b206fee17a1b01324b72e3f..cfdc3a2e73083580d287500eeb4ce74ce1e0591e 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "node-pty": "0.7.3", "nsfw": "1.0.16", "semver": "4.3.6", - "spdlog": "^0.1.2", + "spdlog": "0.2.0", "v8-inspect-profiler": "^0.0.6", "vscode-chokidar": "1.6.2", "vscode-debugprotocol": "1.25.0-pre.0", diff --git a/src/typings/spdlog.d.ts b/src/typings/spdlog.d.ts index 7ade4afb3aed4abca4b71891d04eba5116dbb910..a367b25fff6a52d6bc08898b8045ab0540a05059 100644 --- a/src/typings/spdlog.d.ts +++ b/src/typings/spdlog.d.ts @@ -6,6 +6,7 @@ declare module 'spdlog' { export const version: string; + export function setAsyncMode(bufferSize: number, flushInterval: number); export class RotatingLogger { constructor(name: string, filename: string, filesize: number, filecount: number); diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index 71661f10c58e9bc4e629272d558ee8a299567b65..15a1cd146c200f9ef7c43006d97a07ecdd091f81 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -68,7 +68,8 @@ function createPaths(environmentService: IEnvironmentService): TPromise { const paths = [ environmentService.appSettingsHome, environmentService.extensionsPath, - environmentService.nodeCachedDataDir + environmentService.nodeCachedDataDir, + environmentService.logsPath ]; return TPromise.join(paths.map(p => p && mkdirp(p))) as TPromise; } diff --git a/src/vs/platform/environment/common/environment.ts b/src/vs/platform/environment/common/environment.ts index ef5353ab958c9f265f1ae412cd3e385ff33b2da8..3945f10d1affedde5f6c695e2cc8868bd3ca8e13 100644 --- a/src/vs/platform/environment/common/environment.ts +++ b/src/vs/platform/environment/common/environment.ts @@ -72,6 +72,7 @@ export interface IEnvironmentService { userHome: string; userDataPath: string; + logsPath: string; appNameLong: string; appQuality: string; diff --git a/src/vs/platform/environment/node/environmentService.ts b/src/vs/platform/environment/node/environmentService.ts index d79ebc00ec58f14a829157c5bcf55e36a2b9593a..7403ecb4404560332c9b40d8079c21c36e1da05c 100644 --- a/src/vs/platform/environment/node/environmentService.ts +++ b/src/vs/platform/environment/node/environmentService.ts @@ -51,6 +51,8 @@ export class EnvironmentService implements IEnvironmentService { get execPath(): string { return this._execPath; } + readonly logsPath: string; + @memoize get userHome(): string { return os.homedir(); } @@ -134,6 +136,13 @@ export class EnvironmentService implements IEnvironmentService { readonly machineUUID: string; constructor(private _args: ParsedArgs, private _execPath: string) { + if (!process.env['VSCODE_LOGS']) { + const key = new Date().toISOString().replace(/-|:|\.\d+Z$/g, ''); + process.env['VSCODE_LOGS'] = path.join(this.userDataPath, 'logs', key); + } + + this.logsPath = process.env['VSCODE_LOGS']; + const machineIdPath = path.join(this.userDataPath, 'machineid'); try { diff --git a/src/vs/platform/log/node/spdlogService.ts b/src/vs/platform/log/node/spdlogService.ts index 04388cecaaecc0e44bc1afcb851fc03a2eccab40..a58e5a1ad096bf0ff0f58e1e13f266f7ddf9b244 100644 --- a/src/vs/platform/log/node/spdlogService.ts +++ b/src/vs/platform/log/node/spdlogService.ts @@ -8,7 +8,7 @@ import * as path from 'path'; import { ILogService } from 'vs/platform/log/common/log'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; -import { RotatingLogger } from 'spdlog'; +import { RotatingLogger, setAsyncMode } from 'spdlog'; export class SpdLogService implements ILogService { @@ -20,7 +20,9 @@ export class SpdLogService implements ILogService { processName: string, @IEnvironmentService environmentService: IEnvironmentService ) { - const logfilePath = path.join(environmentService.userDataPath, 'logs', processName); + setAsyncMode(8192, 2000); + + const logfilePath = path.join(environmentService.logsPath, processName); this.logger = new RotatingLogger(processName, logfilePath, 1024 * 1024 * 5, 6); } diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 047788587f2c302542095da2197b0e9690dea4c6..61c5293e1fcded3e7646e3ae48421ff4c8721d98 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -39,9 +39,9 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc'; import { IURLService } from 'vs/platform/url/common/url'; import { WorkspacesChannelClient } from 'vs/platform/workspaces/common/workspacesIpc'; import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; +import { SpdLogService } from 'vs/platform/log/node/spdlogService'; import fs = require('fs'); -import { SpdLogService } from 'vs/platform/log/node/spdlogService'; gracefulFs.gracefulify(fs); // enable gracefulFs const currentWindowId = remote.getCurrentWindow().id; diff --git a/yarn.lock b/yarn.lock index 0ae2467df309c2966e0f5de53dc94e561d1793a3..0872b2df80d2c4e3859761e01a63235733965724 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5038,9 +5038,9 @@ sparkles@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" -spdlog@^0.1.2: - version "0.1.2" - resolved "https://registry.yarnpkg.com/spdlog/-/spdlog-0.1.2.tgz#c9a00a84711f1ba698a0137d09eb6c8bf22683e9" +spdlog@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/spdlog/-/spdlog-0.2.0.tgz#45ca84aa37a8c84cdbd1f52206890e1db0639636" dependencies: bindings "^1.3.0" mkdirp "^0.5.1"