Log: Enhancements and cleaup (#171325)

- Make logger service primary source for log level
- Automatically register output channels for loggers from anywhere
- Use logger channels on remote processes (server, pty)
- clean up loggers and log service
This commit is contained in:
Sandeep Somavarapu
2023-01-14 19:46:46 +01:00
committed by GitHub
parent a2bdb408ba
commit 05d59b893e
38 changed files with 380 additions and 396 deletions
+6 -5
View File
@@ -39,7 +39,7 @@ import { InstantiationService } from 'vs/platform/instantiation/common/instantia
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { ILanguagePackService } from 'vs/platform/languagePacks/common/languagePacks';
import { NativeLanguagePackService } from 'vs/platform/languagePacks/node/languagePacks';
import { ConsoleLogger, getLogLevel, ILogger, ILogService, LogLevel, MultiplexLogService } from 'vs/platform/log/common/log';
import { ConsoleLogger, getLogLevel, ILogger, ILogService, LogLevel } from 'vs/platform/log/common/log';
import { SpdLogLogger } from 'vs/platform/log/node/spdlogLog';
import { FilePolicyService } from 'vs/platform/policy/common/filePolicyService';
import { IPolicyService, NullPolicyService } from 'vs/platform/policy/common/policy';
@@ -62,6 +62,7 @@ import { IUserDataProfilesService, PROFILES_ENABLEMENT_CONFIG } from 'vs/platfor
import { UserDataProfilesService } from 'vs/platform/userDataProfile/node/userDataProfile';
import { resolveMachineId } from 'vs/platform/telemetry/node/telemetryUtils';
import { ExtensionsProfileScannerService } from 'vs/platform/extensionManagement/node/extensionsProfileScannerService';
import { LogService } from 'vs/platform/log/common/logService';
class CliMain extends Disposable {
@@ -126,13 +127,13 @@ class CliMain extends Disposable {
// Log
const logLevel = getLogLevel(environmentService);
const loggers: ILogger[] = [];
loggers.push(new SpdLogLogger('cli', join(environmentService.logsPath, 'cli.log'), true, false, logLevel));
const spdLogLogger = new SpdLogLogger('cli', join(environmentService.logsPath, 'cli.log'), true, false, logLevel);
const otherLoggers: ILogger[] = [];
if (logLevel === LogLevel.Trace) {
loggers.push(new ConsoleLogger(logLevel));
otherLoggers.push(new ConsoleLogger(logLevel));
}
const logService = this._register(new MultiplexLogService(loggers));
const logService = this._register(new LogService(spdLogLogger, otherLoggers));
services.set(ILogService, logService);
// Files