Ejemplo n.º 1
0
        private static bool InternalRemoveFilter(TraceSinkType sinkType, string taskName)
        {
            string eventName = null;
            int    index     = taskName.IndexOf('.');

            if (index >= 0)
            {
                eventName = taskName.Substring(index + 1).Trim();
                taskName  = taskName.Substring(0, index).Trim();
            }

            EventTask taskId;

            if (!string.IsNullOrEmpty(taskName))
            {
                taskId = FabricEvents.Events.GetEventTask(taskName);
                if (taskId == FabricEvents.Tasks.Max)
                {
                    return(false);
                }
            }
            else
            {
                taskId = FabricEvents.Tasks.Max;
            }

            TraceSinkFilter filter = SinkFilters[(int)sinkType];

            lock (SyncLock)
            {
                filter.RemoveFilter(taskId, eventName);
            }

            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add filter for a sink.
        /// </summary>
        /// <param name="sink">Type of the sink.</param>
        /// <param name="taskName">Task name.</param>
        /// <param name="eventName">Event name.</param>
        /// <param name="level">Level for the filter.</param>
        /// <param name="samplingRatio">Sampling ratio for records below the level.</param>
        /// <returns>Whether the filter is set correctly.</returns>
        private static bool InternalAddFilter(TraceSinkType sink, string taskName, string eventName, EventLevel level, int samplingRatio)
        {
            EventTask taskId;

            if (!string.IsNullOrEmpty(taskName))
            {
                taskId = FabricEvents.Events.GetEventTask(taskName);

                if (taskId == FabricEvents.Tasks.Max)
                {
                    return(false);
                }
            }
            else
            {
                taskId = FabricEvents.Tasks.Max;
            }

            TraceSinkFilter filter = SinkFilters[(int)sink];

            lock (SyncLock)
            {
                filter.AddFilter(taskId, eventName, level, samplingRatio);
            }

            return(true);
        }
Ejemplo n.º 3
0
        private static TraceSinkFilter[] CreateSinkFilters()
        {
            TraceSinkFilter[] filters = new TraceSinkFilter[(int)TraceSinkType.Max];
            for (int i = 0; i < filters.Length; i++)
            {
                TraceSinkType sink = (TraceSinkType)i;
                filters[i] = new TraceSinkFilter(sink, EventLevel.LogAlways);
            }

            SetDefaultConfigFilters(filters);

            return(filters);
        }