Captures a string message, optionally formatted with arguments, as sent to Sentry.
コード例 #1
0
        public void Message_ReturnsMessage()
        {
            const string format = "Format something {0:N} in here";
            var arg = Guid.NewGuid();
            SentryMessage message = new SentryMessage(format, arg);

            Assert.That(message.Message, Is.EqualTo(format));
        }
コード例 #2
0
ファイル: CaptureTests.cs プロジェクト: rowandh/raven-csharp
        public void CaptureException_WithMessageFormat_ReturnsValidID()
        {
            object[] args = Enumerable.Range(0, 5).Select(i => Guid.NewGuid()).Cast<object>().ToArray();
            var message = new SentryMessage("A {0:N} B {1:N} C {2:N} D {3:N} F {4:N}.", args);
            var id = this.ravenClient.CaptureException(new Exception("Test without a stacktrace."), message);
            //Console.WriteLine("Sent packet: " + id);

            Assert.That(id, Is.Not.Null.Or.Empty);
            Assert.That(Guid.Parse(id), Is.Not.Null);
        }
コード例 #3
0
        public JsonPacket Create(string project,
            SentryMessage message,
            ErrorLevel level = ErrorLevel.Info,
            IDictionary<string, string> tags = null,
            string[] fingerprint = null,
            object extra = null)
        {
            var @event = new SentryEvent(message)
            {
                Level = level,
                Extra = extra,
                Tags = tags,
                Fingerprint = fingerprint
            };

            return Create(project, @event);
        }
コード例 #4
0
        /// <summary>
        /// Creates a new instance of
        /// <see cref="JsonPacket" /> for the specified
        /// <paramref name="project" />.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="message">The message to capture.</param>
        /// <param name="level">The <see cref="ErrorLevel" /> of the captured <paramref name="message" />. Default <see cref="ErrorLevel.Info" />.</param>
        /// <param name="tags">The tags to annotate the captured <paramref name="message" /> with.</param>
        /// <param name="extra">The extra metadata to send with the captured <paramref name="message" />.</param>
        /// <returns>
        /// A new instance of <see cref="JsonPacket" /> for the specified <paramref name="project" />.
        /// </returns>
        public JsonPacket Create(string project,
                                 SentryMessage message,
                                 ErrorLevel level = ErrorLevel.Info,
                                 IDictionary<string, string> tags = null,
                                 object extra = null)
        {
            var json = new JsonPacket(project)
            {
                Message = message != null ? message.ToString() : null,
                MessageObject = message,
                Level = level,
                Tags = tags,
                Extra = extra
            };

            return OnCreate(json);
        }
コード例 #5
0
        public async Task<string> CaptureExceptionAsync(Exception exception,
                                                        SentryMessage message = null,
                                                        ErrorLevel level = ErrorLevel.Error,
                                                        IDictionary<string, string> tags = null,
                                                        string[] fingerprint = null,
                                                        object extra = null)
        {
            var @event = new SentryEvent(exception)
            {
                Message = message,
                Level = level,
                Extra = extra,
                Tags = tags,
                Fingerprint = fingerprint
            };

            return await CaptureAsync(@event);
        }
コード例 #6
0
ファイル: RavenClient.cs プロジェクト: getsentry/raven-csharp
        public string CaptureMessage(SentryMessage message,
            ErrorLevel level = ErrorLevel.Info,
            IDictionary<string, string> tags = null,
            string[] fingerprint = null,
            object extra = null)
        {
            var @event = new SentryEvent(message)
            {
                Level = level,
                Extra = extra,
                Tags = MergeTags(tags),
                Fingerprint = fingerprint
            };

            return Capture(@event);
        }
コード例 #7
0
ファイル: RavenClient.cs プロジェクト: getsentry/raven-csharp
        public string CaptureException(Exception exception,
            SentryMessage message = null,
            ErrorLevel level = ErrorLevel.Error,
            IDictionary<string, string> tags = null,
            string[] fingerprint = null,
            object extra = null)
        {
            var @event = new SentryEvent(exception)
            {
                Message = message,
                Level = level,
                Extra = extra,
                Tags = MergeTags(tags),
                Fingerprint = fingerprint
            };

            return Capture(@event);
        }
コード例 #8
0
        public void Parameters_ReturnsParameters()
        {
            const string format = "Format something {0:N} in here";
            var arg = Guid.NewGuid();
            SentryMessage message = new SentryMessage(format, arg);

            Assert.That(message.Parameters, Has.Length.EqualTo(1));
            Assert.That(message.Parameters[0], Is.EqualTo(arg));
        }
コード例 #9
0
        public void Message_IsImplicitlyConvertedTo_String()
        {
            string message = new SentryMessage("Hello");

            Assert.That(message, Is.EqualTo("Hello"));
        }
コード例 #10
0
        public void ToString_ReturnsFormattedString()
        {
            Guid arg = Guid.NewGuid();
            SentryMessage message = new SentryMessage("Format something {0:N} in here", arg);

            Assert.That(message.ToString(), Is.StringContaining(arg.ToString("N")));
        }
コード例 #11
0
        public JsonPacket Create(string project,
            Exception exception,
            SentryMessage message = null,
            ErrorLevel level = ErrorLevel.Error,
            IDictionary<string, string> tags = null,
            string[] fingerprint = null,
            object extra = null)
        {
            var @event = new SentryEvent(exception)
            {
                Message = message,
                Level = level,
                Extra = extra,
                Tags = tags,
                Fingerprint = fingerprint,
            };

            return Create(project, @event);
        }
コード例 #12
0
ファイル: RavenClient.cs プロジェクト: rowandh/raven-csharp
 /// <summary>
 /// Captures the message.
 /// </summary>
 /// <param name="message">The message to capture.</param>
 /// <param name="level">The <see cref="ErrorLevel" /> of the captured <paramref name="message" />. Default <see cref="ErrorLevel.Info" />.</param>
 /// <param name="tags">The tags to annotate the captured <paramref name="message" /> with.</param>
 /// <param name="extra">The extra metadata to send with the captured <paramref name="message" />.</param>
 /// <returns>
 /// The <see cref="JsonPacket.EventID" /> of the successfully captured <paramref name="message" />, or <c>null</c> if it fails.
 /// </returns>
 public string CaptureMessage(SentryMessage message,
     ErrorLevel level = ErrorLevel.Info,
     Dictionary<string, string> tags = null,
     object extra = null)
 {
     JsonPacket packet = this.jsonPacketFactory.Create(CurrentDsn.ProjectID, message, level, tags, extra);
     return Send(packet, CurrentDsn);
 }
コード例 #13
0
ファイル: RavenClient.cs プロジェクト: rowandh/raven-csharp
 /// <summary>
 /// Captures the <see cref="Exception" />.
 /// </summary>
 /// <param name="exception">The <see cref="Exception" /> to capture.</param>
 /// <param name="message">The optional messge to capture. Default: <see cref="Exception.Message" />.</param>
 /// <param name="level">The <see cref="ErrorLevel" /> of the captured <paramref name="exception" />. Default: <see cref="ErrorLevel.Error" />.</param>
 /// <param name="tags">The tags to annotate the captured <paramref name="exception" /> with.</param>
 /// <param name="extra">The extra metadata to send with the captured <paramref name="exception" />.</param>
 /// <returns>
 /// The <see cref="JsonPacket.EventID" /> of the successfully captured <paramref name="exception" />, or <c>null</c> if it fails.
 /// </returns>
 public string CaptureException(Exception exception,
     SentryMessage message = null,
     ErrorLevel level = ErrorLevel.Error,
     IDictionary<string, string> tags = null,
     object extra = null)
 {
     JsonPacket packet = this.jsonPacketFactory.Create(this.currentDsn.ProjectID,
                                                       exception,
                                                       message,
                                                       level,
                                                       tags,
                                                       extra);
     return Send(packet, CurrentDsn);
 }
コード例 #14
0
ファイル: SentryEvent.cs プロジェクト: getsentry/raven-csharp
 /// <summary>Initializes a new instance of the <see cref="SentryEvent"/> class.</summary>
 /// <param name="message">The message to capture.</param>
 public SentryEvent(SentryMessage message)
     : this()
 {
     Message = message;
 }
コード例 #15
0
        public void ToString_ReturnsMessage()
        {
            string stringMessage = Guid.NewGuid().ToString("N");
            SentryMessage message = new SentryMessage(stringMessage);

            Assert.That(message.ToString(), Is.EqualTo(stringMessage));
        }
コード例 #16
0
        public void CaptureMessage_WithFormat_ReturnsValidID()
        {
            object[] args = Enumerable.Range(0, 5).Select(i => Guid.NewGuid()).Cast<object>().ToArray();
            var message = new SentryMessage("Lorem %s ipsum %s dolor %s sit %s amet %s.", args);
            var id = this.ravenClient.CaptureMessage(message);
            //Console.WriteLine("Sent packet: " + id);

            Assert.That(id, Is.Not.Null);
            Assert.That(Guid.Parse(id), Is.Not.Null);
        }
コード例 #17
0
        public async Task<string> CaptureMessageAsync(SentryMessage message,
                                                      ErrorLevel level = ErrorLevel.Info,
                                                      IDictionary<string, string> tags = null,
                                                      string[] fingerprint = null,
                                                      object extra = null)
        {
            var @event = new SentryEvent(message)
            {
                Level = level,
                Extra = extra,
                Tags = tags,
                Fingerprint = fingerprint
            };

            return await CaptureAsync(@event);
        }