Skip to content

Commit 2cb8d66

Browse files
authored
LTTngDriver - Fix CSV commas and FieldNames not being outputted properly (#14)
* LTTngDriver - Fix CSV comma not being output properly along with fieldnames as well
1 parent f9af8f9 commit 2cb8d66

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

LTTngDriver/Program.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// Licensed under the MIT License.
33

44
using System;
5+
using System.Collections;
56
using System.Collections.Generic;
67
using System.Diagnostics;
78
using System.Globalization;
@@ -40,6 +41,8 @@ public bool Run()
4041
// adding inputs.
4142
//
4243

44+
Console.WriteLine($"ExtensionDirectory:{parsed.ExtensionDirectory}");
45+
4346
var runtime = Engine.Create(
4447
new EngineCreateInfo
4548
{
@@ -50,6 +53,7 @@ public bool Run()
5053
Debug.Assert(parsed.CtfInput.Count > 0);
5154
foreach (var ctf in parsed.CtfInput.Distinct())
5255
{
56+
Console.WriteLine($"CTF Path:{ctf}");
5357
runtime.AddFile(ctf);
5458
}
5559

@@ -169,9 +173,12 @@ private static void EmitEvents(
169173
{
170174
output.Write(',');
171175
}
176+
else
177+
{
178+
first = false;
179+
}
172180

173181
output.Write(p.Name);
174-
first = false;
175182
}
176183

177184
for (var i = 0; i < maxNumFields; ++i)
@@ -190,9 +197,34 @@ private static void EmitEvents(
190197
{
191198
output.Write(',');
192199
}
200+
else
201+
{
202+
first = false;
203+
}
193204

194205
var v = p.GetValue(e);
195-
output.Write(v);
206+
207+
if (p.Name == "FieldNames" && v is IEnumerable)
208+
{
209+
var list = v as IList;
210+
var firstli = true;
211+
foreach (var li in list)
212+
{
213+
if (!firstli)
214+
{
215+
output.Write(';');
216+
}
217+
else
218+
{
219+
firstli = false;
220+
}
221+
output.Write(li);
222+
}
223+
}
224+
else
225+
{
226+
output.Write(v);
227+
}
196228
}
197229

198230
Debug.Assert(e.FieldNames.Count <= maxNumFields);

0 commit comments

Comments
 (0)