From d008326706ac5759d3bf838df092dceac39813a5 Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Thu, 10 Sep 2020 20:53:03 +0800 Subject: [PATCH] common/dout: escape formatting string for crimson crimson uses seastar logging facility for logging. and the latter uses fmt::format(). currently, we collect the log message into a string and pass it to log(fmt,...) as "fmt", but seastar/core/sstring.hh defines the operator<<(ostream&, const vector&) which is a better match than our the operator<<(ostream&, const vector&). and seastar's operator<<(ostream&, const vector&) uses "{" and "}" to mark the begin and end of a vector when printing it. and "{}" is also used by libfmt to enclose its replacement fields. see https://fmt.dev/latest/syntax.html. so when a vector is printed using logging facility in crimson, libfmt chokes when trying to parse it as a format string. so we have some options, like: - disable seastar's operator<< implementation - escape the "{}" when writing the vector to the output stream - print the message as the args, and use "{}" as the fmt. the 3rd one is the most straightforward, and probably more performant. Signed-off-by: Kefu Chai --- src/common/dout.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/dout.h b/src/common/dout.h index c7c08182e53..b8f762991db 100644 --- a/src/common/dout.h +++ b/src/common/dout.h @@ -129,7 +129,7 @@ struct is_dynamic> : public std::true_type {}; #define dendl_impl \ ""; \ _logger.log(crimson::to_log_level(_lv), \ - _out.str().c_str()); \ + "{}", _out.str().c_str()); \ } \ } while (0) #elif defined(WITH_SEASTAR) && defined(WITH_ALIEN) -- 2.39.5