Example #1
0
        /// <summary>
        /// This method must be overriden and forms the core logging method called by all other TraceEvent methods.
        /// </summary>
        /// <param name="eventCache">A cache of data that defines the trace event</param>
        /// <param name="source">The trace source</param>
        /// <param name="eventType">The type of event</param>
        /// <param name="id">The unique ID of the trace event</param>
        /// <param name="message">A message to be output regarding the trace event</param>
        protected override void TraceEventCore(TraceEventCache eventCache, string source, TraceEventType eventType,
                                               int id, string message)
        {
            object value;

            if (_propertyReader.TryGetValue(out value, eventCache, source, eventType, id, message, null))
            {
                Console.WriteLine(StringFormatter.SafeToString(value));
            }
        }
        /// <summary>
        /// This method must be overriden and forms the core logging method called by all other TraceEvent methods.
        /// </summary>
        /// <param name="eventCache">A cache of data that defines the trace event</param>
        /// <param name="source">The trace source</param>
        /// <param name="eventType">The type of event</param>
        /// <param name="id">The unique ID of the trace event</param>
        /// <param name="message">A message to be output regarding the trace event</param>
        protected override void TraceEventCore(TraceEventCache eventCache, string source, TraceEventType eventType,
                                               int id, string message)
        {
            object value;

            if (_propertyReader.TryGetValue(out value, eventCache, source, eventType, id, message, null))
            {
                SafeNativeMethods.OutputDebugString(StringFormatter.SafeToString(value));
            }
        }
Example #3
0
        /// <summary>
        /// This method implements the logging for TraceEvent calls
        /// </summary>
        protected override void TraceEventCore(TraceEventCache eventCache, string source, TraceEventType eventType, int id, string message)
        {
            if (!ShouldLog()) // don't build the message if there's no-one listening
            {
                return;
            }
            object value;

            if (_propertyReader.TryGetValue(out value, eventCache, source, eventType, id, message, null))
            {
                Log(StringFormatter.SafeToString(value));
            }
        }
Example #4
0
        /// <summary>
        /// Return true if we should trace the current event
        /// </summary>
        /// <param name="cache">The event to trace</param>
        /// <param name="source">The source of the event</param>
        /// <param name="eventType">The type of event</param>
        /// <param name="id">The ID of the event</param>
        /// <param name="formatOrMessage">The format or message string</param>
        /// <param name="args">A collection of optional arguments</param>
        /// <param name="data1">An optional data object</param>
        /// <param name="data">An optional data object collection</param>
        /// <returns>True if this event should be traced</returns>
        public override bool ShouldTrace(TraceEventCache cache, string source, TraceEventType eventType, int id,
                                         string formatOrMessage, object[] args, object data1, object[] data)
        {
            object value;

            bool valueFound = PropertyReader.TryGetValue(out value, cache, source, eventType, id, formatOrMessage, data);

            if (!valueFound)
            {
                return(DefaultEvaluation);
            }

            return(PropertyReader.Comparator.Compare(Operation, (IComparable)value, TargetValue));
        }