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

scope the logs per date folder

上级 d3fb016d
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
declare module 'spdlog' { declare module 'spdlog' {
export const version: string; export const version: string;
export function setAsyncMode(bufferSize: number, flushInterval: number);
export class RotatingLogger { export class RotatingLogger {
constructor(name: string, filename: string, filesize: number, filecount: number); constructor(name: string, filename: string, filesize: number, filecount: number);
......
...@@ -68,7 +68,8 @@ function createPaths(environmentService: IEnvironmentService): TPromise<any> { ...@@ -68,7 +68,8 @@ function createPaths(environmentService: IEnvironmentService): TPromise<any> {
const paths = [ const paths = [
environmentService.appSettingsHome, environmentService.appSettingsHome,
environmentService.extensionsPath, environmentService.extensionsPath,
environmentService.nodeCachedDataDir environmentService.nodeCachedDataDir,
environmentService.logsPath
]; ];
return TPromise.join(paths.map(p => p && mkdirp(p))) as TPromise<any>; return TPromise.join(paths.map(p => p && mkdirp(p))) as TPromise<any>;
} }
......
...@@ -72,6 +72,7 @@ export interface IEnvironmentService { ...@@ -72,6 +72,7 @@ export interface IEnvironmentService {
userHome: string; userHome: string;
userDataPath: string; userDataPath: string;
logsPath: string;
appNameLong: string; appNameLong: string;
appQuality: string; appQuality: string;
......
...@@ -51,6 +51,8 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -51,6 +51,8 @@ export class EnvironmentService implements IEnvironmentService {
get execPath(): string { return this._execPath; } get execPath(): string { return this._execPath; }
readonly logsPath: string;
@memoize @memoize
get userHome(): string { return os.homedir(); } get userHome(): string { return os.homedir(); }
...@@ -134,6 +136,13 @@ export class EnvironmentService implements IEnvironmentService { ...@@ -134,6 +136,13 @@ export class EnvironmentService implements IEnvironmentService {
readonly machineUUID: string; readonly machineUUID: string;
constructor(private _args: ParsedArgs, private _execPath: 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'); const machineIdPath = path.join(this.userDataPath, 'machineid');
try { try {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
import * as path from 'path'; import * as path from 'path';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { RotatingLogger } from 'spdlog'; import { RotatingLogger, setAsyncMode } from 'spdlog';
export class SpdLogService implements ILogService { export class SpdLogService implements ILogService {
...@@ -20,7 +20,9 @@ export class SpdLogService implements ILogService { ...@@ -20,7 +20,9 @@ export class SpdLogService implements ILogService {
processName: string, processName: string,
@IEnvironmentService environmentService: IEnvironmentService @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); this.logger = new RotatingLogger(processName, logfilePath, 1024 * 1024 * 5, 6);
} }
......
...@@ -39,9 +39,9 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc'; ...@@ -39,9 +39,9 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc';
import { IURLService } from 'vs/platform/url/common/url'; import { IURLService } from 'vs/platform/url/common/url';
import { WorkspacesChannelClient } from 'vs/platform/workspaces/common/workspacesIpc'; import { WorkspacesChannelClient } from 'vs/platform/workspaces/common/workspacesIpc';
import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces';
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
import fs = require('fs'); import fs = require('fs');
import { SpdLogService } from 'vs/platform/log/node/spdlogService';
gracefulFs.gracefulify(fs); // enable gracefulFs gracefulFs.gracefulify(fs); // enable gracefulFs
const currentWindowId = remote.getCurrentWindow().id; const currentWindowId = remote.getCurrentWindow().id;
......
...@@ -5038,9 +5038,9 @@ sparkles@^1.0.0: ...@@ -5038,9 +5038,9 @@ sparkles@^1.0.0:
version "1.0.0" version "1.0.0"
resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3"
spdlog@^0.1.2: spdlog@0.2.0:
version "0.1.2" version "0.2.0"
resolved "https://registry.yarnpkg.com/spdlog/-/spdlog-0.1.2.tgz#c9a00a84711f1ba698a0137d09eb6c8bf22683e9" resolved "https://registry.yarnpkg.com/spdlog/-/spdlog-0.2.0.tgz#45ca84aa37a8c84cdbd1f52206890e1db0639636"
dependencies: dependencies:
bindings "^1.3.0" bindings "^1.3.0"
mkdirp "^0.5.1" mkdirp "^0.5.1"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册