/// <summary> /// Blocks log events with the loglevels specified within the range of /// <paramref name="from"/> and <paramref name="to"/>. /// </summary> /// <remarks>The order of <paramref name="from"/> and <paramref name="to"/> /// is irrelevant.</remarks> /// <typeparam name="TLoglevel">The loglevel type.</typeparam> /// <param name="self">The configuration builder.</param> /// <param name="from">The more detailed loglevel to block.</param> /// <param name="to">The more critical loglevel to block.</param> /// <returns>The same configuration builder instance to allow a fluent syntax.</returns> public static LogfileConfigurationBuilder <TLoglevel> BlockLoglevels <TLoglevel>( this LogfileConfigurationBuilder <TLoglevel> self, TLoglevel from, TLoglevel to) where TLoglevel : Enum { if (self == null) { throw new ArgumentNullException(nameof(self)); } if (from.CompareTo(to) > 0) { var temp = to; to = from; from = temp; } var from_ = from; var loglevels = from l in Enum.GetValues(typeof(TLoglevel)).Cast <TLoglevel>() where l.CompareTo(from_) >= 0 && l.CompareTo(to) <= 0 select l; foreach (var loglevel in loglevels.Except(self.BlockLoglevels).ToList()) { self.BlockLoglevels.Add(loglevel); } return(self); }
/// <summary> /// Enables the automatic extraction of log events stored in exception data. /// </summary> /// <typeparam name="TLoglevel">The loglevel type.</typeparam> /// <param name="configurationBuilder">The configuration builder.</param> /// <returns>The same configuration builder instance to allow a fluent syntax.</returns> public static LogfileConfigurationBuilder <TLoglevel> UseLogEventsFromExceptionData <TLoglevel>( this LogfileConfigurationBuilder <TLoglevel> configurationBuilder) where TLoglevel : Enum { configurationBuilder.AddPreprocessor(ExtractLogEventsFromExceptions <TLoglevel> .Instance); return(configurationBuilder); }
/// <summary> /// Enables the developer mode. /// </summary> /// <remarks>Enabling the developer mode allows log events to be forwarded which /// had been flagged as developer events. Thus, a developer may still use /// the loglevel to distinguish different types of events while completely /// turning on or off certain events not intended for public audience.</remarks> /// <typeparam name="TLoglevel">The loglevel type.</typeparam> /// <param name="self">The configuration builder.</param> /// <returns>The same configuration builder instance to allow a fluent syntax.</returns> public static LogfileConfigurationBuilder <TLoglevel> EnableDeveloperMode <TLoglevel>( this LogfileConfigurationBuilder <TLoglevel> self) where TLoglevel : Enum { if (self == null) { throw new ArgumentNullException(nameof(self)); } self.IsDeveloperModeEnabled = true; return(self); }
/// <summary> /// Enables the developer mode when compiled in with DEBUG compiler flag. /// </summary> /// <remarks>Enabling the developer mode allows log events to be forwarded which /// had been flagged as developer events. Thus, a developer may still use /// the loglevel to distinguish different types of events while completely /// turning on or off certain events not intended for public audience.</remarks> /// <typeparam name="TLoglevel">The loglevel type.</typeparam> /// <param name="self">The configuration builder.</param> /// <returns>The same configuration builder instance to allow a fluent syntax.</returns> public static LogfileConfigurationBuilder <TLoglevel> EnableDeveloperModeForDebugCompilerFlag <TLoglevel>( this LogfileConfigurationBuilder <TLoglevel> self) where TLoglevel : Enum { if (self == null) { throw new ArgumentNullException(nameof(self)); } #if DEBUG self.IsDeveloperModeEnabled = true; #endif return(self); }
/// <summary> /// Blocks log events with the specified <paramref name="loglevel"/> from being forwarded. /// </summary> /// <typeparam name="TLoglevel">The loglevel type.</typeparam> /// <param name="self">The configuration builder.</param> /// <param name="loglevel">The loglevel to block.</param> /// <returns>The same configuration builder instance to allow fluent syntax.</returns> public static LogfileConfigurationBuilder <TLoglevel> BlockLoglevel <TLoglevel>( this LogfileConfigurationBuilder <TLoglevel> self, TLoglevel loglevel) where TLoglevel : Enum { if (self == null) { throw new ArgumentNullException(nameof(self)); } if (!self.BlockLoglevels.Contains(loglevel)) { self.BlockLoglevels.Add(loglevel); } return(self); }
/// <summary> /// Adds a router. /// </summary> /// <typeparam name="T">The loglevel type.</typeparam> /// <param name="self">The configuration builder.</param> /// <param name="router">The router to add.</param> /// <returns>The same configuration builder instance to allow a fluent syntax.</returns> /// <exception cref="ArgumentNullException">Thrown if either /// <paramref name="self"/> or <paramref name="router"/> is null.</exception> public static LogfileConfigurationBuilder <TLoglevel> AddRouter <TLoglevel>(this LogfileConfigurationBuilder <TLoglevel> self, IRouter <LogEvent <TLoglevel> > router) where TLoglevel : Enum { if (self == null) { throw new ArgumentNullException(nameof(self)); } if (router == null) { throw new ArgumentNullException(nameof(router)); } self.Routers.Add(router); return(self); }
/// <summary> /// Sets the time to wait for more routables to be forwarded /// before actually starting to forward any routables. /// </summary> /// <typeparam name="TLoglevel">The event type.</typeparam> /// <param name="self">The configuration builder.</param> /// <param name="value">The delay.</param> /// <returns>The same configuration builder instance to allow a fluent syntax.</returns> public static LogfileConfigurationBuilder <TLoglevel> SetWaitForMoreRoutablesForwardingDelay <TLoglevel>(this LogfileConfigurationBuilder <TLoglevel> self, TimeSpan value) where TLoglevel : Enum { if (self == null) { throw new ArgumentNullException(nameof(self)); } self.WaitForMoreRoutablesForwardingDelay = value; return(self); }
/// <summary> /// Set the maximum number of routables to forward at once. /// </summary> /// <typeparam name="TLoglevel">The event type.</typeparam> /// <param name="self">The configuration builder.</param> /// <param name="value">The count.</param> /// <returns>The same configuration builder instance to allow a fluent syntax.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="self"/> is null.</exception> public static LogfileConfigurationBuilder <TLoglevel> SetMaximumRoutablesForwardingCount <TLoglevel>(this LogfileConfigurationBuilder <TLoglevel> self, int value) where TLoglevel : Enum { if (self == null) { throw new ArgumentNullException(nameof(self)); } self.MaximumRoutablesForwardingCount = value; return(self); }
/// <summary> /// Adds a preprocessor. /// </summary> /// <typeparam name="T">The loglevel type.</typeparam> /// <param name="self">The configuration builder.</param> /// <param name="preprocessor">The preprocessor to add.</param> /// <returns>The same configuration builder instance to allow a fluent syntax.</returns> /// <exception cref="ArgumentNullException">Thrown if either /// <paramref name="self"/> or <paramref name="preprocessor"/> is null.</exception> public static LogfileConfigurationBuilder <TLoglevel> AddPreprocessor <TLoglevel>(this LogfileConfigurationBuilder <TLoglevel> self, IRoutablePreprocessor <LogEvent <TLoglevel> > preprocessor) where TLoglevel : Enum { if (self == null) { throw new ArgumentNullException(nameof(self)); } if (preprocessor == null) { throw new ArgumentNullException(nameof(preprocessor)); } self.Preprocessors.Add(preprocessor); return(self); }