diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-15 20:05:01 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2021-02-15 20:05:01 +0000 |
commit | aa209cfbcfc1acb4a12ba1ff77d8342119371938 (patch) | |
tree | 8321dc14645ef3d5b936e69fd682f20007e3fed2 | |
parent | 9c741e5019471d40ff1b655e99fb42e6d5354c19 (diff) | |
download | rspamd-aa209cfbcfc1acb4a12ba1ff77d8342119371938.tar.gz rspamd-aa209cfbcfc1acb4a12ba1ff77d8342119371938.zip |
[Project] Css: Make debug strings json like to simplify tests
-rw-r--r-- | src/libserver/css/css_parser.cxx | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/libserver/css/css_parser.cxx b/src/libserver/css/css_parser.cxx index cc248cce4..0e6ec4e84 100644 --- a/src/libserver/css/css_parser.cxx +++ b/src/libserver/css/css_parser.cxx @@ -137,16 +137,16 @@ struct css_consumed_block { } auto debug_str(void) -> std::string { - std::string ret = token_type_str(); + std::string ret = std::string("\"type\": \"") + token_type_str() + "\""; - ret += "; value: "; + ret += ", \"value\": "; std::visit([&](auto& arg) { using T = std::decay_t<decltype(arg)>; if constexpr (std::is_same_v<T, std::vector<consumed_block_ptr>>) { /* Array of blocks */ - ret += "nodes: ["; + ret += "["; for (const auto &block : arg) { ret += "{"; ret += block->debug_str(); @@ -161,11 +161,11 @@ struct css_consumed_block { } else if constexpr (std::is_same_v<T, std::monostate>) { /* Empty block */ - ret += "empty"; + ret += "\"empty\""; } else { /* Single element block */ - ret += arg.debug_token_str(); + ret += "\"" + arg.debug_token_str() + "\""; } }, content); @@ -486,7 +486,7 @@ bool css_parser::consume_input(const std::string_view &sv) } auto debug_str = consumed_blocks->debug_str(); - msg_debug_css("consumed css: %*s", (int)debug_str.size(), debug_str.data()); + msg_debug_css("consumed css: {%*s}", (int)debug_str.size(), debug_str.data()); tokeniser.reset(nullptr); /* No longer needed */ |