]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
common/dout: escape formatting string for crimson 37084/head
authorKefu Chai <kchai@redhat.com>
Thu, 10 Sep 2020 12:53:03 +0000 (20:53 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 10 Sep 2020 13:21:39 +0000 (21:21 +0800)
commitd008326706ac5759d3bf838df092dceac39813a5
tree1f7a563acab4a63d8716a4d87e52830ad73426de
parent69260a60b7f76442d72a70c381d79357467be94e
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<T>&) which is a better match than
our the operator<<(ostream&, const vector<T, Allocator>&). and seastar's
operator<<(ostream&, const vector<T>&) 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 <kchai@redhat.com>
src/common/dout.h