Esempio n. 1
0
        public override string Log(Error error)
        {
            if (_session == null)
            {
                return(Guid.NewGuid().ToString());
            }
            var log = new Log
            {
                Error   = BinaryData.CanSerialize(error) ? error : new Error(),
                Message = error.Message,
                Detail  = error.Detail,
                Site    = _session.Get <Site>(CurrentRequestData.CurrentSite.Id)
            };

            _session.Transact(session => session.Save(log));

            var siteSettings = CurrentRequestData.SiteSettings;

            if (!string.IsNullOrWhiteSpace(siteSettings?.RaygunAPIKey))
            {
                var raygunClient = new RaygunClient(siteSettings.RaygunAPIKey);

                var exception = error.Exception;
                if (!(exception is HttpException httpException) || !siteSettings.RaygunExcludedStatusCodeCollection.Contains(httpException.GetHttpCode()))
                {
                    raygunClient.SendInBackground(exception);
                }
            }

            return(log.Guid.ToString());
        }
        public override string Log(Error error)
        {
            if (_session == null)
            {
                return(Guid.NewGuid().ToString());
            }
            var log = new Log
            {
                Error   = BinaryData.CanSerialize(error) ? error : new Error(),
                Message = error.Message,
                Detail  = error.Detail,
                Site    = _session.Get <Site>(CurrentRequestData.CurrentSite.Id)
            };

            _session.Transact(session => session.Save(log));
            return(log.Guid.ToString());
        }