-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate public range print helpers #1544
Comments
first of all, i am for this change. Seastar is not a formatting library, neither should it help user to print standard containers or even range-like containers or string-like objects -- this is covered by fmtlib already. currently, we have 6 ways to print a range
i think we should consolidate them, and only use fmtlib for printing out various objects and containers of them. but we should at least ready Scylla for this change. to make this happen, there is a strong requisite: to make we need to use a bottom-up approach to achieve this goal:
as scylla is a large scale project, we might want to address this in multiple iterations. |
@tchaikov the above sounds like a solid plan |
Agree with the plan. Note that FMT_DEPRECATED_OSTREAM isn't in seastar, IIRC. |
No, it's not in Seastar. But it prevents Scylla from using fmtlib's builtin range and tuple formatters with our types like sstring. So we need to fix Scylla first and then drop these helpers. |
i am copying this issue and the plan above to scylla. so when we have PRs address it, we can associate these PRs to the scylla issue, as Avi pointed out, |
before this change, we use `boost::lexical_cast<std::string>()` to convert a given value to a string when creating a `label_instance`. but since we are migrating to fmtlib based formatting, it'd be desirable to format things using fmtlib. this change has been tested by compiling scylla with the seastar submodule with the change. Refs scylladb#1544 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
before this change, we use `boost::lexical_cast<std::string>()` to convert a given value to a string when creating a `label_instance`. but since we are migrating to fmtlib based formatting, it'd be desirable to format things using fmtlib. this change has been tested by compiling scylla with the seastar submodule with the change. Refs scylladb#1544 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
before this change, we use `boost::lexical_cast<std::string>()` to convert a given value to a string when creating a `label_instance`. but since we are migrating to fmtlib based formatting, it'd be desirable to format things using fmtlib. this change has been tested by compiling scylla with the seastar submodule with the change. Refs scylladb#1544 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
before this change, we use `boost::lexical_cast<std::string>()` to convert a given value to a string when creating a `label_instance`. but since we are migrating to fmtlib based formatting, it'd be desirable to format things using fmtlib. this change has been tested by compiling scylla with the seastar submodule with the change. Refs #1544 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This issue is a duplicate of the seven-year-old #98. The original reason why these various pretty-printers were added to Seastar was that Seastar included a logging library, and you often wanted to log things like exceptions, vectors, and so on. Of course as #98 explains this was never a very good reason to add all of them, and certainly not in random header files like we did. @tchaikov is right that probably as we switch more and more to using fmt instead of C++'s Personally, to reduce friction and backward-incompatibility, and make Seastar's logging easier to use, I would add a header file that makes it easy to log objects of various common types (and also serve as an example how different projects, like Scylla, should make their own objects printable) - and not require most uses of Seastar loggers to use various fmt functions manually. |
@nyh I can understand seastar proving printers for data structures it defines, but why would it provide pretty printers for stl types? |
Because if nobody else provides them then printing containers becomes a PITA. |
Modern fmt library version provide helpers for containers / ranges. |
I am explaining why do we have them now. Obviously if we move to another library that provides them there is no need to have them in Seastar any more. |
Seastar is an event-driven framework, not a collection of libraries for multiple purposes. also, when migrating to a {fmt} only formatting solution, the operator<< based printers can actually makes our lives more difficult. for instance, Boost.test expects operator<< and fall back to `boost_test_print_type()`, so even if we provide a templated `boost_test_print_type()` which accepts all types which can be formatted with {fmt}, if Boost.test is able to find the operator<<-based formatter for a std::vector, it just picks it, and then hits the brick wall, as the elements in the vector does not provide an operator<<-based formatter. instead of enabling these operator<<:s to print the element with fmt::formatter support, let's just disable them on user's request. in this change, a new option is added. so that user can disable these formatter on request. and these two formatters are marked deprecated. so in future, we can remove them when we bump up the API level or just completely drop them. Fixes scylladb#1544 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
Seastar is an event-driven framework, not a collection of libraries for multiple purposes. also, when migrating to a {fmt} only formatting solution, the operator<< based printers can actually makes our lives more difficult. for instance, Boost.test expects operator<< and fall back to `boost_test_print_type()`, so even if we provide a templated `boost_test_print_type()` which accepts all types which can be formatted with {fmt}, if Boost.test is able to find the operator<<-based formatter for a std::vector, it just picks it, and then hits the brick wall, as the elements in the vector does not provide an operator<<-based formatter. instead of enabling these operator<<:s to print the element with fmt::formatter support, let's just disable them on user's request. in this change, a new option is added. so that user can disable these formatter on request. and these two formatters are marked deprecated. so in future, we can remove them when we bump up the API level or just completely drop them. Fixes scylladb#1544 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
Seastar is an event-driven framework, not a collection of libraries for multiple purposes. also, when migrating to a {fmt} only formatting solution, the operator<< based printers can actually makes our lives more difficult. for instance, Boost.test expects operator<< and fall back to `boost_test_print_type()`, so even if we provide a templated `boost_test_print_type()` which accepts all types which can be formatted with {fmt}, if Boost.test is able to find the operator<<-based formatter for a std::vector, it just picks it, and then hits the brick wall, as the elements in the vector does not provide an operator<<-based formatter. instead of enabling these operator<<:s to print the element with fmt::formatter support, let's just disable them on user's request. in this change, a new option is added. so that user can disable these formatter on request. and these two formatters are marked deprecated. so in future, we can remove them when we bump up the API level or just completely drop them. Fixes scylladb#1544 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
Seastar is an event-driven framework, not a collection of libraries for multiple purposes. also, when migrating to a {fmt} only formatting solution, the operator<< based printers can actually makes our lives more difficult. for instance, Boost.test expects operator<< and fall back to `boost_test_print_type()`, so even if we provide a templated `boost_test_print_type()` which accepts all types which can be formatted with {fmt}, if Boost.test is able to find the operator<<-based formatter for a std::vector, it just picks it, and then hits the brick wall, as the elements in the vector does not provide an operator<<-based formatter. instead of enabling these operator<<:s to print the element with fmt::formatter support, let's just disable them on user's request. in this change, a new option is added. so that user can disable these formatter on request. and these two formatters are marked deprecated. so in future, we can remove them when we bump up the API level or just completely drop them. Fixes #1544 Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
…from Kefu Chai this series disables operator<<:s for vector and unordered_map, and drop operator<< for mutation, because we don't have to keep it to work with these operator:s anymore. this change is a follow up of scylladb/seastar#1544 this change is a cleanup. so no need to backport Closes #18866 * github.com:scylladb/scylladb: mutation,db: drop operator<< for mutation and seed_provider_type& build: disable operator<< for vector and unordered_map db/heat_load_balance: include used header test: define a more generic boost_test_print_type test/boost: define fmt::formatter for service_level_controller_test.cc test/boost: include test/lib/test_utils.hh
Seastar exposes two print helpers in
seastar/include/seastar/core/sstring.hh
Lines 749 to 782 in 58a4e90
and a bunch of
to_sstring
helpers inseastar/include/seastar/core/sstring.hh
Lines 720 to 747 in 58a4e90
This is out of scope for the seastar library.
In particular, the implementation for
operator<<(std::ostream&, const std::unordered_map)
is unusual and conflicts with similar helpers in scylla utils/to_string.hhcc @avikivity @nyh @tchaikov
The text was updated successfully, but these errors were encountered: