protected override ILogger CreateLogger(TelemetrySession telemetrySession)
 => AggregateLogger.Create(
     CodeMarkerLogger.Instance,
     new EtwLogger(FunctionIdOptions.CreateFunctionIsEnabledPredicate(_globalOptions)),
     TelemetryLogger.Create(telemetrySession, _globalOptions),
     new FileLogger(_globalOptions),
     Logger.GetLogger());
Exemple #2
0
        public static void SetLoggers(IGlobalOptionService globalOptions, IThreadingContext threadingContext, HostWorkspaceServices workspaceServices)
        {
            var loggerTypeNames = GetLoggerTypes(globalOptions).ToImmutableArray();

            // update loggers in VS
            var isEnabled = FunctionIdOptions.CreateFunctionIsEnabledPredicate(globalOptions);

            SetRoslynLogger(loggerTypeNames, () => new EtwLogger(isEnabled));
            SetRoslynLogger(loggerTypeNames, () => new TraceLogger(isEnabled));
            SetRoslynLogger(loggerTypeNames, () => new OutputWindowLogger(isEnabled));

            // update loggers in remote process
            var client = threadingContext.JoinableTaskFactory.Run(() => RemoteHostClient.TryGetClientAsync(workspaceServices, CancellationToken.None));

            if (client != null)
            {
                var functionIds = Enum.GetValues(typeof(FunctionId)).Cast <FunctionId>().Where(isEnabled).ToImmutableArray();

                threadingContext.JoinableTaskFactory.Run(async() => _ = await client.TryInvokeAsync <IRemoteProcessTelemetryService>(
                                                             (service, cancellationToken) => service.EnableLoggingAsync(loggerTypeNames, functionIds, cancellationToken),
                                                             CancellationToken.None).ConfigureAwait(false));
            }
        }