-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added stringification support #160
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thanks for spotting this gap! Just had one comment.
@@ -78,6 +78,11 @@ public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Except | |||
if (logger.BindProperty(property.Key.Substring(1), property.Value, true, out var destructured)) | |||
properties.Add(destructured); | |||
} | |||
else if (property.Key.StartsWith("$")) | |||
{ | |||
if (logger.BindProperty(property.Key.Substring(1), property.Value?.ToString() ?? "null", true, out var stringified)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Substituting in the text null
will be inconsistent with Serilog here, I think. We should just pass null if property.Value
is null.
@jonnybi hi! I just spotted one more place where we special-case |
@nblumhardt thx for spotting this. i will check it |
@@ -78,6 +78,11 @@ public void EnrichAndCreateScopeItem(LogEvent logEvent, ILogEventPropertyFactory | |||
destructureObject = true; | |||
} | |||
|
|||
if (key.StartsWith("$")) | |||
{ | |||
key = key.Substring(1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value would also have to be ToString()
ed in order for this to take effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sry, i was a little too fast. Fixed it again and added a unit test.
Thanks! 👍 |
Added "force stringification" support as described in serilog documentation.