public static void RemoveFromContext(RecordingTracingInterceptor interceptor) { try { TracingAdapter.RemoveTracingInterceptor(interceptor); } catch { // Ignore } }
public static void AddToContext(RecordingTracingInterceptor interceptor) { RemoveFromContext(interceptor); TracingAdapter.AddTracingInterceptor(interceptor); }
/// <summary> /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile /// </summary> protected override void BeginProcessing() { PromptForDataCollectionProfileIfNotExists(); InitializeQosEvent(); if (string.IsNullOrEmpty(ParameterSetName)) { WriteDebugWithTimestamp(string.Format("{0} begin processing without ParameterSet.", this.GetType().Name)); } else { WriteDebugWithTimestamp(string.Format("{0} begin processing with ParameterSet '{1}'.", this.GetType().Name, ParameterSetName)); } if (DefaultContext != null && DefaultContext.Account != null && DefaultContext.Account.Id != null) { WriteDebugWithTimestamp(string.Format("using account id '{0}'...", DefaultContext.Account.Id)); } _httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages); _adalListener = _adalListener ?? new DebugStreamTraceListener(_debugMessages); RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor); DebugStreamTraceListener.AddAdalTracing(_adalListener); ProductInfoHeaderValue userAgentValue = new ProductInfoHeaderValue( ModuleName, string.Format("v{0}", ModuleVersion)); AzureSession.ClientFactory.UserAgents.Add(userAgentValue); AzureSession.ClientFactory.AddHandler(new CmdletInfoHandler(this.CommandRuntime.ToString(), this.ParameterSetName)); base.BeginProcessing(); }
/// <summary> /// Cmdlet begin process. Write to logs, setup Http Tracing and initialize profile /// </summary> protected override void BeginProcessing() { InitializeProfile(); PromptForDataCollectionProfileIfNotExists(); InitializeQosEvent(); if (string.IsNullOrEmpty(ParameterSetName)) { WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithoutParameterSetLog, this.GetType().Name)); } else { WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithParameterSetLog, this.GetType().Name, ParameterSetName)); } if (Profile != null && Profile.Context != null && Profile.Context.Account != null && Profile.Context.Account.Id != null) { WriteDebugWithTimestamp(string.Format("using account id '{0}'...", Profile.Context.Account.Id)); } _httpTracingInterceptor = _httpTracingInterceptor?? new RecordingTracingInterceptor(_debugMessages); _adalListener = _adalListener?? new DebugStreamTraceListener(_debugMessages); RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor); DebugStreamTraceListener.AddAdalTracing(_adalListener); base.BeginProcessing(); }