Added indexing to container logging

This commit is contained in:
Pasha Bibko
2025-08-03 20:50:00 +01:00
parent c523375dbe
commit 5bb9f2c28a

View File

@@ -187,13 +187,16 @@ namespace LXC::Util
Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, "[LXC] \"", containerName, "\":\n{"); Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, "[LXC] \"", containerName, "\":\n{");
// Iterates over each of the items in the container and prints them // // Iterates over each of the items in the container and prints them //
unsigned counter = 0;
for (const auto& item : container) for (const auto& item : container)
{ {
if constexpr (Internal::HasLogStrFunc<CargoType>) if constexpr (Internal::HasLogStrFunc<CargoType>)
Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, '\t', item.LogStr()); Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, '\t', std::setw(3), std::left, counter, "| ", item.LogStr());
else else
Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, '\t', item); Internal::WriteImpl<Util::Color::DEFAULT, true>(std::cout, '\t', std::setw(3), std::left, counter, "| ", item);
counter++;
} }
// Prints the ending bracket // // Prints the ending bracket //
@@ -256,13 +259,16 @@ namespace LXC::Util
Internal::WriteImpl<Util::Color::DEFAULT, true>(log, "[LXC] \"", containerName, "\":\n{"); Internal::WriteImpl<Util::Color::DEFAULT, true>(log, "[LXC] \"", containerName, "\":\n{");
// Iterates over each of the items in the container and prints them // // Iterates over each of the items in the container and prints them //
unsigned counter = 0;
for (const auto& item : container) for (const auto& item : container)
{ {
if constexpr (Internal::HasLogStrFunc<CargoType>) if constexpr (Internal::HasLogStrFunc<CargoType>)
Internal::WriteImpl<Util::Color::DEFAULT, true>(log, '\t', item.LogStr()); Internal::WriteImpl<Util::Color::DEFAULT, true>(log, '\t', std::setw(3), std::left, counter, "| ", item.LogStr());
else else
Internal::WriteImpl<Util::Color::DEFAULT, true>(log, '\t', item); Internal::WriteImpl<Util::Color::DEFAULT, true>(log, '\t', std::setw(3), std::left, counter, "| ", item);
counter++;
} }
// Prints the ending bracket // // Prints the ending bracket //