Пример #1
0
 /// <summary>
 /// Sink that passes messages to YouTrack.
 /// </summary>
 /// <param name="reporter">Reporter to pass off messages to YouTrack.</param>
 /// <param name="configure">Configure reporting parameters such as YouTrack project, issue types and templates.</param>
 /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param>
 /// <param name="period">The time to wait between checking for event batches.</param>
 public YouTrackSink(IYouTrackReporter reporter, Action <IYouTrackReportingConfigurationExpressions> configure, int batchSizeLimit, TimeSpan period) : base(batchSizeLimit, period)
 {
     this.reporter = reporter ?? throw new ArgumentNullException(nameof(reporter));
     if (configure == null)
     {
         throw new ArgumentNullException(nameof(configure));
     }
     configuration = new YouTrackReportingConfiguration();
     configure(configuration);
     configuration.Build();
 }
Пример #2
0
        /// <summary>
        /// Adds a sink that sends log events to YouTrack.
        /// </summary>
        /// <param name="sinkConfiguration">The logger configuration.</param>
        /// <param name="reporter">The reporter used to pass off log events to YouTrack.</param>
        /// <param name="reportingConfiguration">Configure reporting parameters such as YouTrack project, issue types and templates. Project needs to always be configured.</param>
        /// <param name="batchSizeLimit">The maximum number of events to post in a single batch.</param>
        /// <param name="period">The time to wait between checking for event batches.</param>
        /// <param name="restrictedToMinimumLevel">The minimum log event level required in order to write an event to the sink.</param>
        /// <returns>Logger configuration, allowing configuration to continue.</returns>
        public static LoggerConfiguration YouTrack(this LoggerSinkConfiguration sinkConfiguration, IYouTrackReporter reporter, Action <IYouTrackReportingConfigurationExpressions> reportingConfiguration, int batchSizeLimit = DefaultBatchPostingLimit, TimeSpan?period = null, LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
        {
            if (sinkConfiguration == null)
            {
                throw new ArgumentNullException(nameof(sinkConfiguration));
            }

            if (reporter == null)
            {
                throw new ArgumentNullException(nameof(reporter));
            }

            if (reportingConfiguration == null)
            {
                throw new ArgumentNullException(nameof(reportingConfiguration));
            }

            period = period ?? DefaultPeriod;

            var sink = new YouTrackSink(reporter, reportingConfiguration, batchSizeLimit, period.Value);

            return(sinkConfiguration.Sink(sink, restrictedToMinimumLevel));
        }