提交 4c79dc1f 编写于 作者: J Joao Moreno

scope the logs per date folder

上级 d3fb016d
......@@ -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);
......
......@@ -68,7 +68,8 @@ function createPaths(environmentService: IEnvironmentService): TPromise<any> {
const paths = [
environmentService.appSettingsHome,
environmentService.extensionsPath,
environmentService.nodeCachedDataDir
environmentService.nodeCachedDataDir,
environmentService.logsPath
];
return TPromise.join(paths.map(p => p && mkdirp(p))) as TPromise<any>;
}
......
......@@ -72,6 +72,7 @@ export interface IEnvironmentService {
userHome: string;
userDataPath: string;
logsPath: string;
appNameLong: string;
appQuality: string;
......
......@@ -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 {
......
......@@ -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);
}
......
......@@ -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;
......
......@@ -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"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册