Skip to content

Commit 04f35ef

Browse files
authored
Using a new private Write method to write to Console or Debug (#1618)
1 parent 2785ffb commit 04f35ef

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

src/OpenTelemetry.Exporter.Console/ConsoleExporter.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,12 @@ public override ExportResult Export(in Batch<T> batch)
6464
continue;
6565
}
6666

67-
Console.Write($" {tag.Key}: [");
67+
this.Write($" {tag.Key}: [");
6868

6969
for (int i = 0; i < array.Length; i++)
7070
{
71-
Console.Write(i != 0 ? ", " : string.Empty);
72-
Console.Write($"{array.GetValue(i)}");
71+
this.Write(i != 0 ? ", " : string.Empty);
72+
this.Write($"{array.GetValue(i)}");
7373
}
7474

7575
this.WriteLine($"]");
@@ -151,5 +151,18 @@ private void WriteLine(string message)
151151
Debug.WriteLine(message);
152152
}
153153
}
154+
155+
private void Write(string message)
156+
{
157+
if (this.options.Targets.HasFlag(ConsoleExporterOutputTargets.Console))
158+
{
159+
Console.Write(message);
160+
}
161+
162+
if (this.options.Targets.HasFlag(ConsoleExporterOutputTargets.Debug))
163+
{
164+
Debug.Write(message);
165+
}
166+
}
154167
}
155168
}

0 commit comments

Comments
 (0)