Пример #1
0
        protected override void EmitBatch(IEnumerable <LogEvent> events)
        {
            // ReSharper disable once PossibleMultipleEnumeration
            Task[] sendTasks = events.Select(logEvent =>
            {
                JObject json    = _converter.GetGelfJson(logEvent);
                Task resultTask = _transport.Send(json.ToString(Newtonsoft.Json.Formatting.None));
                return(resultTask);
            }).ToArray();

            Task.WaitAll(sendTasks);

            // ReSharper disable once PossibleMultipleEnumeration
            base.EmitBatch(events);
        }
Пример #2
0
        private Task EmitAsync(LogEvent logEvent)
        {
            JObject json    = _converter.GetGelfJson(logEvent);
            string  payload = json.ToString(Newtonsoft.Json.Formatting.None);

            return(_transport.Send(payload));
        }
 protected override async Task EmitBatchAsync(IEnumerable <LogEvent> events)
 {
     foreach (var @event in events)
     {
         var jObject = converter.GetGelfJson(@event);
         var json    = jObject.ToString(Newtonsoft.Json.Formatting.None);
         await transport.Value.SendAsync(json).ConfigureAwait(false);
     }
 }
Пример #4
0
        public void Emit(LogEvent logEvent)
        {
            try
            {
                JObject json = _converter.GetGelfJson(logEvent);

                Task.Run(async() => await _transport.Send(json.ToString(Newtonsoft.Json.Formatting.None)).ConfigureAwait(false)).GetAwaiter().GetResult();
            }
            catch (Exception exc)
            {
                SelfLog.WriteLine("Oops something going wrong {0}", exc);
            }
        }
 public void Emit(LogEvent @event)
 {
     try
     {
         var jObject = converter.GetGelfJson(@event);
         var json    = jObject.ToString(Newtonsoft.Json.Formatting.None);
         transport.Value.SendAsync(json).ConfigureAwait(false).GetAwaiter().GetResult();
     }
     catch (Exception exc)
     {
         SelfLog.WriteLine("Oops something going wrong {0}", exc);
     }
 }
Пример #6
0
        public void Emit(LogEvent logEvent)
        {
            JObject json = _converter.GetGelfJson(logEvent);

            Task.Factory.StartNew(() => _transport.Send(json.ToString(Newtonsoft.Json.Formatting.None))).GetAwaiter().GetResult();
        }
Пример #7
0
        public void Emit(LogEvent logEvent)
        {
            JObject json = _converter.GetGelfJson(logEvent);

            _transport.Send(json.ToString(Newtonsoft.Json.Formatting.None));
        }