Exemplo n.º 1
0
        /// <summary>
        /// Stops event logging started with <see cref="Start()"/>.
        /// </summary>
        public static void Stop()
        {
            foreach (var kvp in sources)
            {
                FieldLogTraceListener listener;
                if (listeners.TryGetValue(kvp.Key, out listener))
                {
                    listener.Flush();
                    listener.Close();
                    kvp.Key.Listeners.Remove(listener);
                    listeners.Remove(kvp.Key);
                }
            }

            if (diagTraceListener != null)
            {
                diagTraceListener.Flush();
                diagTraceListener.Close();
                Trace.Listeners.Remove(diagTraceListener);
                diagTraceListener = null;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts event logging of all events from all WPF sources and System.Diagnostics.Trace.
        /// </summary>
        /// <param name="level">The minimum source level to log.</param>
        public static void Start(SourceLevels level)
        {
            // Enable WPF tracing, independently of registry setting
            PresentationTraceSources.Refresh();

            foreach (var kvp in sources)
            {
                FieldLogTraceListener listener;
                if (!listeners.TryGetValue(kvp.Key, out listener))
                {
                    listener = new FieldLogTraceListener(kvp.Value, "WPF");
                    listeners.Add(kvp.Key, listener);
                    kvp.Key.Listeners.Add(listener);
                }
                kvp.Key.Switch.Level = level;
            }

            if (diagTraceListener == null)
            {
                diagTraceListener = new FieldLogTraceListener("Diagnostics.Trace", "Trace");
                Trace.Listeners.Add(diagTraceListener);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Stops event logging started with <see cref="Start()"/>.
        /// </summary>
        public static void Stop()
        {
            foreach (var kvp in sources)
            {
                FieldLogTraceListener listener;
                if (listeners.TryGetValue(kvp.Key, out listener))
                {
                    listener.Flush();
                    listener.Close();
                    kvp.Key.Listeners.Remove(listener);
                    listeners.Remove(kvp.Key);
                }
            }

            if (diagTraceListener != null)
            {
                diagTraceListener.Flush();
                diagTraceListener.Close();
                Trace.Listeners.Remove(diagTraceListener);
                diagTraceListener = null;
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Starts event logging of all events from all WPF sources and System.Diagnostics.Trace.
        /// </summary>
        /// <param name="level">The minimum source level to log.</param>
        public static void Start(SourceLevels level)
        {
            // Enable WPF tracing, independently of registry setting
            PresentationTraceSources.Refresh();

            foreach (var kvp in sources)
            {
                FieldLogTraceListener listener;
                if (!listeners.TryGetValue(kvp.Key, out listener))
                {
                    listener = new FieldLogTraceListener(kvp.Value, "WPF");
                    listeners.Add(kvp.Key, listener);
                    kvp.Key.Listeners.Add(listener);
                }
                kvp.Key.Switch.Level = level;
            }

            if (diagTraceListener == null)
            {
                diagTraceListener = new FieldLogTraceListener("Diagnostics.Trace", "Trace");
                Trace.Listeners.Add(diagTraceListener);
            }
        }