From 7cb48d68bb58d9bc48a4a84d805ae347c82cfae1 Mon Sep 17 00:00:00 2001 From: Cijo Thomas Date: Thu, 29 Jul 2021 10:20:29 -0700 Subject: [PATCH] changelog fix --- src/OpenTelemetry/CHANGELOG.md | 4 ++-- src/OpenTelemetry/Logs/OpenTelemetryLogger.cs | 11 +---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/OpenTelemetry/CHANGELOG.md b/src/OpenTelemetry/CHANGELOG.md index 08959440bcc..89595afcbd8 100644 --- a/src/OpenTelemetry/CHANGELOG.md +++ b/src/OpenTelemetry/CHANGELOG.md @@ -5,8 +5,8 @@ * Removes upper constraint for Microsoft.Extensions.Logging dependencies. ([#2179](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2179)) -* Fix bug which caused ILogger.Log calls to throw exception, when the - formatter supplied is null. +* OpenTelemetryLogger modified to not throw, when the + formatter supplied in ILogger.Log call is null. ([#2200](https://github.com/open-telemetry/opentelemetry-dotnet/pull/2200)) ## 1.2.0-alpha1 diff --git a/src/OpenTelemetry/Logs/OpenTelemetryLogger.cs b/src/OpenTelemetry/Logs/OpenTelemetryLogger.cs index af179d78a9a..11ca152d64a 100644 --- a/src/OpenTelemetry/Logs/OpenTelemetryLogger.cs +++ b/src/OpenTelemetry/Logs/OpenTelemetryLogger.cs @@ -47,22 +47,13 @@ public void Log(LogLevel logLevel, EventId eventId, TState state, Except { var options = this.provider.Options; - string formattedMessage = null; - if (options.IncludeFormattedMessage) - { - if (formatter != null) - { - formattedMessage = formatter(state, exception); - } - } - var record = new LogRecord( options.IncludeScopes ? this.ScopeProvider : null, DateTime.UtcNow, this.categoryName, logLevel, eventId, - formattedMessage, + options.IncludeFormattedMessage ? formatter?.Invoke(state, exception) : null, options.ParseStateValues ? null : (object)state, exception, options.ParseStateValues ? this.ParseState(state) : null);