示例#1
0
        public void MinimumAcceptedLevelIsIgnoredWhenMissing()
        {
            const string response  = @"{}";
            var          extracted = SeqIngestionApiClient.ReadIngestionResult(response);

            Assert.Null(extracted);
        }
示例#2
0
        public void MinimumAcceptedLevelIsExtractedWhenPresent()
        {
            const string response  = @"{""MinimumLevelAccepted"":""Warning""}";
            var          extracted = SeqIngestionApiClient.ReadIngestionResult(response);

            Assert.Equal(LogEventLevel.Warning, extracted);
        }
        /// <summary>
        /// Write audit log events to a <a href="https://datalust.co/seq">Seq</a> server. Auditing writes are
        /// synchronous and non-batched; any failures will propagate to the caller immediately as exceptions.
        /// </summary>
        /// <param name="loggerAuditSinkConfiguration">The logger configuration.</param>
        /// <param name="serverUrl">The base URL of the Seq server that log events will be written to.</param>
        /// <param name="restrictedToMinimumLevel">The minimum log event level required
        /// in order to write an event to the sink.</param>
        /// <param name="apiKey">A Seq <i>API key</i> that authenticates the client to the Seq server.</param>
        /// <param name="messageHandler">Used to construct the HttpClient that will send the log messages to Seq.</param>
        /// <returns>Logger configuration, allowing configuration to continue.</returns>
        /// <exception cref="ArgumentNullException">A required parameter is null.</exception>
        public static LoggerConfiguration Seq(
            this LoggerAuditSinkConfiguration loggerAuditSinkConfiguration,
            string serverUrl,
            LogEventLevel restrictedToMinimumLevel = LevelAlias.Minimum,
            string?apiKey = null,
            HttpMessageHandler?messageHandler = null)
        {
            if (loggerAuditSinkConfiguration == null)
            {
                throw new ArgumentNullException(nameof(loggerAuditSinkConfiguration));
            }
            if (serverUrl == null)
            {
                throw new ArgumentNullException(nameof(serverUrl));
            }

            var ingestionApi = new SeqIngestionApiClient(serverUrl, apiKey, messageHandler);

            return(loggerAuditSinkConfiguration.Sink(new SeqAuditSink(ingestionApi), restrictedToMinimumLevel));
        }
示例#4
0
        public void ServerBaseAddressesAreNormalized(string url, string expected)
        {
            var normalized = SeqIngestionApiClient.NormalizeServerBaseAddress(url);

            Assert.Equal(expected, normalized);
        }