소스 검색

Renames LogLevel to TraceLevel for consistency with others

main
Eric Amodio 5 년 전
부모
커밋
f67bf87c53
3개의 변경된 파일32개의 추가작업 그리고 32개의 파일을 삭제
  1. +27
    -27
      src/logger.ts
  2. +3
    -3
      src/system/decorators/log.ts
  3. +2
    -2
      src/ui/config.ts

+ 27
- 27
src/logger.ts 파일 보기

@ -1,11 +1,11 @@
'use strict';
import { ConfigurationChangeEvent, ExtensionContext, OutputChannel, Uri, window } from 'vscode';
import { configuration, LogLevel } from './configuration';
import { configuration, TraceLevel } from './configuration';
import { extensionOutputChannelName } from './constants';
import { getCorrelationContext } from './system';
// import { Telemetry } from './telemetry';
export { LogLevel } from './configuration';
export { TraceLevel } from './configuration';
const ConsolePrefix = `[${extensionOutputChannelName}]`;
@ -18,7 +18,7 @@ export interface LogCorrelationContext {
}
export class Logger {
static level: LogLevel = LogLevel.Silent;
static level: TraceLevel = TraceLevel.Silent;
static output: OutputChannel | undefined;
static customLoggableFn: ((o: object) => string | undefined) | undefined;
@ -32,9 +32,9 @@ export class Logger {
private static onConfigurationChanged(e: ConfigurationChangeEvent) {
const section = configuration.name('outputLevel').value;
if (configuration.changed(e, section)) {
this.level = configuration.get<LogLevel>(section);
this.level = configuration.get<TraceLevel>(section);
if (this.level === LogLevel.Silent) {
if (this.level === TraceLevel.Silent) {
if (this.output !== undefined) {
this.output.dispose();
this.output = undefined;
@ -49,7 +49,7 @@ export class Logger {
static debug(message: string, ...params: any[]): void;
static debug(context: LogCorrelationContext | undefined, message: string, ...params: any[]): void;
static debug(contextOrMessage: LogCorrelationContext | string | undefined, ...params: any[]): void {
if (this.level !== LogLevel.Debug && !Logger.isDebugging) return;
if (this.level !== TraceLevel.Debug && !Logger.isDebugging) return;
let message;
if (typeof contextOrMessage === 'string') {
@ -67,7 +67,7 @@ export class Logger {
console.log(this.timestamp, ConsolePrefix, message || '', ...params);
}
if (this.output !== undefined && this.level === LogLevel.Debug) {
if (this.output !== undefined && this.level === TraceLevel.Debug) {
this.output.appendLine(`${this.timestamp} ${message || ''}${this.toLoggableParams(true, params)}`);
}
}
@ -75,7 +75,7 @@ export class Logger {
static error(ex: Error, message?: string, ...params: any[]): void;
static error(ex: Error, context?: LogCorrelationContext, message?: string, ...params: any[]): void;
static error(ex: Error, contextOrMessage: LogCorrelationContext | string | undefined, ...params: any[]): void {
if (this.level === LogLevel.Silent && !Logger.isDebugging) return;
if (this.level === TraceLevel.Silent && !Logger.isDebugging) return;
let message;
if (contextOrMessage === undefined || typeof contextOrMessage === 'string') {
@ -103,7 +103,7 @@ export class Logger {
console.error(this.timestamp, ConsolePrefix, message || '', ...params, ex);
}
if (this.output !== undefined && this.level !== LogLevel.Silent) {
if (this.output !== undefined && this.level !== TraceLevel.Silent) {
this.output.appendLine(`${this.timestamp} ${message || ''}${this.toLoggableParams(false, params)}\n${ex}`);
}
@ -117,7 +117,7 @@ export class Logger {
static log(message: string, ...params: any[]): void;
static log(context: LogCorrelationContext | undefined, message: string, ...params: any[]): void;
static log(contextOrMessage: LogCorrelationContext | string | undefined, ...params: any[]): void {
if (this.level !== LogLevel.Verbose && this.level !== LogLevel.Debug && !Logger.isDebugging) {
if (this.level !== TraceLevel.Verbose && this.level !== TraceLevel.Debug && !Logger.isDebugging) {
return;
}
@ -137,7 +137,7 @@ export class Logger {
console.log(this.timestamp, ConsolePrefix, message || '', ...params);
}
if (this.output !== undefined && (this.level === LogLevel.Verbose || this.level === LogLevel.Debug)) {
if (this.output !== undefined && (this.level === TraceLevel.Verbose || this.level === TraceLevel.Debug)) {
this.output.appendLine(`${this.timestamp} ${message || ''}${this.toLoggableParams(false, params)}`);
}
}
@ -145,7 +145,7 @@ export class Logger {
static logWithDebugParams(message: string, ...params: any[]): void;
static logWithDebugParams(context: LogCorrelationContext | undefined, message: string, ...params: any[]): void;
static logWithDebugParams(contextOrMessage: LogCorrelationContext | string | undefined, ...params: any[]): void {
if (this.level !== LogLevel.Verbose && this.level !== LogLevel.Debug && !Logger.isDebugging) {
if (this.level !== TraceLevel.Verbose && this.level !== TraceLevel.Debug && !Logger.isDebugging) {
return;
}
@ -165,7 +165,7 @@ export class Logger {
console.log(this.timestamp, ConsolePrefix, message || '', ...params);
}
if (this.output !== undefined && (this.level === LogLevel.Verbose || this.level === LogLevel.Debug)) {
if (this.output !== undefined && (this.level === TraceLevel.Verbose || this.level === TraceLevel.Debug)) {
this.output.appendLine(`${this.timestamp} ${message || ''}${this.toLoggableParams(true, params)}`);
}
}
@ -173,7 +173,7 @@ export class Logger {
static warn(message: string, ...params: any[]): void;
static warn(context: LogCorrelationContext | undefined, message: string, ...params: any[]): void;
static warn(contextOrMessage: LogCorrelationContext | string | undefined, ...params: any[]): void {
if (this.level === LogLevel.Silent && !Logger.isDebugging) return;
if (this.level === TraceLevel.Silent && !Logger.isDebugging) return;
let message;
if (typeof contextOrMessage === 'string') {
@ -191,7 +191,7 @@ export class Logger {
console.warn(this.timestamp, ConsolePrefix, message || '', ...params);
}
if (this.output !== undefined && this.level !== LogLevel.Silent) {
if (this.output !== undefined && this.level !== TraceLevel.Silent) {
this.output.appendLine(`${this.timestamp} ${message || ''}${this.toLoggableParams(false, params)}`);
}
}
@ -244,19 +244,8 @@ export class Logger {
.replace(/\..+/, '')}:${('00' + now.getUTCMilliseconds()).slice(-3)}]`;
}
static gitOutput: OutputChannel | undefined;
static logGitCommand(command: string, ex?: Error): void {
if (this.level !== LogLevel.Debug) return;
if (this.gitOutput === undefined) {
this.gitOutput = window.createOutputChannel(`${extensionOutputChannelName} (Git)`);
}
this.gitOutput.appendLine(`${this.timestamp} ${command}${ex != null ? `\n\n${ex.toString()}` : ''}`);
}
private static toLoggableParams(debugOnly: boolean, params: any[]) {
if (params.length === 0 || (debugOnly && this.level !== LogLevel.Debug && !Logger.isDebugging)) {
if (params.length === 0 || (debugOnly && this.level !== TraceLevel.Debug && !Logger.isDebugging)) {
return '';
}
@ -274,4 +263,15 @@ export class Logger {
return this._isDebugging;
}
static gitOutput: OutputChannel | undefined;
static logGitCommand(command: string, ex?: Error): void {
if (this.level !== TraceLevel.Debug) return;
if (this.gitOutput === undefined) {
this.gitOutput = window.createOutputChannel(`${extensionOutputChannelName} (Git)`);
}
this.gitOutput.appendLine(`${this.timestamp} ${command}${ex != null ? `\n\n${ex.toString()}` : ''}`);
}
}

+ 3
- 3
src/system/decorators/log.ts 파일 보기

@ -1,5 +1,5 @@
'use strict';
import { LogCorrelationContext, Logger, LogLevel } from '../../logger';
import { LogCorrelationContext, Logger, TraceLevel } from '../../logger';
import { Functions } from './../function';
import { Strings } from './../string';
@ -98,8 +98,8 @@ export function log(
if (
(!Logger.isDebugging &&
Logger.level !== LogLevel.Debug &&
!(Logger.level === LogLevel.Verbose && !options.debug)) ||
Logger.level !== TraceLevel.Debug &&
!(Logger.level === TraceLevel.Verbose && !options.debug)) ||
(typeof options.condition === 'function' && !options.condition(...args))
) {
return fn!.apply(this, args);

+ 2
- 2
src/ui/config.ts 파일 보기

@ -67,7 +67,7 @@ export interface Config {
};
};
modes: { [key: string]: ModeConfig };
outputLevel: LogLevel;
outputLevel: TraceLevel;
recentChanges: {
highlight: {
locations: HighlightLocations[];
@ -157,7 +157,7 @@ export enum KeyMap {
None = 'none'
}
export enum LogLevel {
export enum TraceLevel {
Silent = 'silent',
Errors = 'errors',
Verbose = 'verbose',

불러오는 중...
취소
저장