public static void Error(this IEventRegistry registry, IEventSource source, int errorClass, int errorCode, ErrorLevel level, string message, string stackTrace, string errorSource)
 {
     var errorEvent = new ErrorEvent(source, errorClass, errorCode, message);
     errorEvent.ErrorLevel(level);
     errorEvent.StackTrace(stackTrace);
     errorEvent.ErrorSource(errorSource);
     registry.RegisterEvent(errorEvent);
 }
        public static void Error(this IEventRegistry registry, IEventSource source, Exception ex)
        {
            var errorEvent = new ErrorEvent(source, EventClasses.Runtime, -1, ex.Message);
            errorEvent.ErrorLevel(ErrorLevel.Error);
            errorEvent.StackTrace(ex.StackTrace);
            #if !PCL
            errorEvent.ErrorSource(ex.Source);
            #endif

            registry.RegisterEvent(errorEvent);
        }
Esempio n. 3
0
        /// <summary>
        /// Transforms the error to an event to be passed to the diagnostics,
        /// given a source where this was generated.
        /// </summary>
        /// <param name="source">The source of the error.</param>
        /// <returns>
        /// Returns an instance of <see cref="ErrorEvent"/> that encapsulates all the information
        /// about this exception, that can be routed to the diagnostics.
        /// </returns>
        public ErrorEvent AsEvent(IEventSource source)
        {
            var e = new ErrorEvent(source, EventClass, ErrorCode, Message);

            foreach (DictionaryEntry entry in Data) {
                e.SetData(entry.Key.ToString(), entry.Value);
            }

            e.ErrorLevel(ErrorLevel);
            e.StackTrace(StackTrace);
            #if !PCL
            e.ErrorSource(Source);
            #endif

            return e;
        }
 public static void OnError(this IEventSource source, Exception error, int errorCode, ErrorLevel level)
 {
     var errorEvent = new ErrorEvent(error, errorCode, level);
     source.OnEvent(errorEvent);
 }
Esempio n. 5
0
        /// <summary>
        /// Transforms the error to an event to be passed to the diagnostics,
        /// given a source where this was generated.
        /// </summary>
        /// <param name="source">The source of the error.</param>
        /// <returns>
        /// Returns an instance of <see cref="ErrorEvent"/> that encapsulates all the information
        /// about this exception, that can be routed to the diagnostics.
        /// </returns>
        public ErrorEvent AsEvent(IEventSource source)
        {
            var e = new ErrorEvent(this, ErrorCode, ErrorLevel);

            if (source != null)
                e.EventSource = source;

            return e;
        }
        public static void OnError(this IHasContext obj, Exception error, int errorCode, ErrorLevel level)
        {
            var errorEvent = new ErrorEvent(error, errorCode, level);

            obj.OnEvent(errorEvent);
        }
Esempio n. 7
0
        public static void OnError(this IEventSource source, Exception error, int errorCode, ErrorLevel level)
        {
            var errorEvent = new ErrorEvent(error, errorCode, level);

            source.OnEvent(errorEvent);
        }
Esempio n. 8
0
 private EventLog CreateEntry(ErrorEvent @event)
 {
     return new EventLog(
         @event.EventClass,
         @event.ErrorCode,
         @event.ErrorSource(),
         GetLogLevel(@event.ErrorLevel()),
         @event.Database(),
         @event.UserName(),
         @event.RemoteAddress(),
         @event.Message,
         null);
 }