Immutable encapsulation of the two source filters: this enables overriding or per source file filtering.
 /// <summary>
 /// Sets a <see cref="SourceLogFilter"/> for a given file.
 /// Use <see cref="SourceLogFilter.Undefined"/> to clear any existing configuration for the file.
 /// </summary>
 /// <param name="filter">The filter to set for the file.</param>
 /// <param name="fileName">The file name: do not specify it to inject the path of your source file.</param>
 public static void SetFilter(SourceLogFilter filter, [CallerFilePath] string fileName = null)
 {
     if (filter.IsUndefined)
     {
         _filters.TryRemove(fileName, out filter);
     }
     else
     {
         _filters.AddOrUpdate(fileName, filter, (s, prev) => filter);
     }
 }
示例#2
0
 /// <summary>
 /// Combines this filter with another one. <see cref="Override"/> and <see cref="Minimal"/> level filters
 /// are combined with <see cref="LogFilter.Combine(LogFilter)"/>.
 /// </summary>
 /// <param name="other">The other filter to combine with this one.</param>
 /// <returns>The resulting filter.</returns>
 public SourceLogFilter Combine( SourceLogFilter other )
 {
     return new SourceLogFilter( Override.Combine( other.Override ), Minimal.Combine( other.Minimal ) );
 }
示例#3
0
 /// <summary>
 /// Combines this filter with another one. <see cref="Override"/> and <see cref="Minimal"/> level filters
 /// are combined with <see cref="LogFilter.Combine(LogFilter)"/>.
 /// </summary>
 /// <param name="other">The other filter to combine with this one.</param>
 /// <returns>The resulting filter.</returns>
 public SourceLogFilter Combine(SourceLogFilter other)
 {
     return(new SourceLogFilter(Override.Combine(other.Override), Minimal.Combine(other.Minimal)));
 }
 /// <summary>
 /// Sets a <see cref="SourceLogFilter"/> for a given file. 
 /// Use <see cref="SourceLogFilter.Undefined"/> to clear any existing configuration for the file.
 /// </summary>
 /// <param name="filter">The filter to set for the file.</param>
 /// <param name="fileName">The file name: do not specify it to inject the path of your source file.</param>
 public static void SetFilter( SourceLogFilter filter, [CallerFilePath]string fileName = null )
 {
     if( filter.IsUndefined ) _filters.TryRemove( fileName, out filter );
     else _filters.AddOrUpdate( fileName, filter, ( s, prev ) => filter ); 
 }