From: Kefu Chai Date: Thu, 10 Sep 2020 12:53:03 +0000 (+0800) Subject: common/dout: escape formatting string for crimson X-Git-Tag: v16.1.0~1125^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d008326706ac5759d3bf838df092dceac39813a5;p=ceph.git 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 --- diff --git a/src/common/dout.h b/src/common/dout.h index c7c08182e539..b8f762991dba 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)