예제 #1
0
        public static bool LogEvent(Exception ex, CallingMethod component)
        {
            try
            {
                if (EventLog.SourceExists(EventSource))
                {
                    var eventLogger = new EventLog {
                        Source = EventSource
                    };
                    var message = ex.InnerException == null
                                      ? ex.Message
                                      : ex.InnerException.Message;

                    eventLogger.WriteEntry(string.Format("{0} {1}", message, component.Text), EventLogEntryType.Warning);
                }
            }
// ReSharper disable EmptyGeneralCatchClause
            catch
// ReSharper restore EmptyGeneralCatchClause
            {
            }
            return(true);
        }
예제 #2
0
 /// <summary>
 /// Logs the error.
 /// </summary>
 /// <param name="error">The error.</param>
 /// <param name="component">The component.</param>
 /// <param name="instance">The instance.</param>
 /// <returns></returns>
 public static bool LogError(string error, CallingMethod component, string instance)
 {
     return(Log(string.Format("{0} {1}", error, component.Text), 3, component.MethodName, instance));
 }
예제 #3
0
 /// <summary>
 /// Logs the error.
 /// </summary>
 /// <param name="ex">The ex.</param>
 /// <param name="component">The component.</param>
 /// <returns></returns>
 public static bool LogError(Exception ex, CallingMethod component)
 {
     return(LogError(ex.GetBaseException().Message, component));
 }
예제 #4
0
 /// <summary>
 /// Logs the error.
 /// </summary>
 /// <param name="error">The error.</param>
 /// <param name="component">The component.</param>
 /// <returns></returns>
 public static bool LogError(string error, CallingMethod component)
 {
     return(LogError(error, component, string.Empty));
 }