Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Merge pull request #22 from getsentry/ref/log-entry
Browse files Browse the repository at this point in the history
ref: rename StructuredMessage to standard: logEntry
  • Loading branch information
bruno-garcia authored Oct 12, 2018
2 parents 912fd8b + c63ed59 commit 558bf9b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Sentry.Protocol
/// </example>
/// <seealso href="https://docs.sentry.io/clientdev/interfaces/message/"/>
[DataContract]
public class SentryMessage
public class LogEntry
{
/// <summary>
/// The raw message string (uninterpolated)
Expand Down
10 changes: 9 additions & 1 deletion src/Sentry.Protocol/SentryEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,16 @@ public class SentryEvent : BaseScope
/// <summary>
/// Gets the structured message that describes this event
/// </summary>
/// <remarks>
/// This helps Sentry group events together as the grouping happens
/// on the template message instead of the result string message.
/// </remarks>
/// <example>
/// LogEntry will have a template like: 'user {0} logged in'
/// Or structured logging template '{user} has logged in'
/// </example>
[DataMember(Name = "logentry", EmitDefaultValue = false)]
public SentryMessage StructuredMessage { get; set; }
public LogEntry LogEntry { get; set; }

/// <summary>
/// Name of the logger (or source) of the event
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

namespace Sentry.Protocol.Tests
{
public class SentryMessageTests
public class LogEntryTests
{
[Fact]
public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
{
var sut = new SentryMessage
var sut = new LogEntry
{
Message = "Message {eventId} {name}",
Params = new object[] { 100, "test-name" },
Expand All @@ -25,7 +25,7 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()

[Theory]
[MemberData(nameof(TestCases))]
public void SerializeObject_TestCase_SerializesAsExpected((SentryMessage msg, string serialized) @case)
public void SerializeObject_TestCase_SerializesAsExpected((LogEntry msg, string serialized) @case)
{
var actual = JsonSerializer.SerializeObject(@case.msg);

Expand All @@ -34,10 +34,10 @@ public void SerializeObject_TestCase_SerializesAsExpected((SentryMessage msg, st

public static IEnumerable<object[]> TestCases()
{
yield return new object[] { (new SentryMessage(), "{}") };
yield return new object[] { (new SentryMessage { Message = "some message" }, "{\"message\":\"some message\"}") };
yield return new object[] { (new SentryMessage { Params = new[] { "param" } }, "{\"params\":[\"param\"]}") };
yield return new object[] { (new SentryMessage { Formatted = "some formatted" }, "{\"formatted\":\"some formatted\"}") };
yield return new object[] { (new LogEntry(), "{}") };
yield return new object[] { (new LogEntry { Message = "some message" }, "{\"message\":\"some message\"}") };
yield return new object[] { (new LogEntry { Params = new[] { "param" } }, "{\"params\":[\"param\"]}") };
yield return new object[] { (new LogEntry { Formatted = "some formatted" }, "{\"formatted\":\"some formatted\"}") };
}
}
}
2 changes: 1 addition & 1 deletion test/Sentry.Protocol.Tests/SentryEventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
Level = SentryLevel.Fatal,
Logger = "logger",
Message = "message",
StructuredMessage = new SentryMessage
LogEntry = new LogEntry
{
Message = "structured_message"
},
Expand Down

0 comments on commit 558bf9b

Please sign in to comment.