Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public configure(extensibilityPoints: IExtensibilityPoints, configuration: ILoggingConfiguration): void {
const logToFile = configuration.logLevel !== LogLevel.Stop;
// The debug configuration provider should have set logFilePath on the launch config. If not, default to 'true' to use the
// "legacy" log file path from the CDA subclass
const logFilePath = _.defaultTo(configuration.logFilePath, _.defaultTo(extensibilityPoints.logFilePath, logToFile));
logger.setup(LogLevel.Warn /* This controls the console logging not the file logging */,
logFilePath, configuration.shouldLogTimestamps);
if (configuration.logLevel !== LogLevel.Verbose) {
/* We want the logger.verbose message to not appear when we configure the logger to only log info level. The logger doesn't support this
* so we monkey-patch it.
*
* Note that any logger.verbose call done before we call logger.setup will get logged anyways
*/
this.patchLoggerToFilterOutVerboseMessages(configuration.logLevel);
}
}
protected attachRequest(response: DebugProtocol.AttachResponse, args: AttachRequestArgumentsV1) {
if (args.logToFile === true) {
logger.setup(LogLevel.Verbose, true);
}
this.sendEvent(new TelemetryEvent(DEBUGGER, { trigger: 'attach' }));
this.attachArgs = args;
this.debugClient = CreateAttachDebugClient(args, this);
this.entryResponse = response;
// tslint:disable-next-line:no-this-assignment
const that = this;
this.canStartDebugger().then(() => {
return this.startDebugServer();
}).then(dbgServer => {
return that.debugClient!.LaunchApplicationToDebug(dbgServer);
}).catch(error => {
this.sendEvent(new OutputEvent(`${error}${'\n'}`, "stderr"));
this.sendErrorResponse(that.entryResponse!, 2000, error);
protected launchRequest(response: DebugProtocol.LaunchResponse, args: LaunchRequestArguments): void {
if (args.logToFile === true) {
logger.setup(LogLevel.Verbose, true);
}
// Some versions may still exist with incorrect launch.json values
const setting = '${config.python.pythonPath}';
if (args.pythonPath === setting) {
return this.sendErrorResponse(response, 2001, `Invalid launch.json (re-create it or replace 'config.python.pythonPath' with 'config:python.pythonPath')`);
}
// Add support for specifying just the directory where the python executable will be located
// E.g. virtual directory name
try {
args.pythonPath = getPythonExecutable(args.pythonPath);
}
catch (ex) {
}
// Confirm the file exists
if (typeof args.module !== 'string' || args.module.length === 0) {
if (!args.program || !fs.existsSync(args.program)) {
public setupLogger(args: LaunchRequestArguments): void {
if (typeof args.trace === 'boolean') {
this.trace = args.trace ? [TRACE_ALL] : [];
this.traceAll = args.trace;
} else if (typeof args.trace === 'string') {
this.trace = args.trace.split(',').map(category => category.trim());
this.traceAll = this.trace.indexOf(TRACE_ALL) >= 0;
}
if (this.trace && this.trace.indexOf(TRACE_CATEGORY_PROTOCOL) >= 0) {
logger.setup(Logger.LogLevel.Verbose, false);
} else {
logger.setup(Logger.LogLevel.Stop, false);
}
}
private set loggingEnabled(value: boolean) {
if (value) {
logger.setup(LogLevel.Verbose, true);
this.protocolLogger.setup(logger);
}
}
constructor(private readonly serviceContainer: IServiceContainer) {