Exemple #1
0
        /// <inheritdoc/>
        public void Log(Exception e)
        {
            RealmExceptionReport report = new RealmExceptionReport
            {
                Uid              = Guid.NewGuid().ToString(),
                ExceptionType    = e.GetType().ToString(),
                HResult          = e.HResult,
                Message          = e.Message,
                NativeStackTrace = e.StackTrace,
                StackTrace       = e.Demystify().StackTrace,
                AppVersion       = (BigWatson.VersionParser?.Invoke() ??
                                    (Assembly.GetEntryAssembly() ?? Assembly.GetCallingAssembly()).GetName().Version).ToString(),
                UsedMemory = BigWatson.MemoryParser?.Invoke() ?? Process.GetCurrentProcess().PrivateMemorySize64,
                Timestamp  = DateTimeOffset.Now
            };

            Log(report);
        }
        internal ExceptionReport(
            [NotNull] RealmExceptionReport report,
            [NotNull] string min, [NotNull] string max, int occurrences,
            DateTimeOffset recent, DateTimeOffset old)
            : base(report.Timestamp.LocalDateTime, Version.Parse(report.AppVersion))
        {
            // Primary
            ExceptionType    = report.ExceptionType;
            HResult          = report.HResult;
            Message          = report.Message ?? string.Empty;
            Source           = report.Source ?? string.Empty;
            StackTrace       = report.StackTrace ?? string.Empty;
            NativeStackTrace = report.NativeStackTrace ?? string.Empty;
            UsedMemory       = report.UsedMemory;

            // Secondary
            MinExceptionVersion       = Version.Parse(min);
            MaxExceptionVersion       = Version.Parse(max);
            ExceptionTypeOccurrencies = occurrences;
            MostRecentCrashTime       = recent.LocalDateTime;
            LeastRecentCrashTime      = old.LocalDateTime;
        }