X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Ffield.hpp;h=dec5b103222008200b7adbcb8a019fa2ae3dbd3d;hp=2a1bcf35bf8002d5eec1a447fbe48b611d8eb345;hb=6e01cdc6c6e9cd18d99e8898fa3df41911388e8e;hpb=eda1aa02582ba8af1f30d40f131f4a32d2b372ab diff --git a/src/bin/lttng-sessiond/field.hpp b/src/bin/lttng-sessiond/field.hpp index 2a1bcf35b..dec5b1032 100644 --- a/src/bin/lttng-sessiond/field.hpp +++ b/src/bin/lttng-sessiond/field.hpp @@ -8,13 +8,15 @@ #ifndef LTTNG_FIELD_H #define LTTNG_FIELD_H +#include + +#include + #include #include #include #include -#include - namespace lttng { namespace sessiond { namespace trace { @@ -456,4 +458,48 @@ protected: } /* namespace sessiond */ } /* namespace lttng */ +/* + * Due to a bug in g++ < 7.1, this specialization must be enclosed in the fmt namespace, + * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480. + */ +namespace fmt { +template <> +struct formatter : formatter { + template + typename FormatCtx::iterator format( + const lttng::sessiond::trace::field_location& location, FormatCtx& ctx) + { + std::string location_str{"["}; + + switch (location.root_) { + case lttng::sessiond::trace::field_location::root::PACKET_HEADER: + location_str += "\"packet-header\""; + break; + case lttng::sessiond::trace::field_location::root::PACKET_CONTEXT: + location_str += "\"packet-context\""; + break; + case lttng::sessiond::trace::field_location::root::EVENT_RECORD_HEADER: + location_str += "\"event-record-header\""; + break; + case lttng::sessiond::trace::field_location::root::EVENT_RECORD_COMMON_CONTEXT: + location_str += "\"event-record-common-context\""; + break; + case lttng::sessiond::trace::field_location::root::EVENT_RECORD_SPECIFIC_CONTEXT: + location_str += "\"event-record-specific-context\""; + break; + case lttng::sessiond::trace::field_location::root::EVENT_RECORD_PAYLOAD: + location_str += "\"event-record-payload\""; + break; + } + + for (const auto &name : location.elements_) { + location_str += ", \"" + name + "\""; + } + + location_str += "]"; + return format_to(ctx.out(), location_str); + } +}; +} /* namespace fmt */ + #endif /* LTTNG_FIELD_H */