internal Logger([NotNull] SoftString name, [NotNull] LogPredicate logPredicate, Action dispose) { _name = name ?? throw new ArgumentNullException(nameof(name)); _logPredicate = logPredicate; _dispose = dispose; _observers = new HashSet <IObserver <ILog> >(); }
public static LogPredicate LogRegex([NotNull] this LogPredicate logPredicate, Func <Log, string> getValue, [RegexPattern] string pattern, RegexOptions regexOptions = RegexOptions.None) { if (logPredicate == null) { throw new ArgumentNullException(nameof(logPredicate)); } return(log => logPredicate(log) && Regex.IsMatch(getValue(log), pattern, regexOptions)); }
public static LogPredicate ContainsException([NotNull] this LogPredicate logPredicate) { if (logPredicate == null) { throw new ArgumentNullException(nameof(logPredicate)); } return(log => logPredicate(log) && log.Exception().IsNotNull()); }
public static LogPredicate ScopeRegex([NotNull] this LogPredicate logPredicate, [RegexPattern] string pattern, RegexOptions regexOptions = RegexOptions.IgnoreCase) { if (logPredicate == null) { throw new ArgumentNullException(nameof(logPredicate)); } return(log => logPredicate(log) && log.Scopes().Select(scope => scope.ToString()).Any(scope => Regex.IsMatch(scope, pattern, regexOptions))); }
public static LogPredicate Contains([NotNull] this LogPredicate logPredicate, [NotNull] LogLevel logLevel) { if (logLevel == null) { throw new ArgumentNullException(nameof(logLevel)); } return(log => logPredicate(log) && logLevel.Contains(log.LogLevel())); }
public static LogPredicate Min([NotNull] this LogPredicate logPredicate, TimeSpan elapsed) { if (logPredicate == null) { throw new ArgumentNullException(nameof(logPredicate)); } return(log => logPredicate(log) && elapsed <= log.Elapsed()); }
public static LogPredicate NameRegex([NotNull] this LogPredicate logPredicate, [RegexPattern] string pattern, RegexOptions regexOptions = RegexOptions.IgnoreCase) { return(log => logPredicate(log) && logPredicate.LogRegex(l => l.Name()?.ToString() ?? string.Empty, pattern, regexOptions)(log)); }
public static LogPredicate MessageMatches([NotNull] this LogPredicate logPredicate, [RegexPattern] string pattern, RegexOptions regexOptions = RegexOptions.IgnoreCase) { return(log => logPredicate(log) && logPredicate.ValueMatches(l => l.Message() ?? string.Empty, pattern, regexOptions)(log)); }