mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-03-19 11:31:40 -04:00
Merge VS Code 1.21 source code (#1067)
* Initial VS Code 1.21 file copy with patches * A few more merges * Post npm install * Fix batch of build breaks * Fix more build breaks * Fix more build errors * Fix more build breaks * Runtime fixes 1 * Get connection dialog working with some todos * Fix a few packaging issues * Copy several node_modules to package build to fix loader issues * Fix breaks from master * A few more fixes * Make tests pass * First pass of license header updates * Second pass of license header updates * Fix restore dialog issues * Remove add additional themes menu items * fix select box issues where the list doesn't show up * formatting * Fix editor dispose issue * Copy over node modules to correct location on all platforms
This commit is contained in:
@@ -5,10 +5,11 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { createDecorator as createServiceDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import Event, { Emitter } from 'vs/base/common/event';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
|
||||
export const ILogService = createServiceDecorator<ILogService>('logService');
|
||||
|
||||
@@ -22,11 +23,14 @@ export enum LogLevel {
|
||||
Off
|
||||
}
|
||||
|
||||
export const DEFAULT_LOG_LEVEL: LogLevel = LogLevel.Info;
|
||||
|
||||
export interface ILogService extends IDisposable {
|
||||
_serviceBrand: any;
|
||||
onDidChangeLogLevel: Event<LogLevel>;
|
||||
|
||||
setLevel(level: LogLevel): void;
|
||||
getLevel(): LogLevel;
|
||||
setLevel(level: LogLevel): void;
|
||||
trace(message: string, ...args: any[]): void;
|
||||
debug(message: string, ...args: any[]): void;
|
||||
info(message: string, ...args: any[]): void;
|
||||
@@ -35,27 +39,37 @@ export interface ILogService extends IDisposable {
|
||||
critical(message: string | Error, ...args: any[]): void;
|
||||
}
|
||||
|
||||
export class ConsoleLogMainService implements ILogService {
|
||||
export abstract class AbstractLogService extends Disposable {
|
||||
|
||||
_serviceBrand: any;
|
||||
private level: LogLevel = LogLevel.Error;
|
||||
private useColors: boolean;
|
||||
|
||||
constructor( @IEnvironmentService environmentService: IEnvironmentService) {
|
||||
this.setLevel(environmentService.logLevel);
|
||||
this.useColors = !isWindows;
|
||||
}
|
||||
private level: LogLevel = DEFAULT_LOG_LEVEL;
|
||||
private readonly _onDidChangeLogLevel: Emitter<LogLevel> = this._register(new Emitter<LogLevel>());
|
||||
readonly onDidChangeLogLevel: Event<LogLevel> = this._onDidChangeLogLevel.event;
|
||||
|
||||
setLevel(level: LogLevel): void {
|
||||
this.level = level;
|
||||
if (this.level !== level) {
|
||||
this.level = level;
|
||||
this._onDidChangeLogLevel.fire(this.level);
|
||||
}
|
||||
}
|
||||
|
||||
getLevel(): LogLevel {
|
||||
return this.level;
|
||||
}
|
||||
}
|
||||
|
||||
export class ConsoleLogMainService extends AbstractLogService implements ILogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
private useColors: boolean;
|
||||
|
||||
constructor(logLevel: LogLevel = DEFAULT_LOG_LEVEL) {
|
||||
super();
|
||||
this.setLevel(logLevel);
|
||||
this.useColors = !isWindows;
|
||||
}
|
||||
|
||||
trace(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Trace) {
|
||||
if (this.getLevel() <= LogLevel.Trace) {
|
||||
if (this.useColors) {
|
||||
console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, message, ...args);
|
||||
} else {
|
||||
@@ -65,7 +79,7 @@ export class ConsoleLogMainService implements ILogService {
|
||||
}
|
||||
|
||||
debug(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Debug) {
|
||||
if (this.getLevel() <= LogLevel.Debug) {
|
||||
if (this.useColors) {
|
||||
console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, message, ...args);
|
||||
} else {
|
||||
@@ -75,7 +89,7 @@ export class ConsoleLogMainService implements ILogService {
|
||||
}
|
||||
|
||||
info(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Info) {
|
||||
if (this.getLevel() <= LogLevel.Info) {
|
||||
if (this.useColors) {
|
||||
console.log(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, message, ...args);
|
||||
} else {
|
||||
@@ -85,7 +99,7 @@ export class ConsoleLogMainService implements ILogService {
|
||||
}
|
||||
|
||||
warn(message: string | Error, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Warning) {
|
||||
if (this.getLevel() <= LogLevel.Warning) {
|
||||
if (this.useColors) {
|
||||
console.warn(`\x1b[93m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, message, ...args);
|
||||
} else {
|
||||
@@ -95,7 +109,7 @@ export class ConsoleLogMainService implements ILogService {
|
||||
}
|
||||
|
||||
error(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Error) {
|
||||
if (this.getLevel() <= LogLevel.Error) {
|
||||
if (this.useColors) {
|
||||
console.error(`\x1b[91m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, message, ...args);
|
||||
} else {
|
||||
@@ -105,7 +119,7 @@ export class ConsoleLogMainService implements ILogService {
|
||||
}
|
||||
|
||||
critical(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Critical) {
|
||||
if (this.getLevel() <= LogLevel.Critical) {
|
||||
if (this.useColors) {
|
||||
console.error(`\x1b[90m[main ${new Date().toLocaleTimeString()}]\x1b[0m`, message, ...args);
|
||||
} else {
|
||||
@@ -119,55 +133,47 @@ export class ConsoleLogMainService implements ILogService {
|
||||
}
|
||||
}
|
||||
|
||||
export class ConsoleLogService implements ILogService {
|
||||
export class ConsoleLogService extends AbstractLogService implements ILogService {
|
||||
|
||||
_serviceBrand: any;
|
||||
private level: LogLevel = LogLevel.Error;
|
||||
|
||||
constructor( @IEnvironmentService environmentService: IEnvironmentService) {
|
||||
this.setLevel(environmentService.logLevel);
|
||||
}
|
||||
|
||||
setLevel(level: LogLevel): void {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
getLevel(): LogLevel {
|
||||
return this.level;
|
||||
constructor(logLevel: LogLevel = DEFAULT_LOG_LEVEL) {
|
||||
super();
|
||||
this.setLevel(logLevel);
|
||||
}
|
||||
|
||||
trace(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Trace) {
|
||||
if (this.getLevel() <= LogLevel.Trace) {
|
||||
console.log('%cTRACE', 'color: #888', message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
debug(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Debug) {
|
||||
if (this.getLevel() <= LogLevel.Debug) {
|
||||
console.log('%cDEBUG', 'background: #eee; color: #888', message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
info(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Info) {
|
||||
if (this.getLevel() <= LogLevel.Info) {
|
||||
console.log('%c INFO', 'color: #33f', message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
warn(message: string | Error, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Warning) {
|
||||
if (this.getLevel() <= LogLevel.Warning) {
|
||||
console.log('%c WARN', 'color: #993', message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
error(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Error) {
|
||||
if (this.getLevel() <= LogLevel.Error) {
|
||||
console.log('%c ERR', 'color: #f33', message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
critical(message: string, ...args: any[]): void {
|
||||
if (this.level <= LogLevel.Critical) {
|
||||
if (this.getLevel() <= LogLevel.Critical) {
|
||||
console.log('%cCRITI', 'background: #f33; color: white', message, ...args);
|
||||
}
|
||||
}
|
||||
@@ -175,22 +181,21 @@ export class ConsoleLogService implements ILogService {
|
||||
dispose(): void { }
|
||||
}
|
||||
|
||||
export class MultiplexLogService implements ILogService {
|
||||
export class MultiplexLogService extends AbstractLogService implements ILogService {
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(private logServices: ILogService[]) { }
|
||||
constructor(private logServices: ILogService[]) {
|
||||
super();
|
||||
if (logServices.length) {
|
||||
this.setLevel(logServices[0].getLevel());
|
||||
}
|
||||
}
|
||||
|
||||
setLevel(level: LogLevel): void {
|
||||
for (const logService of this.logServices) {
|
||||
logService.setLevel(level);
|
||||
}
|
||||
}
|
||||
|
||||
getLevel(): LogLevel {
|
||||
for (const logService of this.logServices) {
|
||||
return logService.getLevel();
|
||||
}
|
||||
return LogLevel.Info;
|
||||
super.setLevel(level);
|
||||
}
|
||||
|
||||
trace(message: string, ...args: any[]): void {
|
||||
@@ -236,8 +241,54 @@ export class MultiplexLogService implements ILogService {
|
||||
}
|
||||
}
|
||||
|
||||
export class NoopLogService implements ILogService {
|
||||
export class DelegatedLogService extends Disposable implements ILogService {
|
||||
_serviceBrand: any;
|
||||
|
||||
constructor(private logService: ILogService) {
|
||||
super();
|
||||
this._register(logService);
|
||||
}
|
||||
|
||||
get onDidChangeLogLevel(): Event<LogLevel> {
|
||||
return this.logService.onDidChangeLogLevel;
|
||||
}
|
||||
|
||||
setLevel(level: LogLevel): void {
|
||||
this.logService.setLevel(level);
|
||||
}
|
||||
|
||||
getLevel(): LogLevel {
|
||||
return this.logService.getLevel();
|
||||
}
|
||||
|
||||
trace(message: string, ...args: any[]): void {
|
||||
this.logService.trace(message, ...args);
|
||||
}
|
||||
|
||||
debug(message: string, ...args: any[]): void {
|
||||
this.logService.debug(message, ...args);
|
||||
}
|
||||
|
||||
info(message: string, ...args: any[]): void {
|
||||
this.logService.info(message, ...args);
|
||||
}
|
||||
|
||||
warn(message: string, ...args: any[]): void {
|
||||
this.logService.warn(message, ...args);
|
||||
}
|
||||
|
||||
error(message: string | Error, ...args: any[]): void {
|
||||
this.logService.error(message, ...args);
|
||||
}
|
||||
|
||||
critical(message: string | Error, ...args: any[]): void {
|
||||
this.logService.critical(message, ...args);
|
||||
}
|
||||
}
|
||||
|
||||
export class NullLogService implements ILogService {
|
||||
_serviceBrand: any;
|
||||
readonly onDidChangeLogLevel: Event<LogLevel> = new Emitter<LogLevel>().event;
|
||||
setLevel(level: LogLevel): void { }
|
||||
getLevel(): LogLevel { return LogLevel.Info; }
|
||||
trace(message: string, ...args: any[]): void { }
|
||||
@@ -248,3 +299,30 @@ export class NoopLogService implements ILogService {
|
||||
critical(message: string | Error, ...args: any[]): void { }
|
||||
dispose(): void { }
|
||||
}
|
||||
|
||||
|
||||
export function getLogLevel(environmentService: IEnvironmentService): LogLevel {
|
||||
if (environmentService.verbose) {
|
||||
return LogLevel.Trace;
|
||||
}
|
||||
if (typeof environmentService.args.log === 'string') {
|
||||
const logLevel = environmentService.args.log.toLowerCase();
|
||||
switch (logLevel) {
|
||||
case 'trace':
|
||||
return LogLevel.Trace;
|
||||
case 'debug':
|
||||
return LogLevel.Debug;
|
||||
case 'info':
|
||||
return LogLevel.Info;
|
||||
case 'warn':
|
||||
return LogLevel.Warning;
|
||||
case 'error':
|
||||
return LogLevel.Error;
|
||||
case 'critical':
|
||||
return LogLevel.Critical;
|
||||
case 'off':
|
||||
return LogLevel.Off;
|
||||
}
|
||||
}
|
||||
return DEFAULT_LOG_LEVEL;
|
||||
}
|
||||
Reference in New Issue
Block a user