From 595ba9e8a6718982520487cf85b67b32ad4b7bda Mon Sep 17 00:00:00 2001 From: Quinten Mennen Date: Tue, 23 Sep 2025 21:01:07 +0200 Subject: [PATCH] fix(channel): add extra indents for level-1 nested objects --- webserv/log/Channel.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/webserv/log/Channel.cpp b/webserv/log/Channel.cpp index 9089ef0..fb9d988 100644 --- a/webserv/log/Channel.cpp +++ b/webserv/log/Channel.cpp @@ -1,6 +1,7 @@ #include -#include + #include +#include Log::Level Channel::getLogLevel() const { @@ -17,21 +18,24 @@ std::string Channel::printContext(const std::map &cont std::stringstream ss; if (!context.empty()) { - bool first = true; for (const auto &[key, value] : context) { - if (!first) + if (value.find('\n') != std::string::npos) { - ss << "\n"; + ss << "\t| " << std::right << std::setfill(' ') << "\e[1m" << key << "\e[0m" << " : \n"; + std::istringstream valueStream(value); + std::string line; + while (std::getline(valueStream, line)) + { + ss << std::setw(10) << "\t\t| " << line << "\n"; + } + continue; } - ss << "\t| " << std::setw(15) << std::right << std::setfill(' ') << key << " : " << value; - - first = false; + ss << "\t| " << std::right << std::setfill(' ') << "\e[1m" << key << "\e[0m" << " : " << value << "\n"; } - ss << "\n\n"; - + ss << "\n"; } - + return ss.str(); } \ No newline at end of file