-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCLogDecodedTraceLine.cs
More file actions
159 lines (124 loc) · 4.98 KB
/
CLogDecodedTraceLine.cs
File metadata and controls
159 lines (124 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*++
Copyright (c) Microsoft Corporation.
Licensed under the MIT License.
Abstract:
Represents one trace line, containing one event. It's created during compilation and stored within a side car for future presentation
--*/
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using clogutils.ConfigFile;
using clogutils.MacroDefinations;
using Newtonsoft.Json;
namespace clogutils
{
[JsonObject(MemberSerialization.OptIn)]
public class CLogDecodedTraceLine
{
[JsonProperty] public Dictionary<string, Dictionary<string, string>> ModuleProperites = new Dictionary<string, Dictionary<string, string>>();
public CLogDecodedTraceLine(string uniqueId, string sourceFile, string userString, string userStringNoPrefix, CLogLineMatch m, CLogConfigurationFile c,
CLogTraceMacroDefination mac, CLogFileProcessor.CLogVariableBundle[] args, CLogFileProcessor.DecomposedString decompString)
{
SourceFile = sourceFile;
macro = mac;
UniqueId = uniqueId;
match = m;
configFile = c;
TraceString = userString;
splitArgs = args;
TraceStringNoPrefix = userStringNoPrefix;
DecomposedString = decompString;
}
[JsonProperty]
public string TraceString { get; private set; }
public CLogFileProcessor.DecomposedString DecomposedString;
public string CleanedString { get { return DecomposedString.AsManifestedETWEncoding; } }
public string TraceStringNoPrefix { get; private set; }
[JsonProperty]
public string UniqueId { get; private set; }
public CLogConfigurationFile configFile { get; private set; }
[JsonProperty]
public CLogFileProcessor.CLogVariableBundle[] splitArgs { get; private set; }
private CLogFileProcessor.CLogVariableBundle[] _tempArgs;
[OnSerializing]
internal void OnSerializingMethod(StreamingContext context)
{
List<CLogFileProcessor.CLogVariableBundle> tArgs = new List<CLogFileProcessor.CLogVariableBundle>();
foreach (var a in splitArgs)
{
if (!string.IsNullOrEmpty(a.DefinationEncoding))
tArgs.Add(a);
}
_tempArgs = splitArgs;
splitArgs = tArgs.ToArray();
}
[OnSerialized]
internal void OnSerializedMethod(StreamingContext context)
{
splitArgs = _tempArgs;
}
//[JsonProperty]
public CLogTraceMacroDefination macro { get; private set; }
private string _macroName;
[JsonProperty]
public string macroName
{
get
{
if (null != macro && !string.IsNullOrEmpty(macro.MacroName))
return macro.MacroName;
return _macroName;
}
set
{
_macroName = value;
}
}
public CLogConfigurationProfile GetMacroConfigurationProfile()
{
return configFile.MacroConfigurations[macro.MacroConfiguration[configFile.ProfileName]];
}
public string GetConfigurationValue(string moduleName, string key)
{
string ret;
if (null != macro.CustomSettings && macro.CustomSettings.ContainsKey(moduleName))
{
if (macro.CustomSettings[moduleName].TryGetValue(key, out ret))
return ret;
}
CLogExportModuleDefination moduleSettings = GetMacroConfigurationProfile().FindExportModule(moduleName);
if (null == moduleSettings || !moduleSettings.CustomSettings.ContainsKey("Priority"))
throw new CLogEnterReadOnlyModeException("Priority", CLogHandledException.ExceptionType.RequiredConfigParameterUnspecified, match);
return moduleSettings.CustomSettings["Priority"];
}
public CLogLineMatch match { get; private set; }
public string SourceFile { get; set; }
public void AddConfigFileProperty(string module, string key, string value)
{
string oldValue = GetConfigFileProperty(module, key);
// If we already have this value, dont set it (we dont want to dirty the config file)
if (value.Equals(oldValue))
{
return;
}
if (!ModuleProperites.ContainsKey(module))
{
ModuleProperites[module] = new Dictionary<string, string>();
}
ModuleProperites[module][key] = value;
}
public string GetConfigFileProperty(string module, string key)
{
if (!ModuleProperites.ContainsKey(module))
{
return null;
}
if (!ModuleProperites[module].ContainsKey(key))
{
return null;
}
return ModuleProperites[module][key];
}
}
}