Merge remote-tracking branch 'origin/master' into sid-dahiya/PGImprovements
This commit is contained in:
Коммит
aa1ec4c8c2
|
@ -402,7 +402,7 @@ namespace MAT_NS_BEGIN
|
|||
m_httpClient = nullptr;
|
||||
m_taskDispatcher = nullptr;
|
||||
m_dataViewer = nullptr;
|
||||
m_dataInspector = nullptr;
|
||||
ClearDataInspectors();
|
||||
|
||||
m_filters.UnregisterAllFilters();
|
||||
|
||||
|
@ -525,9 +525,9 @@ namespace MAT_NS_BEGIN
|
|||
m_context.SetCustomField(name, prop);
|
||||
{
|
||||
LOCKGUARD(m_dataInspectorGuard);
|
||||
if (m_dataInspector)
|
||||
for(const auto& dataInspector : m_dataInspectors)
|
||||
{
|
||||
m_dataInspector->InspectSemanticContext(name, value, /*isGlobalContext: */ true, std::string{});
|
||||
dataInspector->InspectSemanticContext(name, value, /*isGlobalContext: */ true, std::string{});
|
||||
}
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -603,9 +603,9 @@ namespace MAT_NS_BEGIN
|
|||
m_context.SetCustomField(name, prop);
|
||||
{
|
||||
LOCKGUARD(m_dataInspectorGuard);
|
||||
if (m_dataInspector)
|
||||
for(const auto& dataInspector : m_dataInspectors)
|
||||
{
|
||||
m_dataInspector->InspectSemanticContext(name, value, /*isGlobalContext: */ true, std::string{});
|
||||
dataInspector->InspectSemanticContext(name, value, /*isGlobalContext: */ true, std::string{});
|
||||
}
|
||||
}
|
||||
return STATUS_SUCCESS;
|
||||
|
@ -710,9 +710,9 @@ namespace MAT_NS_BEGIN
|
|||
{
|
||||
LOCKGUARD(m_dataInspectorGuard);
|
||||
|
||||
if (m_dataInspector)
|
||||
for (const auto& dataInspector : m_dataInspectors)
|
||||
{
|
||||
m_dataInspector->InspectRecord(*(event->source));
|
||||
dataInspector->InspectRecord(*(event->source));
|
||||
}
|
||||
}
|
||||
GetSystem()->sendEvent(event);
|
||||
|
@ -807,12 +807,53 @@ namespace MAT_NS_BEGIN
|
|||
void LogManagerImpl::SetDataInspector(const std::shared_ptr<IDataInspector>& dataInspector)
|
||||
{
|
||||
LOCKGUARD(m_dataInspectorGuard);
|
||||
m_dataInspector = dataInspector;
|
||||
if(dataInspector == nullptr)
|
||||
{
|
||||
LOG_WARN("Attempting to set nullptr as DataInspector");
|
||||
return;
|
||||
}
|
||||
|
||||
auto itDataInspector = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&dataInspector](const std::shared_ptr<IDataInspector>& currentInspector)
|
||||
{
|
||||
return strcmp(dataInspector->GetName(), currentInspector->GetName()) == 0;
|
||||
});
|
||||
|
||||
if (itDataInspector != m_dataInspectors.end())
|
||||
{
|
||||
LOG_WARN("Replacing specified IDataInspector with passed in inspector");
|
||||
m_dataInspectors.erase(itDataInspector);
|
||||
}
|
||||
|
||||
m_dataInspectors.push_back(dataInspector);
|
||||
}
|
||||
|
||||
std::shared_ptr<IDataInspector> LogManagerImpl::GetDataInspector() noexcept
|
||||
void LogManagerImpl::ClearDataInspectors()
|
||||
{
|
||||
return m_dataInspector;
|
||||
LOCKGUARD(m_dataInspectorGuard);
|
||||
std::vector<std::shared_ptr<IDataInspector>>{}.swap(m_dataInspectors);
|
||||
}
|
||||
|
||||
void LogManagerImpl::RemoveDataInspector(const std::string& name)
|
||||
{
|
||||
LOCKGUARD(m_dataInspectorGuard);
|
||||
auto itDataInspector = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&name](const std::shared_ptr<IDataInspector>& inspector){
|
||||
return strcmp(inspector->GetName(), name.c_str()) == 0;
|
||||
});
|
||||
|
||||
if (itDataInspector != m_dataInspectors.end())
|
||||
{
|
||||
m_dataInspectors.erase(itDataInspector);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<IDataInspector> LogManagerImpl::GetDataInspector(const std::string& name) noexcept
|
||||
{
|
||||
LOCKGUARD(m_dataInspectorGuard);
|
||||
auto it = std::find_if(m_dataInspectors.begin(), m_dataInspectors.end(), [&name](const std::shared_ptr<IDataInspector>& inspector){
|
||||
return strcmp(inspector->GetName(), name.c_str()) == 0;
|
||||
});
|
||||
|
||||
return it != m_dataInspectors.end() ? *it : nullptr;
|
||||
}
|
||||
|
||||
status_t LogManagerImpl::DeleteData()
|
||||
|
|
|
@ -297,8 +297,9 @@ namespace MAT_NS_BEGIN
|
|||
static size_t GetDeadLoggerCount();
|
||||
|
||||
virtual void SetDataInspector(const std::shared_ptr<IDataInspector>& dataInspector) override;
|
||||
|
||||
virtual std::shared_ptr<IDataInspector> GetDataInspector() noexcept override;
|
||||
virtual void ClearDataInspectors() override;
|
||||
virtual void RemoveDataInspector(const std::string& name) override;
|
||||
virtual std::shared_ptr<IDataInspector> GetDataInspector(const std::string& name) noexcept override;
|
||||
|
||||
protected:
|
||||
std::unique_ptr<ITelemetrySystem>& GetSystem();
|
||||
|
@ -337,7 +338,7 @@ namespace MAT_NS_BEGIN
|
|||
EventFilterCollection m_filters;
|
||||
std::vector<std::unique_ptr<IModule>> m_modules;
|
||||
DataViewerCollection m_dataViewerCollection;
|
||||
std::shared_ptr<IDataInspector> m_dataInspector;
|
||||
std::vector<std::shared_ptr<IDataInspector>> m_dataInspectors;
|
||||
std::recursive_mutex m_dataInspectorGuard;
|
||||
};
|
||||
|
||||
|
|
|
@ -64,6 +64,12 @@ namespace MAT_NS_BEGIN
|
|||
/// <param name="isGlobalContext">Whether this is a global/logmanager Context or local ILogger context</param>
|
||||
/// <param name="associatedTenant">(Optional) Tenant associated with the Context</param>
|
||||
virtual void InspectSemanticContext(const std::string& contextName, GUID_t contextValue, bool isGlobalContext, const std::string& associatedTenant) noexcept = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Returns unique name for current Data Inspector
|
||||
/// </summary>
|
||||
/// <returns>Name of Data Inspector</returns>
|
||||
virtual const char* GetName() const noexcept { return ""; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -380,10 +380,28 @@ namespace MAT_NS_BEGIN
|
|||
virtual void SetDataInspector(const std::shared_ptr<IDataInspector>& dataInspector) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Get the current instance of IDataInspector
|
||||
/// Clears all IDataInspectors
|
||||
/// </summary>
|
||||
/// <returns>Current instance of IDataInspector if set, nullptr otherwise.</returns>
|
||||
virtual std::shared_ptr<IDataInspector> GetDataInspector() noexcept = 0;
|
||||
virtual void ClearDataInspectors() = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Removes specified IDataInspector
|
||||
/// </summary>
|
||||
/// <param name="name">String name that identifies IDataInspector</param>
|
||||
virtual void RemoveDataInspector(const std::string& name) = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Get the current instance of IDataInspector specified by the name
|
||||
/// </summary>
|
||||
/// <param name="name">String name that identifies IDataInspector</param>
|
||||
/// <returns>Selected instance of IDataInspector if available, nullptr otherwise.</returns>
|
||||
virtual std::shared_ptr<IDataInspector> GetDataInspector(const std::string& name) noexcept = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Get the current instance of IDataInspector specified by an empty string
|
||||
/// </summary>
|
||||
/// <returns>Selected instance of IDataInspector if available, nullptr otherwise.</returns>
|
||||
virtual std::shared_ptr<IDataInspector> GetDataInspector() noexcept { return GetDataInspector(std::string{}); }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -370,7 +370,11 @@ namespace MAT_NS_BEGIN
|
|||
|
||||
void SetDataInspector(const std::shared_ptr<IDataInspector>& /*dataInspector*/) override {}
|
||||
|
||||
std::shared_ptr<IDataInspector> GetDataInspector() noexcept override
|
||||
void RemoveDataInspector(const std::string& /*name*/) override {}
|
||||
|
||||
void ClearDataInspectors() override {}
|
||||
|
||||
std::shared_ptr<IDataInspector> GetDataInspector(const std::string& /*name*/) noexcept override
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче