From f9a4135756da1947c2aa00e5b1e3c8e572d02107 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Thu, 8 Jun 2023 14:53:15 -0400 Subject: [PATCH] Wrap calls to fmt::format to catch formatting exceptions MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit fmt::format throws when a formatting error is encountered. Unfortunately, we can't ensure complete coverage of all logging call sites (e.g. error paths) and it is not desirable for such an exception to be thrown in those cases. The formatting error is returned as the formatted string so that it ends up in the logs or exception messages more or less transparently. Signed-off-by: Jérémie Galarneau Change-Id: I1cb33a5fe87221139eaf9de918b47e0397daa89c --- .../ctf2-trace-class-visitor.cpp | 6 +- src/bin/lttng-sessiond/field.cpp | 8 +- src/bin/lttng-sessiond/field.hpp | 4 +- src/bin/lttng-sessiond/rotation-thread.cpp | 16 +-- .../tsdl-trace-class-visitor.cpp | 134 +++++++++--------- src/bin/lttng-sessiond/ust-app.cpp | 2 +- src/bin/lttng-sessiond/ust-field-convert.cpp | 70 ++++----- .../lttng-sessiond/ust-registry-channel.cpp | 10 +- .../lttng-sessiond/ust-registry-session.cpp | 16 +-- src/bin/lttng/commands/destroy.cpp | 8 +- src/bin/lttng/commands/start.cpp | 2 +- src/bin/lttng/commands/stop.cpp | 2 +- src/common/container-wrapper.hpp | 2 +- src/common/error.hpp | 6 +- src/common/eventfd.cpp | 4 +- src/common/file-descriptor.cpp | 8 +- src/common/format.hpp | 13 ++ src/common/random.cpp | 12 +- 18 files changed, 169 insertions(+), 154 deletions(-) diff --git a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp index 24fe15792..8da98591d 100644 --- a/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/ctf2-trace-class-visitor.cpp @@ -205,8 +205,8 @@ private: if (std::is_signed::value) { LTTNG_THROW_ERROR( - fmt::format("Failed to serialize {}: unexpected role", - _fragment["type"])); + lttng::format("Failed to serialize {}: unexpected role", + _fragment["type"])); } auto role_array = json::json::array(); @@ -219,7 +219,7 @@ private: } if (type.mappings_->size() < 1) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Failed to serialize {}: enumeration must have at least one mapping", _fragment["type"])); } diff --git a/src/bin/lttng-sessiond/field.cpp b/src/bin/lttng-sessiond/field.cpp index 2d7f9deac..94d002167 100644 --- a/src/bin/lttng-sessiond/field.cpp +++ b/src/bin/lttng-sessiond/field.cpp @@ -65,8 +65,8 @@ lst::field::field(std::string in_name, lst::type::cuptr in_type) : name{ std::move(in_name) }, _type{ std::move(in_type) } { if (!_type) { - LTTNG_THROW_ERROR( - fmt::format("Invalid type used to create field: field name = `{}`", name)); + LTTNG_THROW_ERROR(lttng::format( + "Invalid type used to create field: field name = `{}`", name)); } } @@ -90,7 +90,7 @@ const lst::type& lst::field::get_type() const if (_type) { return *_type; } else { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Invalid attempt to access field type after transfer: field name = `{}`", name)); } @@ -162,7 +162,7 @@ lst::floating_point_type::floating_point_type(unsigned int in_alignment, return; } - LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format( + LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format( "Invalid exponent/mantissa values provided while creating {}", typeid(*this))); } diff --git a/src/bin/lttng-sessiond/field.hpp b/src/bin/lttng-sessiond/field.hpp index 8ba85d81a..5180574a1 100644 --- a/src/bin/lttng-sessiond/field.hpp +++ b/src/bin/lttng-sessiond/field.hpp @@ -638,9 +638,9 @@ template MappingIntegerType>::mapping::range_t range) { if (range.begin == range.end) { - return ::fmt::format("[{}]", range.begin); + return ::lttng::format("[{}]", range.begin); } else { - return ::fmt::format("[{}, {}]", range.begin, range.end); + return ::lttng::format("[{}, {}]", range.begin, range.end); } } } /* namespace details */ diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index 10afaa649..1d62c851e 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -752,8 +752,8 @@ void ls::rotation_thread::_run() DBG_FMT("Handling descriptor activity: fd={}, events={:b}", fd, revents); if (revents & LPOLLERR) { - LTTNG_THROW_ERROR( - fmt::format("Polling returned an error on fd: fd={}", fd)); + LTTNG_THROW_ERROR(lttng::format( + "Polling returned an error on fd: fd={}", fd)); } if (fd == _notification_channel->socket || @@ -789,7 +789,7 @@ void ls::rotation_thread::_run() if (lttng_read(fd, &buf, 1) != 1) { LTTNG_THROW_POSIX( - fmt::format( + lttng::format( "Failed to read from wakeup pipe: fd={}", fd), errno); @@ -849,14 +849,14 @@ void ls::rotation_thread::subscribe_session_consumed_size_rotation(ltt_session& auto condition_status = lttng_condition_session_consumed_size_set_threshold(rotate_condition.get(), size); if (condition_status != LTTNG_CONDITION_STATUS_OK) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Could not set session consumed size condition threshold: size={}", size)); } condition_status = lttng_condition_session_consumed_size_set_session_name( rotate_condition.get(), session.name); if (condition_status != LTTNG_CONDITION_STATUS_OK) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Could not set session consumed size condition session name: name=`{}`", session.name)); } @@ -895,7 +895,7 @@ void ls::rotation_thread::subscribe_session_consumed_size_rotation(ltt_session& &_notification_thread_handle, trigger.get(), true); if (register_ret != LTTNG_OK) { LTTNG_THROW_CTL( - fmt::format( + lttng::format( "Failed to register trigger for automatic size-based rotation: session_name{}, size={}", session.name, size), @@ -919,7 +919,7 @@ void ls::rotation_thread::unsubscribe_session_consumed_size_rotation(ltt_session _notification_channel.get(), lttng_trigger_get_const_condition(session.rotate_trigger)); if (unsubscribe_status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Failed to unsubscribe from consumed size condition used to control automatic size-based rotations: session_name=`{}` return_code={}", session.name, static_cast(unsubscribe_status))); @@ -935,7 +935,7 @@ void ls::rotation_thread::unsubscribe_session_consumed_size_rotation(ltt_session &_notification_thread_handle, session.rotate_trigger); if (unregister_status != LTTNG_OK) { LTTNG_THROW_CTL( - fmt::format( + lttng::format( "Failed to unregister trigger for automatic size-based rotation: session_name{}", session.name), unregister_status); diff --git a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp index d8a01864b..7e45f0a8a 100644 --- a/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp +++ b/src/bin/lttng-sessiond/tsdl-trace-class-visitor.cpp @@ -222,7 +222,7 @@ private: new_mappings->emplace_back(mapping); } else { /* Unsafe mapping, rename it and keep the rest of its attributes. */ - new_mappings->emplace_back(fmt::format("_{}", mapping.name), + new_mappings->emplace_back(lttng::format("_{}", mapping.name), mapping.range); } } @@ -248,7 +248,7 @@ private: } } - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Failed to find mapping by range in enumeration while sanitizing a variant: target_mapping_range={}", target_mapping_range)); } @@ -419,9 +419,9 @@ private: _description += "integer { "; /* Mandatory properties (no defaults). */ - _description += fmt::format("size = {size}; align = {alignment};", - fmt::arg("size", type.size), - fmt::arg("alignment", type.alignment)); + _description += lttng::format("size = {size}; align = {alignment};", + fmt::arg("size", type.size), + fmt::arg("alignment", type.alignment)); /* Defaults to unsigned. */ if (type.signedness_ == lst::integer_type::signedness::SIGNED) { @@ -443,12 +443,12 @@ private: base = 16; break; default: - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Unexpected base encountered while serializing integer type to TSDL: base = {}", (int) type.base_)); } - _description += fmt::format(" base = {};", base); + _description += lttng::format(" base = {};", base); } /* Defaults to the trace's native byte order. */ @@ -456,7 +456,7 @@ private: const auto byte_order_str = type.byte_order == lst::byte_order::BIG_ENDIAN_ ? "be" : "le"; - _description += fmt::format(" byte_order = {};", byte_order_str); + _description += lttng::format(" byte_order = {};", byte_order_str); } if (_current_integer_encoding_override) { @@ -470,12 +470,12 @@ private: encoding_str = "UTF8"; break; default: - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Unexpected encoding encountered while serializing integer type to TSDL: encoding = {}", (int) *_current_integer_encoding_override)); } - _description += fmt::format(" encoding = {};", encoding_str); + _description += lttng::format(" encoding = {};", encoding_str); _current_integer_encoding_override.reset(); } @@ -489,7 +489,7 @@ private: type.roles_.end()) { LTTNG_ASSERT(_default_clock_class_name); _description += - fmt::format(" map = clock.{}.value;", _default_clock_class_name); + lttng::format(" map = clock.{}.value;", _default_clock_class_name); } _description += " }"; @@ -497,7 +497,7 @@ private: void visit(const lst::floating_point_type& type) final { - _description += fmt::format( + _description += lttng::format( "floating_point {{ align = {alignment}; mant_dig = {mantissa_digits}; exp_dig = {exponent_digits};", fmt::arg("alignment", type.alignment), fmt::arg("mantissa_digits", type.mantissa_digits), @@ -508,7 +508,7 @@ private: const auto byte_order_str = type.byte_order == lst::byte_order::BIG_ENDIAN_ ? "be" : "le"; - _description += fmt::format(" byte_order = {};", byte_order_str); + _description += lttng::format(" byte_order = {};", byte_order_str); } _description += " }"; @@ -533,12 +533,12 @@ private: _description.resize(_description.size() + mappings_indentation_level, '\t'); if (mapping.range.begin == mapping.range.end) { - _description += - fmt::format("\"{mapping_name}\" = {mapping_value}", - fmt::arg("mapping_name", mapping.name), - fmt::arg("mapping_value", mapping.range.begin)); + _description += lttng::format( + "\"{mapping_name}\" = {mapping_value}", + fmt::arg("mapping_name", mapping.name), + fmt::arg("mapping_value", mapping.range.begin)); } else { - _description += fmt::format( + _description += lttng::format( "\"{mapping_name}\" = {mapping_range_begin} ... {mapping_range_end}", fmt::arg("mapping_name", mapping.name), fmt::arg("mapping_range_begin", mapping.range.begin), @@ -567,7 +567,7 @@ private: { if (type.alignment != 0) { LTTNG_ASSERT(_current_field_name.size() > 0); - _description += fmt::format( + _description += lttng::format( "struct {{ }} align({alignment}) {field_name}_padding;\n", fmt::arg("alignment", type.alignment), fmt::arg("field_name", _current_field_name.top())); @@ -575,7 +575,7 @@ private: } type.element_type->accept(*this); - _type_suffixes.emplace(fmt::format("[{}]", type.length)); + _type_suffixes.emplace(lttng::format("[{}]", type.length)); } void visit(const lst::dynamic_length_array_type& type) final @@ -588,7 +588,7 @@ private: * would allow us to express alignment constraints. */ LTTNG_ASSERT(_current_field_name.size() > 0); - _description += fmt::format( + _description += lttng::format( "struct {{ }} align({alignment}) {field_name}_padding;\n", fmt::arg("alignment", type.alignment), fmt::arg("field_name", _current_field_name.top())); @@ -596,7 +596,7 @@ private: } type.element_type->accept(*this); - _type_suffixes.emplace(fmt::format( + _type_suffixes.emplace(lttng::format( "[{}]", _bypass_identifier_escape ? *(type.length_field_location.elements_.end() - 1) : @@ -677,7 +677,7 @@ private: { if (type.alignment != 0) { LTTNG_ASSERT(_current_field_name.size() > 0); - _description += fmt::format( + _description += lttng::format( "struct {{ }} align({alignment}) {field_name}_padding;\n", fmt::arg("alignment", type.alignment), fmt::arg("field_name", _current_field_name.top())); @@ -685,7 +685,7 @@ private: } _indentation_level++; - _description += fmt::format( + _description += lttng::format( "variant <{}> {{\n", _bypass_identifier_escape ? *(type.selector_field_location.elements_.end() - 1) : @@ -703,7 +703,7 @@ private: for (const auto& field : type.choices_) { _description.resize(_description.size() + _indentation_level, '\t'); field.second->accept(*this); - _description += fmt::format(" {};\n", field.first.name); + _description += lttng::format(" {};\n", field.first.name); } _bypass_identifier_escape = previous_bypass_identifier_escape; @@ -790,14 +790,13 @@ public: void visit(const lst::environment_field& field) override { - _environment += fmt::format(" {} = {};\n", field.name, field.value); + _environment += lttng::format(" {} = {};\n", field.name, field.value); } void visit(const lst::environment_field& field) override { - _environment += fmt::format(" {} = \"{}\";\n", - field.name, - escape_tsdl_env_string_value(field.value)); + _environment += lttng::format( + " {} = \"{}\";\n", field.name, escape_tsdl_env_string_value(field.value)); } /* Only call once. */ @@ -835,7 +834,7 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::trace_class& trace_class.packet_header()->accept(packet_header_visitor); /* Declare type aliases, trace class, and packet header. */ - auto trace_class_tsdl = fmt::format( + auto trace_class_tsdl = lttng::format( "/* CTF {ctf_major}.{ctf_minor} */\n\n" "trace {{\n" " major = {ctf_major};\n" @@ -869,24 +868,24 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::trace_class& void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::clock_class& clock_class) { auto uuid_str = clock_class.uuid ? - fmt::format(" uuid = \"{}\";\n", lttng::utils::uuid_to_str(*clock_class.uuid)) : + lttng::format(" uuid = \"{}\";\n", lttng::utils::uuid_to_str(*clock_class.uuid)) : ""; /* Assumes a single clock that maps to specific stream class fields/roles. */ - auto clock_class_str = fmt::format("clock {{\n" - " name = \"{name}\";\n" - /* Optional uuid. */ - "{uuid}" - " description = \"{description}\";\n" - " freq = {frequency};\n" - " offset = {offset};\n" - "}};\n" - "\n", - fmt::arg("name", clock_class.name), - fmt::arg("uuid", uuid_str), - fmt::arg("description", clock_class.description), - fmt::arg("frequency", clock_class.frequency), - fmt::arg("offset", clock_class.offset)); + auto clock_class_str = lttng::format("clock {{\n" + " name = \"{name}\";\n" + /* Optional uuid. */ + "{uuid}" + " description = \"{description}\";\n" + " freq = {frequency};\n" + " offset = {offset};\n" + "}};\n" + "\n", + fmt::arg("name", clock_class.name), + fmt::arg("uuid", uuid_str), + fmt::arg("description", clock_class.description), + fmt::arg("frequency", clock_class.frequency), + fmt::arg("offset", clock_class.offset)); append_metadata_fragment(clock_class_str); } @@ -897,9 +896,9 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::stream_class const auto clear_stream_class_on_exit = lttng::make_scope_exit([this]() noexcept { _current_stream_class = nullptr; }); - auto stream_class_str = fmt::format("stream {{\n" - " id = {};\n", - stream_class.id); + auto stream_class_str = lttng::format("stream {{\n" + " id = {};\n", + stream_class.id); variant_tsdl_keyword_sanitizer variant_sanitizer( _sanitized_types_overrides, [this](const lttng::sessiond::trace::field_location& location) -> const lst::type& { @@ -915,8 +914,8 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::stream_class event_header->accept(variant_sanitizer); event_header->accept(event_header_visitor); - stream_class_str += fmt::format(" event.header := {};\n", - event_header_visitor.move_description()); + stream_class_str += lttng::format(" event.header := {};\n", + event_header_visitor.move_description()); } const auto *packet_context = stream_class.packet_context(); @@ -928,8 +927,8 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::stream_class packet_context->accept(variant_sanitizer); packet_context->accept(packet_context_visitor); - stream_class_str += fmt::format(" packet.context := {};\n", - packet_context_visitor.move_description()); + stream_class_str += lttng::format(" packet.context := {};\n", + packet_context_visitor.move_description()); } const auto *event_context = stream_class.event_context(); @@ -940,8 +939,8 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::stream_class event_context->accept(variant_sanitizer); event_context->accept(event_context_visitor); - stream_class_str += fmt::format(" event.context := {};\n", - event_context_visitor.move_description()); + stream_class_str += lttng::format(" event.context := {};\n", + event_context_visitor.move_description()); } stream_class_str += "};\n\n"; @@ -955,19 +954,20 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::event_class& const auto clear_event_class_on_exit = lttng::make_scope_exit([this]() noexcept { _current_event_class = nullptr; }); - auto event_class_str = fmt::format("event {{\n" - " name = \"{name}\";\n" - " id = {id};\n" - " stream_id = {stream_class_id};\n" - " loglevel = {log_level};\n", - fmt::arg("name", event_class.name), - fmt::arg("id", event_class.id), - fmt::arg("stream_class_id", event_class.stream_class_id), - fmt::arg("log_level", event_class.log_level)); + auto event_class_str = + lttng::format("event {{\n" + " name = \"{name}\";\n" + " id = {id};\n" + " stream_id = {stream_class_id};\n" + " loglevel = {log_level};\n", + fmt::arg("name", event_class.name), + fmt::arg("id", event_class.id), + fmt::arg("stream_class_id", event_class.stream_class_id), + fmt::arg("log_level", event_class.log_level)); if (event_class.model_emf_uri) { event_class_str += - fmt::format(" model.emf.uri = \"{}\";\n", *event_class.model_emf_uri); + lttng::format(" model.emf.uri = \"{}\";\n", *event_class.model_emf_uri); } tsdl_field_visitor payload_visitor{ _trace_abi, 1, _sanitized_types_overrides }; @@ -981,7 +981,7 @@ void tsdl::trace_class_visitor::visit(const lttng::sessiond::trace::event_class& event_class.payload->accept(payload_visitor); event_class_str += - fmt::format(" fields := {};\n}};\n\n", payload_visitor.move_description()); + lttng::format(" fields := {};\n}};\n\n", payload_visitor.move_description()); append_metadata_fragment(event_class_str); } @@ -1033,7 +1033,7 @@ lookup_type_from_root_type(const lttng::sessiond::trace::type& root_type, * safely. */ if (!struct_type) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Encountered a type that is not a structure while traversing field location: field-location=`{}`", field_location)); } @@ -1046,7 +1046,7 @@ lookup_type_from_root_type(const lttng::sessiond::trace::type& root_type, }); if (field_found_it == struct_type->fields_.cend()) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Failed to find field using field location: field-name:=`{field_name}`, field-location=`{field_location}`", fmt::arg("field_location", field_location), fmt::arg("field_name", location_element))); diff --git a/src/bin/lttng-sessiond/ust-app.cpp b/src/bin/lttng-sessiond/ust-app.cpp index b9091424b..d7b1275b0 100644 --- a/src/bin/lttng-sessiond/ust-app.cpp +++ b/src/bin/lttng-sessiond/ust-app.cpp @@ -6842,7 +6842,7 @@ static int add_enum_ust_registry(int sock, application_reply_code = 0; } catch (const std::exception& ex) { ERR("%s: %s", - fmt::format( + lttng::format( "Failed to create or find enumeration provided by application: app = {}, enumeration name = {}", *app, name) diff --git a/src/bin/lttng-sessiond/ust-field-convert.cpp b/src/bin/lttng-sessiond/ust-field-convert.cpp index 10736611c..b51ba7bfc 100644 --- a/src/bin/lttng-sessiond/ust-field-convert.cpp +++ b/src/bin/lttng-sessiond/ust-field-convert.cpp @@ -90,7 +90,7 @@ ust_ctl_encoding_to_string_field_encoding(UstCtlEncodingType encoding) const auto encoding_it = encoding_conversion_map.find(encoding); if (encoding_it == encoding_conversion_map.end()) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unknown lttng_ust_ctl_string_encodings value `{}` encountered when decoding integer field", encoding)); } @@ -109,7 +109,7 @@ enum lst::integer_type::base ust_ctl_base_to_integer_field_base(UstCtlBaseType b const auto base_it = base_conversion_map.find(base); if (base_it == base_conversion_map.end()) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unknown integer base value `{}` encountered when decoding integer field", base)); } @@ -125,7 +125,7 @@ create_integer_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current, lsu::ctl_field_quirks quirks __attribute__((unused))) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -154,7 +154,7 @@ create_floating_point_type_from_ust_ctl_fields(const lttng_ust_ctl_field *curren lsu::ctl_field_quirks quirks __attribute__((unused))) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -171,7 +171,7 @@ create_floating_point_type_from_ust_ctl_fields(const lttng_ust_ctl_field *curren current->type.u._float.exp_dig, current->type.u._float.mant_dig); } catch (lttng::invalid_argument_error& ex) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Invalid floating point attribute in {}: {}", typeid(*current), ex.what())); } } @@ -184,7 +184,7 @@ create_enumeration_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current, lsu::ctl_field_quirks quirks __attribute__((unused))) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -198,15 +198,15 @@ create_enumeration_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current, /* Nestable enumeration fields are followed by their container type. */ ++current; if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Array of {} is too short to contain nestable enumeration's container", typeid(*current))); } if (current->type.atype != lttng_ust_ctl_atype_integer) { - LTTNG_THROW_PROTOCOL_ERROR( - fmt::format("Invalid type of nestable enum container: type id = {}", - current->type.atype)); + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( + "Invalid type of nestable enum container: type id = {}", + current->type.atype)); } enum_container_uctl_type = ¤t->type.u.integer; @@ -259,7 +259,7 @@ create_string_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current, lsu::ctl_field_quirks quirks __attribute__((unused))) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -301,7 +301,7 @@ create_array_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current, lsu::ctl_field_quirks quirks __attribute__((unused))) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -315,7 +315,7 @@ create_array_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current, const auto& element_uctl_type = array_uctl_field.type.u.legacy.array.elem_type; if (element_uctl_type.atype != lttng_ust_ctl_atype_integer) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unexpected legacy array element type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})", element_uctl_type.atype, lttng_ust_ctl_atype_integer)); @@ -337,7 +337,7 @@ create_array_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current, static_cast(*element_type).size; if (integer_element_size != 8) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unexpected legacy array element type: integer has encoding but size is not 8: size = {}", integer_element_size)); } @@ -363,7 +363,7 @@ lst::type::cuptr create_array_nestable_type_from_ust_ctl_fields( lsu::ctl_field_quirks quirks) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -400,7 +400,7 @@ lst::type::cuptr create_array_nestable_type_from_ust_ctl_fields( static_cast(*element_type).size; if (integer_element_size != 8) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unexpected array element type: integer has encoding but size is not 8: size = {}", integer_element_size)); } @@ -429,7 +429,7 @@ lst::type::cuptr create_sequence_type_from_ust_ctl_fields( lsu::ctl_field_quirks quirks __attribute__((unused))) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -439,14 +439,14 @@ lst::type::cuptr create_sequence_type_from_ust_ctl_fields( const auto sequence_alignment = 0U; if (element_uctl_type.atype != lttng_ust_ctl_atype_integer) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unexpected legacy sequence element type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})", element_uctl_type.atype, lttng_ust_ctl_atype_integer)); } if (length_uctl_type.atype != lttng_ust_ctl_atype_integer) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unexpected legacy sequence length field type: atype = {}, expected atype = lttng_ust_ctl_atype_integer ({})", length_uctl_type.atype, lttng_ust_ctl_atype_integer)); @@ -460,7 +460,7 @@ lst::type::cuptr create_sequence_type_from_ust_ctl_fields( element_uctl_type.u.basic.integer.encoding); } - auto length_field_name = fmt::format("_{}_length", sequence_uctl_field.name); + auto length_field_name = lttng::format("_{}_length", sequence_uctl_field.name); auto element_type = create_integer_type_from_ust_ctl_basic_type(element_uctl_type, session_attributes); auto length_type = @@ -484,7 +484,7 @@ lst::type::cuptr create_sequence_type_from_ust_ctl_fields( static_cast(*element_type).size; if (integer_element_size != 8) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unexpected legacy array element type: integer has encoding but size is not 8: size = {}", integer_element_size)); } @@ -510,7 +510,7 @@ lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields( lsu::ctl_field_quirks quirks) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -567,7 +567,7 @@ lst::type::cuptr create_sequence_nestable_type_from_ust_ctl_fields( static_cast(*element_type).size; if (integer_element_size != 8) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unexpected array element type: integer has encoding but size is not 8: size = {}", integer_element_size)); } @@ -590,7 +590,7 @@ create_structure_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current, lsu::ctl_field_quirks quirks __attribute__((unused))) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -607,7 +607,7 @@ create_structure_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current, } if (field_count != 0) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Only empty structures are supported by LTTng-UST: nr_fields = {}", field_count)); } @@ -673,7 +673,7 @@ create_typed_variant_choices(const lttng_ust_ctl_field *current, }); if (mapping_it == typed_enumeration.mappings_->end()) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Invalid variant choice: `{}` does not match any mapping in `{}` enumeration", field->name, selector_field.name)); @@ -703,7 +703,7 @@ lst::type::cuptr create_variant_field_from_ust_ctl_fields( lsu::ctl_field_quirks quirks) { if (current >= end) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "End of {} array reached unexpectedly during decoding", typeid(*current))); } @@ -855,11 +855,11 @@ create_type_from_ust_ctl_fields(const lttng_ust_ctl_field *current, quirks); default: LTTNG_THROW_PROTOCOL_ERROR( - fmt::format("Unknown {} value `{}` encountered while converting {} to {}", - typeid(current->type.atype), - current->type.atype, - typeid(*current), - typeid(lst::type::cuptr::element_type))); + lttng::format("Unknown {} value `{}` encountered while converting {} to {}", + typeid(current->type.atype), + current->type.atype, + typeid(*current), + typeid(lst::type::cuptr::element_type))); } } @@ -877,7 +877,7 @@ void create_field_from_ust_ctl_fields(const lttng_ust_ctl_field *current, if (lttng_strnlen(current->name, sizeof(current->name)) == sizeof(current->name)) { LTTNG_THROW_PROTOCOL_ERROR( - fmt::format("Name of {} is not null-terminated", typeid(*current))); + lttng::format("Name of {} is not null-terminated", typeid(*current))); } publish_field(lttng::make_unique( @@ -897,7 +897,7 @@ std::vector::iterator lookup_field_in_vector(std::vector& fields, const lst::field_location& location) { if (location.elements_.size() != 1) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Unexpected field location received during field look-up: location = {}", location)); } @@ -916,7 +916,7 @@ lookup_field_in_vector(std::vector& fields, const lst::field_ if (field_it == fields.end()) { LTTNG_THROW_PROTOCOL_ERROR( - fmt::format("Failed to look-up field: location = {}", location)); + lttng::format("Failed to look-up field: location = {}", location)); } return field_it; diff --git a/src/bin/lttng-sessiond/ust-registry-channel.cpp b/src/bin/lttng-sessiond/ust-registry-channel.cpp index 03532cd09..f4c8f226e 100644 --- a/src/bin/lttng-sessiond/ust-registry-channel.cpp +++ b/src/bin/lttng-sessiond/ust-registry-channel.cpp @@ -388,14 +388,14 @@ void lsu::registry_channel::add_event(int session_objd, * external party, don't assert and simply validate values. */ if (session_objd < 0) { - LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format( + LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format( "Invalid session object descriptor provided by application: session descriptor = {}, app = {}", session_objd, app)); } if (channel_objd < 0) { - LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format( + LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format( "Invalid channel object descriptor provided by application: channel descriptor = {}, app = {}", channel_objd, app)); @@ -403,7 +403,7 @@ void lsu::registry_channel::add_event(int session_objd, /* Check if we've reached the maximum possible id. */ if (is_max_event_id(_next_event_id)) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Failed to allocate new event id (id would overflow): app = {}", app)); } @@ -418,7 +418,7 @@ void lsu::registry_channel::add_event(int session_objd, loglevel_value, std::move(model_emf_uri))); - DBG3("%s", fmt::format("UST registry creating event: event = {}", *event).c_str()); + DBG3("%s", lttng::format("UST registry creating event: event = {}", *event).c_str()); /* * This is an add unique with a custom match function for event. The node @@ -439,7 +439,7 @@ void lsu::registry_channel::add_event(int session_objd, nptr, <tng::sessiond::ust::registry_event::_node); event_id = existing_event->id; } else { - LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format( + LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format( "UST registry create event add unique failed for event: event = {}", *event)); } diff --git a/src/bin/lttng-sessiond/ust-registry-session.cpp b/src/bin/lttng-sessiond/ust-registry-session.cpp index c75fc3848..518108cbd 100644 --- a/src/bin/lttng-sessiond/ust-registry-session.cpp +++ b/src/bin/lttng-sessiond/ust-registry-session.cpp @@ -240,7 +240,7 @@ lsu::registry_session::registry_session(const struct lst::abi& in_abi, lst::trace_class(in_abi, generate_uuid_or_throw()), _root_shm_path{ root_shm_path ? root_shm_path : "" }, _shm_path{ shm_path ? shm_path : "" }, - _metadata_path{ _shm_path.size() > 0 ? fmt::format("{}/metadata", _shm_path) : + _metadata_path{ _shm_path.size() > 0 ? lttng::format("{}/metadata", _shm_path) : std::string("") }, _uid{ euid }, _gid{ egid }, @@ -268,7 +268,7 @@ lsu::registry_session::registry_session(const struct lst::abi& in_abi, egid); if (ret < 0) { LTTNG_THROW_POSIX( - fmt::format( + lttng::format( "Failed to open metadata file during registry session creation: path = {}", _metadata_path), errno); @@ -451,7 +451,7 @@ void lsu::registry_session::add_channel(uint64_t key) * the metadata can be dumped for that event. */ if (is_max_channel_id(_used_channel_id)) { - LTTNG_THROW_ERROR(fmt::format( + LTTNG_THROW_ERROR(lttng::format( "Failed to allocate unique id for channel under session while adding channel")); } @@ -496,8 +496,8 @@ lttng::sessiond::ust::registry_channel& lsu::registry_session::channel(uint64_t lttng_ht_lookup(_channels.get(), &channel_key, &iter); node = lttng_ht_iter_get_node_u64(&iter); if (!node) { - LTTNG_THROW_INVALID_ARGUMENT_ERROR( - fmt::format("Invalid channel key provided: channel key = {}", channel_key)); + LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format( + "Invalid channel key provided: channel key = {}", channel_key)); } DIAGNOSTIC_PUSH @@ -722,7 +722,7 @@ lsu::registry_session::enumeration(const char *enum_name, uint64_t enum_id) cons &iter.iter); node = lttng_ht_iter_get_node_str(&iter); if (!node) { - LTTNG_THROW_PROTOCOL_ERROR(fmt::format( + LTTNG_THROW_PROTOCOL_ERROR(lttng::format( "Unknown enumeration referenced by application event field: enum name = `{}`, enum id = {}", enum_name, enum_id)); @@ -795,12 +795,12 @@ void lsu::registry_session::create_or_find_enum(int session_objd, * external party, don't assert and simply validate values. */ if (session_objd < 0) { - LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format( + LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format( "Invalid parameters used to create or look-up enumeration from registry session: session_objd = {}", session_objd)); } if (nr_entries == 0) { - LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format( + LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format( "Invalid parameters used to create or look-up enumeration from registry session: nr_entries = {}", nr_entries)); } diff --git a/src/bin/lttng/commands/destroy.cpp b/src/bin/lttng/commands/destroy.cpp index 019906a20..0258e31e8 100644 --- a/src/bin/lttng/commands/destroy.cpp +++ b/src/bin/lttng/commands/destroy.cpp @@ -74,7 +74,7 @@ cmd_error_code destroy_session(const lttng_session& session) ret = lttng_stop_tracing_no_wait(session.name); if (ret < 0 && ret != -LTTNG_ERR_TRACE_ALREADY_STOPPED) { - LTTNG_THROW_CTL(fmt::format("Failed to stop session `{}`", session.name), + LTTNG_THROW_CTL(lttng::format("Failed to stop session `{}`", session.name), static_cast(-ret)); } @@ -134,7 +134,8 @@ cmd_error_code destroy_session(const lttng_session& session) auto ctl_ret_code = lttng_destroy_session_ext(session.name, &raw_destruction_handle); if (ctl_ret_code != LTTNG_OK) { - LTTNG_THROW_CTL(fmt::format("Failed to destroy session `{}`", session.name), + LTTNG_THROW_CTL(lttng::format("Failed to destroy session `{}`", + session.name), ctl_ret_code); } @@ -184,7 +185,8 @@ cmd_error_code destroy_session(const lttng_session& session) } if (ctl_ret_code != LTTNG_OK) { - LTTNG_THROW_CTL(fmt::format("Failed to destroy session `{}`", session.name), + LTTNG_THROW_CTL(lttng::format("Failed to destroy session `{}`", + session.name), ctl_ret_code); } diff --git a/src/bin/lttng/commands/start.cpp b/src/bin/lttng/commands/start.cpp index 29cff53c2..f78d3e708 100644 --- a/src/bin/lttng/commands/start.cpp +++ b/src/bin/lttng/commands/start.cpp @@ -89,7 +89,7 @@ cmd_error_code start_tracing(const char *session_name) const int ret = lttng_start_tracing(session_name); if (ret < 0) { - LTTNG_THROW_CTL(fmt::format("Failed to start session `{}`", session_name), + LTTNG_THROW_CTL(lttng::format("Failed to start session `{}`", session_name), static_cast(-ret)); } diff --git a/src/bin/lttng/commands/stop.cpp b/src/bin/lttng/commands/stop.cpp index 8b33bd7f4..af42d98db 100644 --- a/src/bin/lttng/commands/stop.cpp +++ b/src/bin/lttng/commands/stop.cpp @@ -91,7 +91,7 @@ cmd_error_code stop_tracing(const char *session_name) ret = lttng_stop_tracing_no_wait(session_name); if (ret < 0) { - LTTNG_THROW_CTL(fmt::format("Failed to start session `{}`", session_name), + LTTNG_THROW_CTL(lttng::format("Failed to start session `{}`", session_name), static_cast(-ret)); } diff --git a/src/common/container-wrapper.hpp b/src/common/container-wrapper.hpp index c2c59f89d..0ed96d44a 100644 --- a/src/common/container-wrapper.hpp +++ b/src/common/container-wrapper.hpp @@ -144,7 +144,7 @@ public: operator[](std::size_t index) const { if (index >= ContainerOperations::size(_container)) { - LTTNG_THROW_INVALID_ARGUMENT_ERROR(fmt::format( + LTTNG_THROW_INVALID_ARGUMENT_ERROR(lttng::format( "Out of bound access through random_access_container_wrapper: index={}, size={}", index, size())); diff --git a/src/common/error.hpp b/src/common/error.hpp index 5935cf151..23d840c2d 100644 --- a/src/common/error.hpp +++ b/src/common/error.hpp @@ -266,7 +266,7 @@ namespace details { #define DBG_FMT(format_str, args...) \ do { \ try { \ - DBG("%s", fmt::format(format_str, ##args).c_str()); \ + DBG("%s", lttng::format(format_str, ##args).c_str()); \ } catch (const std::exception& _formatting_exception) { \ lttng::logging::details::die_formatting_exception(format_str, \ _formatting_exception); \ @@ -276,7 +276,7 @@ namespace details { #define WARN_FMT(format_str, args...) \ do { \ try { \ - WARN("%s", fmt::format(format_str, ##args).c_str()); \ + WARN("%s", lttng::format(format_str, ##args).c_str()); \ } catch (const std::exception& _formatting_exception) { \ lttng::logging::details::die_formatting_exception(format_str, \ _formatting_exception); \ @@ -286,7 +286,7 @@ namespace details { #define ERR_FMT(format_str, args...) \ do { \ try { \ - ERR("%s", fmt::format(format_str, ##args).c_str()); \ + ERR("%s", lttng::format(format_str, ##args).c_str()); \ } catch (const std::exception& _formatting_exception) { \ lttng::logging::details::die_formatting_exception(format_str, \ _formatting_exception); \ diff --git a/src/common/eventfd.cpp b/src/common/eventfd.cpp index 685852682..cb12a51ab 100644 --- a/src/common/eventfd.cpp +++ b/src/common/eventfd.cpp @@ -36,7 +36,7 @@ void lttng::eventfd::increment(std::uint64_t value) try { write(&value, sizeof(value)); } catch (const std::exception& e) { - LTTNG_THROW_ERROR(fmt::format("Failed to increment eventfd: {}", e.what())); + LTTNG_THROW_ERROR(lttng::format("Failed to increment eventfd: {}", e.what())); } } @@ -47,7 +47,7 @@ std::uint64_t lttng::eventfd::decrement() try { read(&value, sizeof(value)); } catch (const std::exception& e) { - LTTNG_THROW_ERROR(fmt::format("Failed to decrement eventfd: {}", e.what())); + LTTNG_THROW_ERROR(lttng::format("Failed to decrement eventfd: {}", e.what())); } return value; diff --git a/src/common/file-descriptor.cpp b/src/common/file-descriptor.cpp index 6f6a6be24..93d7b699f 100644 --- a/src/common/file-descriptor.cpp +++ b/src/common/file-descriptor.cpp @@ -77,7 +77,7 @@ void lttng::file_descriptor::write(const void *buffer, std::size_t size) std::numeric_limits::max(); if (size > max_supported_write_size) { - LTTNG_THROW_UNSUPPORTED_ERROR(fmt::format( + LTTNG_THROW_UNSUPPORTED_ERROR(lttng::format( "Write size exceeds the maximal supported value of lttng_write: write_size={}, maximal_write_size={}", size, max_supported_write_size)); @@ -85,7 +85,7 @@ void lttng::file_descriptor::write(const void *buffer, std::size_t size) const auto write_ret = lttng_write(fd(), buffer, size); if (write_ret < 0 || static_cast(write_ret) != size) { - LTTNG_THROW_POSIX(fmt::format("Failed to write to file descriptor: fd={}", fd()), + LTTNG_THROW_POSIX(lttng::format("Failed to write to file descriptor: fd={}", fd()), errno); } } @@ -101,7 +101,7 @@ void lttng::file_descriptor::read(void *buffer, std::size_t size) constexpr auto max_supported_read_size = std::numeric_limits::max(); if (size > max_supported_read_size) { - LTTNG_THROW_UNSUPPORTED_ERROR(fmt::format( + LTTNG_THROW_UNSUPPORTED_ERROR(lttng::format( "Read size exceeds the maximal supported value of lttng_read: read_size={}, maximal_read_size={}", size, max_supported_read_size)); @@ -109,7 +109,7 @@ void lttng::file_descriptor::read(void *buffer, std::size_t size) const auto read_ret = lttng_read(fd(), buffer, size); if (read_ret < 0 || static_cast(read_ret) != size) { - LTTNG_THROW_POSIX(fmt::format("Failed to read from file descriptor: fd={}", fd()), + LTTNG_THROW_POSIX(lttng::format("Failed to read from file descriptor: fd={}", fd()), errno); } } diff --git a/src/common/format.hpp b/src/common/format.hpp index 389bc596a..c1ab3d54d 100644 --- a/src/common/format.hpp +++ b/src/common/format.hpp @@ -11,6 +11,7 @@ #include #include +#include DIAGNOSTIC_PUSH DIAGNOSTIC_IGNORE_SUGGEST_ATTRIBUTE_FORMAT @@ -42,4 +43,16 @@ struct formatter : formatter { }; } /* namespace fmt */ +namespace lttng { +template +std::string format(FormattingArguments&&...args) +{ + try { + return fmt::format(std::forward(args)...); + } catch (const fmt::format_error& ex) { + return std::string("Failed to format string: ") += ex.what(); + } +} +} /* namespace lttng */ + #endif /* LTTNG_FORMAT_H */ diff --git a/src/common/random.cpp b/src/common/random.cpp index 26f51d3a4..ba9d937ba 100644 --- a/src/common/random.cpp +++ b/src/common/random.cpp @@ -67,8 +67,8 @@ void getrandom_nonblock(char *out_data, std::size_t size) if (ret < 0) { LTTNG_THROW_POSIX( - fmt::format("Failed to get true random data using getrandom(): size={}", - size), + lttng::format("Failed to get true random data using getrandom(): size={}", + size), errno); } } @@ -152,7 +152,7 @@ lttng::random::seed_t produce_random_seed_from_urandom() try { urandom.read(&seed, sizeof(seed)); } catch (const std::exception& e) { - LTTNG_THROW_RANDOM_PRODUCTION_ERROR(fmt::format( + LTTNG_THROW_RANDOM_PRODUCTION_ERROR(lttng::format( "Failed to read from `/dev/urandom`: size={}: {}", sizeof(seed), e.what())); } @@ -183,7 +183,7 @@ lttng::random::seed_t lttng::random::produce_best_effort_random_seed() return lttng::random::produce_true_random_seed(); } catch (const std::exception& e) { WARN("%s", - fmt::format( + lttng::format( "Failed to produce a random seed using getrandom(), falling back to pseudo-random device seed generation which will block until its pool is initialized: {}", e.what()) .c_str()); @@ -197,8 +197,8 @@ lttng::random::seed_t lttng::random::produce_best_effort_random_seed() produce_random_seed_from_urandom(); } catch (const std::exception& e) { WARN("%s", - fmt::format("Failed to produce a random seed from the urandom device: {}", - e.what()) + lttng::format("Failed to produce a random seed from the urandom device: {}", + e.what()) .c_str()); } -- 2.34.1