Skip to content

Commit 1c1d8ad

Browse files
#63 Add support of NLogFileConsumer
1 parent 8ec8b9b commit 1c1d8ad

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/Atata.Configuration.Json/Mapping/JsonConfigMapper.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Reflection;
45

@@ -148,7 +149,24 @@ private static void MapLogConsumer(LogConsumerJsonSection section, AtataContextB
148149
if (section.MessageEndSectionPrefix != null)
149150
consumerBuilder.WithMessageEndSectionPrefix(section.MessageEndSectionPrefix);
150151

151-
consumerBuilder.WithProperties(section.ExtraPropertiesMap);
152+
if (consumerBuilder.Context is NLogFileConsumer nLogFileConsumer)
153+
ConfigureNLogFileConsumer(nLogFileConsumer, section.ExtraPropertiesMap);
154+
else
155+
consumerBuilder.WithProperties(section.ExtraPropertiesMap);
156+
}
157+
158+
// TODO: Remove this method when NLogFileConsumer will get string path/name properties.
159+
private static void ConfigureNLogFileConsumer(NLogFileConsumer consumer, Dictionary<string, object> propertiesMap)
160+
{
161+
foreach (var item in propertiesMap)
162+
{
163+
if (item.Key.Equals("FolderPath", StringComparison.OrdinalIgnoreCase))
164+
consumer.FolderPathBuilder = _ => item.Value.ToString();
165+
else if (item.Key.Equals("FileName", StringComparison.OrdinalIgnoreCase))
166+
consumer.FileNameBuilder = _ => item.Value.ToString();
167+
else if (item.Key.Equals("FilePath", StringComparison.OrdinalIgnoreCase))
168+
consumer.FilePathBuilder = _ => item.Value.ToString();
169+
}
152170
}
153171

154172
private static void MapScreenshotConsumer(ScreenshotConsumerJsonSection section, AtataContextBuilder builder)

0 commit comments

Comments
 (0)