diff --git a/src/native/clr/host/bridge-processing.cc b/src/native/clr/host/bridge-processing.cc index ad7bb02639b..49451f02475 100644 --- a/src/native/clr/host/bridge-processing.cc +++ b/src/native/clr/host/bridge-processing.cc @@ -32,7 +32,7 @@ TemporaryPeerMap::TemporaryPeerMap (JNIEnv *jni_env, MarkCrossReferencesArgs *ar if (env->EnsureLocalCapacity (requested_capacity) != JNI_OK) [[unlikely]] { env->ExceptionClear (); - log_warn (LOG_GC, "Failed to reserve JNI local reference capacity for {} temporary peers", map_capacity); + log_warnf (LOG_GC, "Failed to reserve JNI local reference capacity for %zu temporary peers", map_capacity); } capacity = map_capacity; @@ -470,7 +470,7 @@ void BridgeProcessingShared::log_missing_add_references_method ([[maybe_unused]] } char *class_name = Host::get_java_class_name_for_TypeManager (java_class); - log_error (LOG_GC, "Missing monodroidAddReferences method for object of class {}", optional_string (class_name)); + log_errorf (LOG_GC, "Missing monodroidAddReferences method for object of class %s", optional_string (class_name)); free (class_name); #endif } @@ -486,7 +486,7 @@ void BridgeProcessingShared::log_missing_clear_references_method ([[maybe_unused } char *class_name = Host::get_java_class_name_for_TypeManager (java_class); - log_error (LOG_GC, "Missing monodroidClearReferences method for object of class {}", optional_string (class_name)); + log_errorf (LOG_GC, "Missing monodroidClearReferences method for object of class %s", optional_string (class_name)); free (class_name); #endif } @@ -594,5 +594,5 @@ void BridgeProcessingShared::log_gc_summary () noexcept } } - log_info (LOG_GC, "GC cleanup summary: {} objects tested - resurrecting {}.", total, alive); + log_infof (LOG_GC, "GC cleanup summary: %zu objects tested - resurrecting %zu.", total, alive); } diff --git a/src/native/clr/runtime-base/logger.cc b/src/native/clr/runtime-base/logger.cc index 07edfa25d8d..ffbf9da565c 100644 --- a/src/native/clr/runtime-base/logger.cc +++ b/src/native/clr/runtime-base/logger.cc @@ -67,7 +67,7 @@ auto Logger::open_file (LogCategories category, std::string_view const& custom_p { auto log_and_return = [&category](FILE *f, std::string_view const& path) -> FILE* { if (f != nullptr) { - log_debug (category, "Opened file '{}' for logging.", path); + log_debugf (category, "Opened file '%.*s' for logging.", static_cast(path.length ()), path.data ()); } return f; }; @@ -193,7 +193,13 @@ Logger::init_logging_categories () noexcept auto file_name = segment.at (offset); if (!file_name.has_value ()) { - log_warn (LOG_DEFAULT, "Unable to set path to {} log file: {}", file_kind, to_string (file_name.error ())); + log_warnf ( + LOG_DEFAULT, + "Unable to set path to %.*s log file: %s", + static_cast(file_kind.length ()), + file_kind.data (), + to_string (file_name.error ()) + ); return {}; } diff --git a/src/native/common/include/runtime-base/strings.hh b/src/native/common/include/runtime-base/strings.hh index 589e2f45653..157ba36b050 100644 --- a/src/native/common/include/runtime-base/strings.hh +++ b/src/native/common/include/runtime-base/strings.hh @@ -36,16 +36,14 @@ namespace xamarin::android { index_out_of_range, }; - static inline auto to_string (string_segment_error error) -> std::string_view const + static constexpr auto to_string (string_segment_error error) -> const char* { - using std::operator""sv; - switch (error) { case string_segment_error::index_out_of_range: - return "Index out of range"sv; + return "Index out of range"; default: - return "Unknown error"sv; + return "Unknown error"; } }