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)); }
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); }
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); }
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)); }
/// <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)); }
/// <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); }
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); }
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)); }
/// <summary> /// Creates a new instance of /// <see cref="JsonPacket" /> for the specified /// <paramref name="project" />, with the /// given /// <paramref name="exception" />. /// </summary> /// <param name="project">The project.</param> /// <param name="exception">The <see cref="Exception" /> to capture.</param> /// <param name="message">The optional message 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="fingerprint">The custom fingerprint to annotate the captured <paramref name="message" /> with.</param> /// <param name="extra">The extra metadata to send with the captured <paramref name="exception" />.</param> /// <returns> /// A new instance of /// <see cref="JsonPacket" /> for the specified /// <paramref name="project" />, with the /// given /// <paramref name="exception" />. /// </returns> 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 json = new JsonPacket(project, exception) { Message = message != null?message.ToString() : exception.Message, MessageObject = message, Level = level, Tags = tags, Fingerprint = fingerprint, Extra = Merge(extra, exception) }; return(OnCreate(json)); }
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); }
public void ToString_ReturnsMessage() { string stringMessage = Guid.NewGuid().ToString("N"); SentryMessage message = new SentryMessage(stringMessage); Assert.That(message.ToString(), Is.EqualTo(stringMessage)); }
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); }
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); }
/// <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); }
/// <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; }
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)); }
/// <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); }
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); }
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"))); }
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); }
public void Message_IsImplicitlyConvertedTo_String() { string message = new SentryMessage("Hello"); Assert.That(message, Is.EqualTo("Hello")); }