Exemplo n.º 1
0
        private static Guid?SendBody(Body body, ErrorLevel?level, IDictionary <string, object> custom)
        {
            if (string.IsNullOrWhiteSpace(_config.AccessToken) || _config.Enabled == false)
            {
                return(null);
            }

            var guid = Guid.NewGuid();

            var client = new RollbarClient(_config);
            var data   = new Data(_config.Environment, body)
            {
                Custom = custom,
                Level  = level ?? _config.LogLevel
            };

            var payload = new Payload(_config.AccessToken, data);

            payload.Data.GuidUuid = guid;
            payload.Data.Person   = _personFunc?.Invoke();

            _config.Transform?.Invoke(payload);
            client.PostItem(payload);

            return(guid);
        }
        static async Task <Guid?> SendBodyAsync(Payload payload)
        {
            var client = new RollbarClient(_config);
            await client.PostItemAsync(payload);

            return(payload.Data.GuidUuid);
        }
Exemplo n.º 3
0
 public Rollbar(IEnumerable <IBuilder> builders,
                IEnumerable <IExceptionBuilder> exceptionBuilders,
                RollbarClient rollbarClient)
 {
     this.Builders          = builders;
     this.ExceptionBuilders = exceptionBuilders;
     this.RollbarClient     = rollbarClient;
 }
        static Guid?SendBody(Payload payload)
        {
            var client = new RollbarClient(_config);

            client.PostItem(payload);

            return(payload.Data.GuidUuid);
        }
Exemplo n.º 5
0
        public virtual async Task <Response> SendMessage(RollbarLevel level, string message)
        {
            var payload = SetupPayload(level);

            payload.Data.Body.Message = new Message
            {
                Body = message
            };
            return(await RollbarClient.Send(payload));
        }
Exemplo n.º 6
0
        public virtual async Task <Response> SendException(RollbarLevel level, Exception exception, string message)
        {
            if (SentExceptions.ContainsKey(exception))
            {
                return(SentExceptions[exception]);
            }

            var payload = SetupPayload(level);

            foreach (var exceptionBuilder in ExceptionBuilders)
            {
                exceptionBuilder.Execute(payload, exception);
            }

            payload.Data.Title = message;
            var response = await RollbarClient.Send(payload);

            SentExceptions.Add(exception, response);
            return(response);
        }