in src/TestFramework/Core/Logging/Logger.cs [246:305]
private Dictionary<string, object> CreateLogInformationBag(
LogEntryKind kind,
string message,
params object[] parameters
)
{
Dictionary<string, object> information = new Dictionary<string, object>();
Dictionary<string, bool> allowOverride = new Dictionary<string, bool>();
// Append PTF-reserved information: LogEntryKind
information.Add(LogInformationName.LogEntryKind, kind);
allowOverride.Add(LogInformationName.LogEntryKind, false);
// Append PTF-reserved information: CurrentTestCaseName
if (testSite.TestProperties.ContainsKey(TestPropertyNames.CurrentTestCaseName))
{
information.Add(TestPropertyNames.CurrentTestCaseName,
testSite.TestProperties[TestPropertyNames.CurrentTestCaseName]);
allowOverride.Add(TestPropertyNames.CurrentTestCaseName, false);
}
// Append PTF-reserved information: Message
string msg = parameters != null && parameters.Length > 0 ? String.Format(message, parameters) : message;
information.Add(LogInformationName.Message, msg);
allowOverride.Add(LogInformationName.Message, false);
// Append PTF-reserved information: TimeStamp
DateTime timeStamp = DateTime.Now;
information.Add(LogInformationName.TimeStamp, timeStamp);
allowOverride.Add(LogInformationName.TimeStamp, false);
lock (registeredProviders)
{
// Append information provided by providers.
foreach (LogProvider provider in registeredProviders)
{
provider.PrepareLogInformation(kind, msg, timeStamp, Site.TestProperties);
Dictionary<string, object> providedInfo = provider.Information;
foreach (string name in providedInfo.Keys)
{
if (information.ContainsKey(name) && !allowOverride[name])
{
// The information isn't allowed to be overridden.
throw new InvalidOperationException(
String.Format("Log information '{0}' is not allowed to be overridden.",
name));
}
else
{
// Append log information.
information[name] = providedInfo[name];
allowOverride[name] = provider.AllowOverride;
}
}
}
}
return information;
}