Skip to content

Commit e61b08b

Browse files
committed
Implemented VTEX own concept of Splunk log entry
#9
1 parent 014837b commit e61b08b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace VTEX.SampleWebAPI.Logging
5+
{
6+
public class VTEXSplunkEntry
7+
{
8+
public string WorkflowType { get; private set; }
9+
public string WorkflowInstance { get; private set; }
10+
public string Account { get; private set; }
11+
public Exception Exception { get; private set; }
12+
public List<Tuple<string, string>> ExtraParameters { get; private set; }
13+
14+
public VTEXSplunkEntry(string workflowType, string workflowInstance, string account = "", Exception exception = null, params Tuple<string, string>[] extraParameters)
15+
{
16+
if (string.IsNullOrWhiteSpace(workflowType))
17+
throw new ArgumentNullException(nameof(workflowType));
18+
19+
if (string.IsNullOrWhiteSpace(workflowInstance))
20+
throw new ArgumentNullException(nameof(workflowInstance));
21+
22+
ExtraParameters = new List<Tuple<string, string>>(extraParameters);
23+
WorkflowType = workflowType;
24+
WorkflowInstance = workflowInstance;
25+
Account = account;
26+
Exception = exception;
27+
28+
if (exception != null)
29+
{
30+
ExtraParameters.Add(new Tuple<string, string>("exception_type", exception.GetType().FullName));
31+
ExtraParameters.Add(new Tuple<string, string>("exception_message", exception.Message));
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)