コード例 #1
0
        public void OnNext(EventEntry value)
        {
            var sw = new StringWriter();

            formatter.WriteEvent(value, sw);
            socket.Send(Encoding.UTF8.GetBytes(sw.ToString()));
        }
コード例 #2
0
        public void OnNext(EventEntry value)
        {
            var sw = new StringWriter();

            formatter.WriteEvent(value, sw);
            this.writer.Enqueue(sw.ToString());
        }
コード例 #3
0
        /// <summary>
        /// Formats the event as a string.
        /// </summary>
        /// <param name="entry">The entry to format.</param>
        /// <param name="formatter">The formatter to use.</param>
        /// <returns>A formatted entry.</returns>
        public static string WriteEvent(this IEventTextFormatter formatter, EventEntry entry)
        {
            Guard.ArgumentNotNull(formatter, "formatter");

            using (var writer = new StringWriter(CultureInfo.CurrentCulture))
            {
                formatter.WriteEvent(entry, writer);
                return(writer.ToString());
            }
        }
コード例 #4
0
        /// <summary>
        ///     Formats the event as a string.
        /// </summary>
        /// <param name="snapshot">The partition snapshot to format.</param>
        /// <param name="formatter">The formatter to use.</param>
        /// <returns>A formatted snapshot.</returns>
        public static string WriteEvent(this IEventTextFormatter formatter, PartitionSnapshot snapshot)
        {
            Guard.ArgumentNotNull(formatter, "formatter");

            using (var writer = new StringWriter(CultureInfo.CurrentCulture))
            {
                formatter.WriteEvent(snapshot, writer);
                return(writer.ToString());
            }
        }
コード例 #5
0
 public void OnNext(EventEntry entry)
 {
     if (entry == null)
     {
         return;
     }
     using (var writer = new StringWriter()) {
         _formatter.WriteEvent(entry, writer);
         _log.Add(writer.ToString());
     }
 }
コード例 #6
0
 /// <summary>
 /// All events are going through OnNext callback.
 /// </summary>
 /// <param name="value">An event.</param>
 public void OnNext(EventEntry value)
 {
     using (var sw = new StringWriter())
     {
         formatter.WriteEvent(value, sw);
         sender.Send(
             id: value.EventId.ToString(),
             severity: value.Schema.Level.ToString(),
             message: sw.ToString()
             );
     }
 }
コード例 #7
0
 public void OnNext(EventEntry value)
 {
     if (value == null)
     {
         return;
     }
     using (var writer = new StringWriter())
     {
         formatter.WriteEvent(value, writer);
         events.Enqueue(new DbEventEntry(value, writer.ToString()));
     }
 }
コード例 #8
0
        /// <summary>
        /// Formats an <see cref="EventEntry"/> as a string using an <see cref="IEventTextFormatter"/>.
        /// </summary>
        /// <param name="entry">The entry to format.</param>
        /// <param name="formatter">The formatter to use.</param>
        /// <returns>A formatted entry, or <see langword="null"/> if an exception is thrown by the <paramref name="formatter"/>.</returns>
        public static string TryFormatAsString(this EventEntry entry, IEventTextFormatter formatter)
        {
            try
            {
                return(formatter.WriteEvent(entry));
            }
            catch (Exception e)
            {
                SemanticLoggingEventSource.Log.FormatEntryAsStringFailed(e.ToString());
            }

            return(null);
        }
コード例 #9
0
        /// <summary>
        /// Formats an <see cref="EventEntry"/> as a string using an <see cref="IEventTextFormatter"/>.
        /// </summary>
        /// <param name="entry">The entry to format.</param>
        /// <param name="formatter">The formatter to use.</param>
        /// <returns>A formatted entry, or <see langword="null"/> if an exception is thrown by the <paramref name="formatter"/>.</returns>
        public static string TryFormatAsString(this EventEntry entry, IEventTextFormatter formatter)
        {
            try
            {
                return formatter.WriteEvent(entry);
            }
            catch (Exception e)
            {
                SemanticLoggingEventSource.Log.FormatEntryAsStringFailed(e.ToString());
            }

            return null;
        }
コード例 #10
0
        /// <summary>
        ///     Formats an <see cref="PartitionSnapshot" /> as a string using an <see cref="IEventTextFormatter" />.
        /// </summary>
        /// <param name="snapshot">The snapshot to format.</param>
        /// <param name="formatter">The formatter to use.</param>
        /// <returns>A formatted snapshot, or <see langword="null" /> if an exception is thrown by the <paramref name="formatter" />.</returns>
        public static string TryFormatAsString(this PartitionSnapshot snapshot, IEventTextFormatter formatter)
        {
            try
            {
                return(formatter.WriteEvent(snapshot));
            }
            catch (Exception e)
            {
                //SemanticLoggingEventSource.Log.FormatEntryAsStringFailed(e.ToString());
            }

            return(null);
        }
コード例 #11
0
        /// <summary>
        ///     Formats an <see cref="PartitionSnapshot" /> as a string using an <see cref="IEventTextFormatter" />.
        /// </summary>
        /// <param name="snapshot">The snapshot to format.</param>
        /// <param name="formatter">The formatter to use.</param>
        /// <returns>A formatted snapshot, or <see langword="null" /> if an exception is thrown by the <paramref name="formatter" />.</returns>
        public static string TryFormatAsString(this PartitionSnapshot snapshot, IEventTextFormatter formatter)
        {
            try
            {
                return formatter.WriteEvent(snapshot);
            }
            catch (Exception e)
            {
                //SemanticLoggingEventSource.Log.FormatEntryAsStringFailed(e.ToString());
            }

            return null;
        }
コード例 #12
0
ファイル: EmailSink.cs プロジェクト: mindis/Transformalize
 public void OnNext(EventEntry entry)
 {
     if (entry == null)
     {
         return;
     }
     using (var writer = new StringWriter()) {
         _formatter.WriteEvent(entry, writer);
         if (_log.Async)
         {
             SendAsync(writer.ToString());
         }
         else
         {
             Send(writer.ToString());
         }
     }
 }
コード例 #13
0
 public void OnNext(EventEntry value)
 {
     EventsWritten.Add(formatter.WriteEvent(value));
 }