public static void SetLoggers(IGlobalOptionService optionService, IThreadingContext threadingContext, IRemoteHostClientService remoteService) { var loggerTypes = GetLoggerTypes(optionService).ToList(); // first set VS options var options = Logger.GetLoggingChecker(optionService); SetRoslynLogger(loggerTypes, () => new EtwLogger(options)); SetRoslynLogger(loggerTypes, () => new TraceLogger(options)); SetRoslynLogger(loggerTypes, () => new OutputWindowLogger(options)); // second set RemoteHost options var client = threadingContext.JoinableTaskFactory.Run(() => remoteService.TryGetRemoteHostClientAsync(CancellationToken.None)); if (client == null) { // Remote host is disabled return; } var functionIds = GetFunctionIds(options).ToList(); _ = threadingContext.JoinableTaskFactory.Run(() => client.TryRunRemoteAsync( WellKnownRemoteHostServices.RemoteHostService, nameof(IRemoteHostService.SetLoggingFunctionIds), new object[] { loggerTypes, functionIds }, CancellationToken.None)); }
protected override void OnApply(PageApplyEventArgs e) { base.OnApply(e); var loggerTypes = GetLoggerTypes().ToList(); // first set VS options var options = Logger.GetLoggingChecker(_optionService); SetRoslynLogger(loggerTypes, () => new EtwLogger(options)); SetRoslynLogger(loggerTypes, () => new TraceLogger(options)); // second set RemoteHost options var client = _remoteHostClientService.TryGetRemoteHostClientAsync(CancellationToken.None).Result; if (client == null) { // Remote host is disabled return; } var functionIds = GetFunctionIds(options).ToList(); var unused = client.TryRunRemoteAsync( WellKnownRemoteHostServices.RemoteHostService, nameof(IRemoteHostService.SetLoggingFunctionIds), new object[] { loggerTypes, functionIds }, CancellationToken.None).Result; }