-
Notifications
You must be signed in to change notification settings - Fork 854
[sdk-logs] Update LogRecord for Logger API additions #4456
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -65,11 +65,12 @@ internal LogRecord( | |
| Body = formattedMessage, | ||
| }; | ||
|
|
||
| OpenTelemetryLogger.SetLogRecordSeverityFields(ref this.Data, logLevel); | ||
|
|
||
| this.ILoggerData = new() | ||
| { | ||
| TraceState = activity?.TraceStateString, | ||
| CategoryName = categoryName, | ||
| LogLevel = logLevel, | ||
| FormattedMessage = formattedMessage, | ||
| EventId = eventId, | ||
| Exception = exception, | ||
|
|
@@ -156,10 +157,24 @@ public string? CategoryName | |
| /// <summary> | ||
| /// Gets or sets the log <see cref="Microsoft.Extensions.Logging.LogLevel"/>. | ||
| /// </summary> | ||
| // todo: [Obsolete("Use Severity instead LogLevel will be removed in a future version.")] | ||
| public LogLevel LogLevel | ||
| { | ||
| get => this.ILoggerData.LogLevel; | ||
| set => this.ILoggerData.LogLevel = value; | ||
| get | ||
| { | ||
| if (!this.Data.Severity.HasValue) | ||
| { | ||
| return LogLevel.Trace; | ||
| } | ||
|
|
||
| uint severity = (uint)this.Data.Severity.Value; | ||
| return (LogLevel)((severity - 1) / 4); | ||
| } | ||
|
|
||
| set | ||
| { | ||
| OpenTelemetryLogger.SetLogRecordSeverityFields(ref this.Data, value); | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -247,6 +262,30 @@ public Exception? Exception | |
| set => this.ILoggerData.Exception = value; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the original string representation of the severity as it is | ||
| /// known at the source. | ||
| /// </summary> | ||
| internal string? SeverityText | ||
| { | ||
| get => this.Data.SeverityText; | ||
| set => this.Data.SeverityText = value; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the log <see cref="LogRecordSeverity"/>. | ||
| /// </summary> | ||
| internal LogRecordSeverity? Severity | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nullable or just Unspecified?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok leaving this for now. Good question though.. I think we should opt for one or the other: nullable or |
||
| { | ||
| get => this.Data.Severity; | ||
| set => this.Data.Severity = value; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets or sets the <see cref="Logs.Logger"/> which emitted the <see cref="LogRecord"/>. | ||
| /// </summary> | ||
| internal Logger? Logger { get; /*todo: internal*/ set; } | ||
|
|
||
| /// <summary> | ||
| /// Executes callback for each currently active scope objects in order | ||
| /// of creation. All callbacks are guaranteed to be called inline from | ||
|
|
@@ -378,7 +417,6 @@ internal struct LogRecordILoggerData | |
| public string? TraceState; | ||
| public string? CategoryName; | ||
| public EventId EventId; | ||
| public LogLevel LogLevel; | ||
| public string? FormattedMessage; | ||
| public Exception? Exception; | ||
| public object? State; | ||
|
|
@@ -392,7 +430,6 @@ public LogRecordILoggerData Copy() | |
| TraceState = this.TraceState, | ||
| CategoryName = this.CategoryName, | ||
| EventId = this.EventId, | ||
| LogLevel = this.LogLevel, | ||
| FormattedMessage = this.FormattedMessage, | ||
| Exception = this.Exception, | ||
| State = this.State, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.