/// <summary>
        /// Initializes a new instance of the <see cref="TraceSourceLoggerProvider"/> class.
        /// </summary>
        /// <param name="rootSourceSwitch">The <see cref="SourceSwitch"/> to use.</param>
        /// <param name="rootTraceListener">The <see cref="TraceListener"/> to use.</param>
        public TraceSourceLoggerProvider(SourceSwitch rootSourceSwitch, TraceListener?rootTraceListener)
        {
            ThrowHelper.ThrowIfNull(rootSourceSwitch);

            _rootSourceSwitch  = rootSourceSwitch;
            _rootTraceListener = rootTraceListener;
        }
Exemple #2
0
        /// <devdoc>
        ///    <para>Removes the first listener in the list that has the
        ///       specified name.</para>
        /// </devdoc>
        public void Remove(string name)
        {
            TraceListener?listener = this[name];

            if (listener != null)
            {
                ((IList)this).Remove(listener);
            }
        }
Exemple #3
0
        /// <internalonly/>
        void IList.Insert(int index, object?value)
        {
            TraceListener?listener = value as TraceListener;

            if (listener == null)
            {
                throw new ArgumentException(SR.MustAddListener, nameof(value));
            }

            InitializeListener(listener);

            lock (TraceInternal.critSec)
            {
                _list.Insert(index, (TraceListener?)value);
            }
        }
Exemple #4
0
        /// <internalonly/>
        int IList.Add(object?value)
        {
            TraceListener?listener = value as TraceListener;

            if (listener == null)
            {
                throw new ArgumentException(SR.MustAddListener, nameof(value));
            }

            InitializeListener(listener);

            lock (TraceInternal.critSec)
            {
                return(((IList)_list).Add(value));
            }
        }
Exemple #5
0
        public static void InitializeLogging(TraceSource system, TraceListener?systemListener = null)
        {
            system.Switch.Level      = SourceLevels.All;
            Log.Default.Switch.Level = SourceLevels.All;

            var sources = new[]
            {
                system,
                Log.Default
            };

            foreach (var source in sources)
            {
                source.Listeners.Clear();
                source.Listeners.Add(systemListener ?? new AppTraceListener(showTime: false));
            }
        }
Exemple #6
0
        /// <internalonly/>
        object?IList.this[int index]
        {
            get
            {
                return(_list[index]);
            }

            set
            {
                TraceListener?listener = value as TraceListener;
                if (listener == null)
                {
                    throw new ArgumentException(SR.MustAddListener, nameof(value));
                }
                InitializeListener(listener);
                _list[index] = listener;
            }
        }
Exemple #7
0
        public static IServiceCollection AddOrleansAnalytics <TConfig>(this IServiceCollection services, TraceListener consoleTraceListener)
            where TConfig : class, IApplicationInsightsConfig
        {
            if (_traceListener == null)
            {
                _traceListener = consoleTraceListener;
                services.RegisterConsoleLoggerService(_traceListener);
            }

            services.AddScoped <IApplicationInsightsConfig, TConfig>();
            services.AddScoped <ITelemetryClientProxy, TelemetryClientProxy>();
            services.AddScoped <ITelemetryDecorator, TelemetryDecorator>();

            services.AddScoped <IAnalyticsSessionFactory, OrleansSessionFactory>();

            services.AddScoped <IAnalyticsService, OrleansAnalyticsService>();
            services.AddScoped <IOrleansRequestContext, OrleansRequestContext>();


            return(services);
        }
        public static async Task <RemoteHostClient> CreateAsync(
            HostWorkspaceServices services,
            RemoteServiceCallbackDispatcherRegistry callbackDispatchers,
            TraceListener?traceListener,
            RemoteHostTestData testData
            )
        {
            var inprocServices = new InProcRemoteServices(services, traceListener, testData);

            var remoteHostStream = await inprocServices
                                   .RequestServiceAsync(WellKnownServiceHubService.RemoteHost)
                                   .ConfigureAwait(false);

            var instance = new InProcRemoteHostClient(
                services,
                inprocServices,
                callbackDispatchers,
                remoteHostStream
                );

            // make sure connection is done right
            var uiCultureLCIDE = 0;
            var cultureLCID    = 0;

            await instance._endPoint
            .InvokeAsync(
                nameof(IRemoteHostService.InitializeGlobalState),
                new object?[] { uiCultureLCIDE, cultureLCID },
                CancellationToken.None
                )
            .ConfigureAwait(false);

            instance.Started();

            // return instance
            return(instance);
        }
Exemple #9
0
 /// <devdoc>
 ///    <para>
 ///       Removes the specified instance of the <see cref='System.Diagnostics.TraceListener'/> class from the list.
 ///    </para>
 /// </devdoc>
 public void Remove(TraceListener?listener)
 {
     ((IList)this).Remove(listener);
 }
Exemple #10
0
 /// <devdoc>
 ///    <para>Gets the index of the specified listener.</para>
 /// </devdoc>
 public int IndexOf(TraceListener?listener)
 {
     return(((IList)this).IndexOf(listener));
 }
Exemple #11
0
 /// <devdoc>
 ///    <para>Checks whether the list contains the specified
 ///       listener.</para>
 /// </devdoc>
 public bool Contains(TraceListener?listener)
 {
     return(((IList)this).Contains(listener));
 }
        public static RemoteHostClient Create(HostWorkspaceServices services, RemoteServiceCallbackDispatcherRegistry callbackDispatchers, TraceListener?traceListener, RemoteHostTestData testData)
        {
            var inprocServices = new InProcRemoteServices(services, traceListener, testData);
            var instance       = new InProcRemoteHostClient(services, inprocServices, callbackDispatchers);

            instance.Started();

            // return instance
            return(instance);
        }
Exemple #13
0
 /// <summary>
 /// Register the single event listener.
 /// </summary>
 /// <param name="listener">The listener.</param>
 public static void RegisterListener(TraceListener?listener)
 {
     Log.listener = listener;
 }