Пример #1
0
        /// <summary>
        /// Emit a batch of log events to Datadog logs-backend.
        /// </summary>
        /// <param name="events">The events to emit.</param>
        protected override async Task EmitBatchAsync(IEnumerable <LogEvent> events)
        {
            if (!events.Any())
            {
                return;
            }

            var payload = new StringBuilder();

            foreach (var logEvent in events)
            {
                payload.Append(_apiKey + WhiteSpace);
                payload.Append(formatMessage(logEvent, _source, _service, _host, _tags));
                payload.Append(MessageDelimiter);
            }

            await _client.WriteAsync(payload.ToString());
        }
        /// <summary>
        /// Emit a batch of log events to Datadog logs-backend.
        /// </summary>
        /// <param name="events">The events to emit.</param>
        protected override async Task EmitBatchAsync(IEnumerable <LogEvent> events)
        {
            if (!events.Any())
            {
                return;
            }

            var payload = new StringBuilder();
            var writer  = new StringWriter(payload);

            foreach (var logEvent in events)
            {
                payload.Append(_apiKey + WhiteSpace);
                formatter.Format(logEvent, writer);
                payload.Append(MessageDelimiter);
            }

            await _client.WriteAsync(payload.ToString());
        }