You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
FLOW_LOG_ macros operate with << ostream semantics.
In general we should add printf-format semantics as well. Macros cannot be overloaded, so need to come up with a decent name; maybe FLOW_LOGF_* (analogous to printf, as in print-formatted, log-formatted). Though it breaks the coding style convention of putting the namespace into the macro. Maybe FLOW_LOG_F_* or FLOW_LOG_FMT_*.
In terms of implementation:
---begin mostly ignoring---
There is Boost.format; and [https://abseil.io/tips/124] (which means abseil would become a dependency of Flow). Boost.format might be unsuitable due to requiring % instead of comma. Abseil str_format looks pretty badass. One thing I don't see in it, or anywhere else, is direct support for output of type T, where ostream<<T is supplied; this way a given object outputs its string representation directly into the logged stream. Functionally it's fine, in that one can always do StrFormat("%s", flow::util::ostream_op_string(item_of_type_t)); it is just a bit slower than one would want. There is support for StrFormat("%v", item_of_type_t), but one must supply an overload for a certain thingie for const T&, but either one then has to write a re-impl of ostream<<T, or simply use the latter (but then seems it's still slow involving a temp std::string). But details. Come up with something decent to use and perf-wise; and get on with it.
---stop mostly ignoring---
Update in 1/2024: C++ 20 adopted the fmt library which is mega-fast and good. Before C++20 it is available separately, both headers-only and not. I'd say that automatically makes it the top contender over the above. It has other uses as well such as to print nice time stamps quickly in flow.log. No-brainer.
Update in 2/2024: Flow now depends on fmt (for a certain recent perf improvement)! So for sure we should use it for this.
mentioned std::to_string() overloads; investigate those for relevance; might not be relevant.
The text was updated successfully, but these errors were encountered:
Filed by @ygoldfeld pre-open-source:
FLOW_LOG_ macros operate with
<<
ostream semantics.In general we should add printf-format semantics as well. Macros cannot be overloaded, so need to come up with a decent name; maybe FLOW_LOGF_* (analogous to printf, as in print-formatted, log-formatted). Though it breaks the coding style convention of putting the namespace into the macro. Maybe FLOW_LOG_F_* or FLOW_LOG_FMT_*.
In terms of implementation:
---begin mostly ignoring---
There is Boost.format; and [https://abseil.io/tips/124] (which means abseil would become a dependency of Flow). Boost.format might be unsuitable due to requiring % instead of comma. Abseil str_format looks pretty badass. One thing I don't see in it, or anywhere else, is direct support for output of type T, where ostream<<T is supplied; this way a given object outputs its string representation directly into the logged stream. Functionally it's fine, in that one can always do
StrFormat("%s", flow::util::ostream_op_string(item_of_type_t))
; it is just a bit slower than one would want. There is support forStrFormat("%v", item_of_type_t)
, but one must supply an overload for a certain thingie for const T&, but either one then has to write a re-impl of ostream<<T, or simply use the latter (but then seems it's still slow involving a temp std::string). But details. Come up with something decent to use and perf-wise; and get on with it.---stop mostly ignoring---
Update in 1/2024: C++ 20 adopted the fmt library which is mega-fast and good. Before C++20 it is available separately, both headers-only and not. I'd say that automatically makes it the top contender over the above. It has other uses as well such as to print nice time stamps quickly in flow.log. No-brainer.
Update in 2/2024: Flow now depends on fmt (for a certain recent perf improvement)! So for sure we should use it for this.
mentioned std::to_string() overloads; investigate those for relevance; might not be relevant.
The text was updated successfully, but these errors were encountered: