Skip to content

Commit

Permalink
add spdlog
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Nov 29, 2017
1 parent 4e78a42 commit 0228f71
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"node-pty": "0.7.3",
"nsfw": "1.0.16",
"semver": "4.3.6",
"spdlog": "^0.1.1",
"v8-inspect-profiler": "^0.0.6",
"vscode-chokidar": "1.6.2",
"vscode-debugprotocol": "1.25.0-pre.0",
Expand Down
21 changes: 21 additions & 0 deletions src/typings/spdlog.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'spdlog' {

export const version: string;

export class RotatingLogger {
constructor(name: string, filename: string, filesize: number, filecount: number);

trace(message: string);
debug(message: string);
info(message: string);
warn(message: string);
error(message: string);
critical(message: string);
flush(): void;
}
}
22 changes: 14 additions & 8 deletions src/vs/platform/log/node/spdlogService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,47 @@

'use strict';

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

export class SpdLogService implements ILogService {

_serviceBrand: any;

private logger: RotatingLogger;

constructor(
processName: string,
@IEnvironmentService environmentService: IEnvironmentService
) {
// TODO create logger
// const logfilePath = path.join(environmentService.userDataPath, 'logs', processName);
this.logger = new RotatingLogger(processName, 'LOG', 1024 * 1024 * 5, 6);
}

trace(message: string, ...args: any[]): void {
// console.log('TRACE', message, ...args);
this.logger.trace(message);
}

debug(message: string, ...args: any[]): void {
// console.log('DEBUG', message, ...args);
this.logger.debug(message);
}

info(message: string, ...args: any[]): void {
// console.log('INFO', message, ...args);
this.logger.info(message);
}

warn(message: string, ...args: any[]): void {
// console.warn('WARN', message, ...args);
this.logger.warn(message);
}

error(message: string | Error, ...args: any[]): void {
// console.error('ERROR', message, ...args);
error(arg: string | Error, ...args: any[]): void {
const message = arg instanceof Error ? arg.stack : arg;
this.logger.error(message);
}

critical(message: string, ...args: any[]): void {
// console.error('CRITICAL', message, ...args);
this.logger.critical(message);
}
}
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ binaryextensions@~1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/binaryextensions/-/binaryextensions-1.0.1.tgz#1e637488b35b58bda5f4774bf96a5212a8c90755"

bindings@^1.2.1:
bindings@^1.2.1, bindings@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.3.0.tgz#b346f6ecf6a95f5a815c5839fc7cdb22502f1ed7"

Expand Down Expand Up @@ -3738,6 +3738,10 @@ nan@^2.1.0:
version "2.7.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46"

nan@^2.8.0:
version "2.8.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a"

native-keymap@1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/native-keymap/-/native-keymap-1.2.5.tgz#1035a9417b9a9340cf8097763a43c76d588165a5"
Expand Down Expand Up @@ -5034,6 +5038,13 @@ sparkles@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3"

spdlog@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/spdlog/-/spdlog-0.1.1.tgz#6ec5b59166c03e162aa7b329a9d2c43a281dcc38"
dependencies:
bindings "^1.3.0"
nan "^2.8.0"

spdx-correct@~1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40"
Expand Down

0 comments on commit 0228f71

Please sign in to comment.