Use json_escape_utf8 in broker debug output

This commit is contained in:
AmazingPP 2022-08-02 21:11:40 +08:00
parent 6fd0645aef
commit 2c4449e19a

View file

@ -189,14 +189,19 @@ struct scoped_reporter_location
}; };
#ifdef DEBUG #ifdef DEBUG
static std::string RenderMessage(const broker::data& d)
{
return util::json_escape_utf8(broker::to_string(d));
}
static std::string RenderMessage(std::string topic, const broker::data& x) static std::string RenderMessage(std::string topic, const broker::data& x)
{ {
return util::fmt("%s -> %s", broker::to_string(x).c_str(), topic.c_str()); return util::fmt("%s -> %s", RenderMessage(x).c_str(), topic.c_str());
} }
static std::string RenderEvent(std::string topic, std::string name, const broker::data& args) static std::string RenderEvent(std::string topic, std::string name, const broker::data& args)
{ {
return util::fmt("%s(%s) -> %s", name.c_str(), broker::to_string(args).c_str(), topic.c_str()); return util::fmt("%s(%s) -> %s", name.c_str(), RenderMessage(args).c_str(), topic.c_str());
} }
static std::string RenderMessage(const broker::store::response& x) static std::string RenderMessage(const broker::store::response& x)
@ -210,11 +215,6 @@ static std::string RenderMessage(const broker::vector* xs)
return broker::to_string(*xs); return broker::to_string(*xs);
} }
static std::string RenderMessage(const broker::data& d)
{
return broker::to_string(d);
}
static std::string RenderMessage(const broker::vector& xs) static std::string RenderMessage(const broker::vector& xs)
{ {
return broker::to_string(xs); return broker::to_string(xs);