Skip to content

Commit

Permalink
Fix event name logic + support null categoryname. (#3359)
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch authored Jun 13, 2022
1 parent a80f1f2 commit 8b1521f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/OpenTelemetry.Exporter.Console/ConsoleLogRecordExporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public override ExportResult Export(in Batch<LogRecord> batch)
this.WriteLine($"{"LogRecord.TraceFlags:",-RightPaddingLength}{logRecord.TraceFlags}");
}

this.WriteLine($"{"LogRecord.CategoryName:",-RightPaddingLength}{logRecord.CategoryName}");
if (logRecord.CategoryName != null)
{
this.WriteLine($"{"LogRecord.CategoryName:",-RightPaddingLength}{logRecord.CategoryName}");
}

this.WriteLine($"{"LogRecord.LogLevel:",-RightPaddingLength}{logRecord.LogLevel}");

if (logRecord.FormattedMessage != null)
Expand Down Expand Up @@ -76,13 +80,13 @@ public override ExportResult Export(in Batch<LogRecord> batch)
if (logRecord.EventId != default)
{
this.WriteLine($"{"LogRecord.EventId:",-RightPaddingLength}{logRecord.EventId.Id}");
if (string.IsNullOrEmpty(logRecord.EventId.Name))
if (!string.IsNullOrEmpty(logRecord.EventId.Name))
{
this.WriteLine($"{"LogRecord.EventName:",-RightPaddingLength}{logRecord.EventId.Name}");
}
}

if (logRecord.Exception is { })
if (logRecord.Exception != null)
{
this.WriteLine($"{"LogRecord.Exception:",-RightPaddingLength}{logRecord.Exception?.Message}");
}
Expand Down

0 comments on commit 8b1521f

Please sign in to comment.