public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, LogEvent log)
        {
            var builder = log.Exception != null
                ? client.CreateException(log.Exception)
                : client.CreateLog(log.GetSource(), log.RenderMessage(), log.GetLevel());

            builder.Target.Date = log.Timestamp;
            if (log.Level == LogEventLevel.Fatal)
                builder.MarkAsCritical();

            if (!String.IsNullOrWhiteSpace(log.RenderMessage()))
                builder.SetMessage(log.RenderMessage());

            return builder;
        }
        public static EventBuilder CreateFromLogEvent(this ExceptionlessClient client, LoggingEvent ev) {
            var builder = ev.ExceptionObject != null ? client.CreateException(ev.ExceptionObject) : client.CreateLog(ev.LoggerName, ev.RenderedMessage, ev.Level.Name);
            builder.Target.Date = ev.TimeStamp;

            if (!String.IsNullOrWhiteSpace(ev.RenderedMessage))
                builder.SetMessage(ev.RenderedMessage);

            if (ev.ExceptionObject != null)
                builder.SetSource(ev.LoggerName);

            var props = ev.GetProperties();
            foreach (var key in props.GetKeys().Where(key => !_ignoredEventProperties.Contains(key, StringComparer.OrdinalIgnoreCase))) {
                string propName = key;
                if (propName.StartsWith("log4net:"))
                    propName = propName.Substring(8);
                builder.SetProperty(propName, props[key]);
            }

            return builder;
        }
Exemplo n.º 3
0
        /// <summary>Asserts that the local name of a given element is the name indicated, and ignores the
        /// element's contents.</summary>
        /// <exception cref="XmlException">Thrown when the XML content pointed to by
        /// <paramref name="xmlReader"/> does not match the indicated <paramref name="elementName"/> and
        /// <paramref name="options"/>.</exception>
        /// <param name="xmlReader">The XML reader from which the element shall be read.</param>
        /// <param name="elementName">Name of the element.</param>
        /// <param name="options">Options deciding what content to skip.</param>
        internal static void IgnoreElement(this XmlReader xmlReader, string elementName, IgnoreOptions options)
        {
            if (!IsOnElement(xmlReader, elementName))
            {
                if (options.HasFlag(IgnoreOptions.Optional))
                {
                    return;
                }
                else
                {
                    throw xmlReader.CreateException(ConverterResources.ExpectedElementNamed, elementName);
                }
            }

            xmlReader.Skip();
            if (options.HasFlag(IgnoreOptions.Multiple))
            {
                while (IsOnElement(xmlReader, elementName))
                {
                    xmlReader.Skip();
                }
            }
        }
        /// <summary>
        /// Submits an exception event.
        /// </summary>
        /// <param name="client">The client instance.</param>
        /// <param name="exception">The exception.</param>
        public static void SubmitException(this ExceptionlessClient client, Exception exception) {
            if (client == null)
                throw new ArgumentNullException(nameof(client));

            client.CreateException(exception).Submit();
        }
Exemplo n.º 5
0
 /// <summary>
 /// Submits an exception event.
 /// </summary>
 /// <param name="client">The client instance.</param>
 /// <param name="exception">The exception.</param>
 public static void SubmitException(this ExceptionlessClient client, Exception exception) {
     client.CreateException(exception).Submit();
 }
Exemplo n.º 6
0
 /// <summary>Creates an exception with line number and position data from an
 /// <see cref="XmlReader"/>.</summary>
 /// <param name="xmlReader">The xmlReader from which line data shall be retrieved.</param>
 /// <param name="message">The message to attach to the exception.</param>
 /// <param name="args">A variable-length parameters list containing arguments formatted into
 /// <paramref name="message"/>.</param>
 /// <returns>The new exception with <paramref name="message"/>, and file and line information from
 /// <paramref name="xmlReader"/>.</returns>
 internal static XmlException CreateException(this XmlReader xmlReader, string message, params object[] args)
 {
     return xmlReader.CreateException(String.Format(CultureInfo.CurrentCulture, message, args));
 }