ConsoleLogRecordExporter modified to support Message and StateValues (#1871)

* ConsoleLogRecordExporter modified to support Message and StateValues

* slighty better printing
This commit is contained in:
Cijo Thomas 2021-03-08 08:28:15 -08:00 committed by GitHub
parent 21c440a284
commit f2524286d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -11,6 +11,7 @@ please check the latest changes
* Removed code that prints Baggage information
([#1825](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1825))
* LogRecordExporter exports Message and StateValues from LogRecord.
## 1.0.1

View File

@ -39,7 +39,24 @@ namespace OpenTelemetry.Exporter
this.WriteLine($"{"LogRecord.CategoryName:".PadRight(rightPaddingLength)}{logRecord.CategoryName}");
this.WriteLine($"{"LogRecord.LogLevel:".PadRight(rightPaddingLength)}{logRecord.LogLevel}");
this.WriteLine($"{"LogRecord.TraceFlags:".PadRight(rightPaddingLength)}{logRecord.TraceFlags}");
this.WriteLine($"{"LogRecord.State:".PadRight(rightPaddingLength)}{logRecord.State}");
if (logRecord.Message != null)
{
this.WriteLine($"{"LogRecord.Message:".PadRight(rightPaddingLength)}{logRecord.Message}");
}
if (logRecord.State != null)
{
this.WriteLine($"{"LogRecord.State:".PadRight(rightPaddingLength)}{logRecord.State}");
}
else if (logRecord.StateValues != null)
{
this.WriteLine("LogRecord.StateValues (Key:Value):");
for (int i = 0; i < logRecord.StateValues.Count; i++)
{
this.WriteLine($"{logRecord.StateValues[i].Key.PadRight(rightPaddingLength)}{logRecord.StateValues[i].Value}");
}
}
if (logRecord.Exception is { })
{
this.WriteLine($"{"LogRecord.Exception:".PadRight(rightPaddingLength)}{logRecord.Exception?.Message}");