Improvements to logger and netwok requests logging (#175492)

- Able to create logger by passing id
- Support when conditions for loggers
- Separate logger for all network requests
- Log request and response headers
- Enable request logger on trace
- Add loggerService in CLI
This commit is contained in:
Sandeep Somavarapu
2023-02-27 10:05:20 +01:00
committed by GitHub
parent 86ed8560d7
commit 52dd56689f
46 changed files with 399 additions and 320 deletions
+11 -7
View File
@@ -39,8 +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 } from 'vs/platform/log/common/log';
import { SpdLogLogger } from 'vs/platform/log/node/spdlogLog';
import { ConsoleLogger, getLogLevel, ILogger, ILoggerService, ILogService, LogLevel } from 'vs/platform/log/common/log';
import { FilePolicyService } from 'vs/platform/policy/common/filePolicyService';
import { IPolicyService, NullPolicyService } from 'vs/platform/policy/common/policy';
import { NativePolicyService } from 'vs/platform/policy/node/nativePolicyService';
@@ -62,6 +61,8 @@ import { UserDataProfilesReadonlyService } from 'vs/platform/userDataProfile/nod
import { resolveMachineId } from 'vs/platform/telemetry/node/telemetryUtils';
import { ExtensionsProfileScannerService } from 'vs/platform/extensionManagement/node/extensionsProfileScannerService';
import { LogService } from 'vs/platform/log/common/logService';
import { LoggerService } from 'vs/platform/log/node/loggerService';
import { localize } from 'vs/nls';
class CliMain extends Disposable {
@@ -124,15 +125,18 @@ class CliMain extends Disposable {
environmentService.extensionsPath
].map(path => path ? Promises.mkdir(path, { recursive: true }) : undefined));
// Logger
const loggerService = new LoggerService(getLogLevel(environmentService), environmentService.logsHome);
services.set(ILoggerService, loggerService);
// Log
const logLevel = getLogLevel(environmentService);
const spdLogLogger = new SpdLogLogger('cli', join(environmentService.logsPath, 'cli.log'), true, false, logLevel);
const logger = this._register(loggerService.createLogger('cli', { name: localize('cli', "CLI") }));
const otherLoggers: ILogger[] = [];
if (logLevel === LogLevel.Trace) {
otherLoggers.push(new ConsoleLogger(logLevel));
if (loggerService.getLogLevel() === LogLevel.Trace) {
otherLoggers.push(new ConsoleLogger(loggerService.getLogLevel()));
}
const logService = this._register(new LogService(spdLogLogger, otherLoggers));
const logService = this._register(new LogService(logger, otherLoggers));
services.set(ILogService, logService);
// Files