core: Use unodered_map for LogComponent::ComponentList
This commit is contained in:
@@ -355,67 +355,73 @@ LogComponentDisableAll(LogLevel level)
|
||||
void
|
||||
LogComponentPrintList()
|
||||
{
|
||||
LogComponent::ComponentList* components = LogComponent::GetComponentList();
|
||||
for (LogComponent::ComponentList::const_iterator i = components->begin();
|
||||
i != components->end();
|
||||
i++)
|
||||
// Create sorted map of components by inserting them into a map
|
||||
std::map<std::string, LogComponent*> componentsSorted;
|
||||
|
||||
for (const auto& component : *LogComponent::GetComponentList())
|
||||
{
|
||||
std::cout << i->first << "=";
|
||||
if (i->second->IsNoneEnabled())
|
||||
componentsSorted.insert(component);
|
||||
}
|
||||
|
||||
// Iterate through sorted components
|
||||
for (const auto& [name, component] : componentsSorted)
|
||||
{
|
||||
std::cout << name << "=";
|
||||
if (component->IsNoneEnabled())
|
||||
{
|
||||
std::cout << "0" << std::endl;
|
||||
continue;
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_LEVEL_ALL))
|
||||
if (component->IsEnabled(LOG_LEVEL_ALL))
|
||||
{
|
||||
std::cout << "all";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->second->IsEnabled(LOG_ERROR))
|
||||
if (component->IsEnabled(LOG_ERROR))
|
||||
{
|
||||
std::cout << "error";
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_WARN))
|
||||
if (component->IsEnabled(LOG_WARN))
|
||||
{
|
||||
std::cout << "|warn";
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_DEBUG))
|
||||
if (component->IsEnabled(LOG_DEBUG))
|
||||
{
|
||||
std::cout << "|debug";
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_INFO))
|
||||
if (component->IsEnabled(LOG_INFO))
|
||||
{
|
||||
std::cout << "|info";
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_FUNCTION))
|
||||
if (component->IsEnabled(LOG_FUNCTION))
|
||||
{
|
||||
std::cout << "|function";
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_LOGIC))
|
||||
if (component->IsEnabled(LOG_LOGIC))
|
||||
{
|
||||
std::cout << "|logic";
|
||||
}
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_PREFIX_ALL))
|
||||
if (component->IsEnabled(LOG_PREFIX_ALL))
|
||||
{
|
||||
std::cout << "|prefix_all";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (i->second->IsEnabled(LOG_PREFIX_FUNC))
|
||||
if (component->IsEnabled(LOG_PREFIX_FUNC))
|
||||
{
|
||||
std::cout << "|func";
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_PREFIX_TIME))
|
||||
if (component->IsEnabled(LOG_PREFIX_TIME))
|
||||
{
|
||||
std::cout << "|time";
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_PREFIX_NODE))
|
||||
if (component->IsEnabled(LOG_PREFIX_NODE))
|
||||
{
|
||||
std::cout << "|node";
|
||||
}
|
||||
if (i->second->IsEnabled(LOG_PREFIX_LEVEL))
|
||||
if (component->IsEnabled(LOG_PREFIX_LEVEL))
|
||||
{
|
||||
std::cout << "|level";
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@
|
||||
#include "time-printer.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
/**
|
||||
@@ -395,7 +395,7 @@ class LogComponent
|
||||
* It is exposed here to allow print-introspected-doxygen.cc
|
||||
* to generate a list of all LogComponents.
|
||||
*/
|
||||
typedef std::map<std::string, LogComponent*> ComponentList;
|
||||
using ComponentList = std::unordered_map<std::string, LogComponent*>;
|
||||
|
||||
/**
|
||||
* Get the list of LogComponents.
|
||||
|
||||
Reference in New Issue
Block a user