Exemple #1
0
        /// <summary>
        /// Tests whether a log entry applies to the provider
        /// </summary>
        /// <param name="Entry">The Entry to validate</param>
        /// <returns>Whether it applies</returns>
        public bool MessageApplies(Message.LogEntry Entry)
        {
            if ((IncludeModules.Count == 0) && (ExcludeModules.Count == 0) && (IncludeTags.Count == 0) && (ExcludeTags.Count == 0))
            {
                return(true);
            }

            if (IncludeModules.Count > 0)
            {
                bool test = false;
                foreach (string module in IncludeModules)
                {
                    if (Entry.ModuleName.ToLower() == module.ToLower())
                    {
                        test = true;
                    }
                }

                if (!test)
                {
                    return(false);
                }
            }

            foreach (string module in ExcludeModules)
            {
                if (Entry.ModuleName.ToLower() == module.ToLower())
                {
                    return(false);
                }
            }

            if (IncludeTags.Count > 0)
            {
                if (IncludeTags.Except(Entry.Tags).ToList().Count == IncludeTags.Count)
                {
                    return(false);
                }
            }

            if (ExcludeTags.Except(Entry.Tags).ToList().Count < ExcludeTags.Count)
            {
                return(false);
            }

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Tests whether a log entry applies to the provider instance
        /// </summary>
        /// <param name="Entry">The Entry to validate</param>
        /// <returns>Whether it applies</returns>
        public bool MessageApplies(Message.LogEntry Entry)
        {
            // Level
            if (!IncludeWarning && (Entry.Level == Message.MessageLevel.Warning))
            {
                return(false);
            }
            if (((_MinLevel != 1) || (_MaxLevel != 9)) && (Entry.Level != Message.MessageLevel.Warning))
            {
                if (Entry.Level < (Message.MessageLevel)_MinLevel)
                {
                    return(false);
                }
                if (Entry.Level > (Message.MessageLevel)_MaxLevel)
                {
                    return(false);
                }
            }

            // Modules
            if (IncludeModules.Count > 0)
            {
                bool test = false;
                foreach (string module in IncludeModules)
                {
                    if (string.Equals(Entry.ModuleName, module, StringComparison.InvariantCultureIgnoreCase))
                    {
                        test = true;
                    }
                }

                if (!test)
                {
                    return(false);
                }
            }

            foreach (string module in ExcludeModules)
            {
                if (string.Equals(Entry.ModuleName, module, StringComparison.InvariantCultureIgnoreCase))
                {
                    return(false);
                }
            }

            // Functions
            if (IncludeFunctions.Count > 0)
            {
                bool test = false;
                foreach (string function in IncludeFunctions)
                {
                    if (UtilityHost.IsLike(Entry.FunctionName, function))
                    {
                        test = true;
                    }
                }

                if (!test)
                {
                    return(false);
                }
            }

            foreach (string function in ExcludeFunctions)
            {
                if (UtilityHost.IsLike(Entry.FunctionName, function))
                {
                    return(false);
                }
            }

            // Tags
            if (IncludeTags.Count > 0)
            {
                if (IncludeTags.Except(Entry.Tags, StringComparer.InvariantCultureIgnoreCase).ToList().Count == IncludeTags.Count)
                {
                    return(false);
                }
            }

            if (ExcludeTags.Except(Entry.Tags, StringComparer.InvariantCultureIgnoreCase).ToList().Count < ExcludeTags.Count)
            {
                return(false);
            }

            return(true);
        }