コード例 #1
0
 public HttpLogzioTest()
 {
     client = new Mock <IHttpClient>();
     autkey = "Key";
     sink   = new LogzioSink(
         client.Object,
         autkey,
         LogzioSink.DefaultBatchPostingLimit,
         LogzioSink.DefaultPeriod,
         null);
 }
コード例 #2
0
        /// <summary>
        /// Adds a sink that sends log events using HTTP POST over the network.
        /// </summary>
        /// <param name="sinkConfiguration">The logger configuration.</param>
        /// <param name="authToken">The token for your logzio account.</param>
        /// <param name="type">Your log type - it helps classify the logs you send.</param>
        /// <param name="options">Logzio configuration options</param>
        /// <returns>Logger configuration, allowing configuration to continue.</returns>
        public static LoggerConfiguration LogzIo(this LoggerSinkConfiguration sinkConfiguration, string authToken, string type, LogzioOptions options = null)
        {
            if (sinkConfiguration == null)
            {
                throw new ArgumentNullException(nameof(sinkConfiguration));
            }

            var client = new HttpClientWrapper();
            var sink   = new LogzioSink(client, authToken, type, options ?? new LogzioOptions());
            var restrictedToMinimumLevel = options?.RestrictedToMinimumLevel ?? LogEventLevel.Verbose;

            return(sinkConfiguration.Sink(sink, restrictedToMinimumLevel));
        }
コード例 #3
0
        /// <summary>
        /// Adds a sink that sends log events using HTTP POST over the network.
        /// </summary>
        /// <param name="sinkConfiguration">The logger configuration.</param>
        /// <param name="authToken">The token for your logzio account.</param>
        /// <param name="type">Your log type - it helps classify the logs you send.</param>
        /// <param name="options">Logzio configuration options</param>
        /// <returns>Logger configuration, allowing configuration to continue.</returns>
        public static LoggerConfiguration LogzIo(
            this LoggerSinkConfiguration sinkConfiguration,
            string authToken,
            string type,
            LogzioOptions options = null)
        {
            if (sinkConfiguration == null)
            {
                throw new ArgumentNullException(nameof(sinkConfiguration));
            }

            var client = new HttpClientWrapper();
            var sink   = new LogzioSink(
                client,
                authToken,
                type,
                options?.BatchPostingLimit ?? LogzioSink.DefaultBatchPostingLimit,
                options?.Period ?? LogzioSink.DefaultPeriod,
                options?.UseHttps ?? true);

            return(sinkConfiguration.Sink(sink, options?.RestrictedToMinimumLevel ?? LogEventLevel.Verbose));
        }
コード例 #4
0
        /// <summary>
        /// Adds a sink that sends log events using HTTP POST over the network.
        /// </summary>
        /// <param name="sinkConfiguration">The logger configuration.</param>
        /// <param name="authToken">The token for your logzio account.</param>
        /// <param name="batchPostingLimit">
        /// The maximum number of events to post in a single batch. The default is
        /// <see cref="LogzioSink.DefaultBatchPostingLimit"/>.
        /// </param>
        /// <param name="period">
        /// The time to wait between checking for event batches. The default is
        /// <see cref="LogzioSink.DefaultPeriod"/>.
        /// </param>
        /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
        /// <param name="restrictedToMinimumLevel">
        /// The minimum level for events passed through the sink. The default is
        /// <see cref="LevelAlias.Minimum"/>.
        /// </param>
        /// <returns>Logger configuration, allowing configuration to continue.</returns>
        public static LoggerConfiguration Logzio(
            this LoggerSinkConfiguration sinkConfiguration,
            string authToken,
            int?batchPostingLimit                  = null,
            TimeSpan?period                        = null,
            IFormatProvider formatProvider         = null,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum)
        {
            if (sinkConfiguration == null)
            {
                throw new ArgumentNullException(nameof(sinkConfiguration));
            }

            var client = new HttpClientWrapper();
            var sink   = new LogzioSink(
                client,
                authToken,
                batchPostingLimit ?? LogzioSink.DefaultBatchPostingLimit,
                period ?? LogzioSink.DefaultPeriod,
                formatProvider);

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