Bladeren bron

Fixes #412 - Respects output level for tracing when debugging

main
Eric Amodio 6 jaren geleden
bovenliggende
commit
b5f3b0a751
2 gewijzigde bestanden met toevoegingen van 19 en 7 verwijderingen
  1. +4
    -0
      CHANGELOG.md
  2. +15
    -7
      src/logger.ts

+ 4
- 0
CHANGELOG.md Bestand weergeven

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased]
### Fixed
- Fixes [#400](https://github.com/eamodio/vscode-gitlens/issues/412) - GitLens logging to debug console when debugging different extension
## [8.3.5] - 2018-06-08
### Fixed
- Fixes more instances of [#295](https://github.com/eamodio/vscode-gitlens/issues/295)and [#318](https://github.com/eamodio/vscode-gitlens/issues/318) - Any error encountered during the search for repositories could cause GitLens to die

+ 15
- 7
src/logger.ts Bestand weergeven

@ -38,21 +38,25 @@ export class Logger {
}
static log(message?: any, ...params: any[]): void {
if (this.level !== OutputLevel.Verbose && this.level !== OutputLevel.Debug) return;
if (Logger.isDebugging) {
console.log(this.timestamp, ConsolePrefix, message, ...params);
}
if (this.output !== undefined && (this.level === OutputLevel.Verbose || this.level === OutputLevel.Debug)) {
if (this.output !== undefined) {
this.output.appendLine((Logger.isDebugging ? [this.timestamp, message, ...params] : [message, ...params]).join(' '));
}
}
static error(ex: Error, classOrMethod?: string, ...params: any[]): void {
if (this.level === OutputLevel.Silent) return;
if (Logger.isDebugging) {
console.error(this.timestamp, ConsolePrefix, classOrMethod, ...params, ex);
}
if (this.output !== undefined && this.level !== OutputLevel.Silent) {
if (this.output !== undefined) {
this.output.appendLine((Logger.isDebugging ? [this.timestamp, classOrMethod, ...params, ex] : [classOrMethod, ...params, ex]).join(' '));
}
@ -60,11 +64,13 @@ export class Logger {
}
static warn(message?: any, ...params: any[]): void {
if (this.level === OutputLevel.Silent) return;
if (Logger.isDebugging) {
console.warn(this.timestamp, ConsolePrefix, message, ...params);
}
if (this.output !== undefined && this.level !== OutputLevel.Silent) {
if (this.output !== undefined) {
this.output.appendLine((Logger.isDebugging ? [this.timestamp, message, ...params] : [message, ...params]).join(' '));
}
}
@ -88,11 +94,13 @@ export class Logger {
private static _isDebugging: boolean | undefined;
static get isDebugging() {
if (this._isDebugging === undefined) {
const args = process.execArgv;
try {
const args = process.execArgv;
this._isDebugging = args
? args.some(arg => isDebuggingRegex.test(arg))
: false;
this._isDebugging = args
? args.some(arg => isDebuggingRegex.test(arg))
: false;
} catch { }
}
return this._isDebugging;

Laden…
Annuleren
Opslaan