diff --git a/examples/mir_demo_server/server_example_test_client.cpp b/examples/mir_demo_server/server_example_test_client.cpp index 4eb8b6d7706..a37d417a99c 100644 --- a/examples/mir_demo_server/server_example_test_client.cpp +++ b/examples/mir_demo_server/server_example_test_client.cpp @@ -143,11 +143,14 @@ void me::TestClientRunner::operator()(mir::Server& server) setenv("SDL_VIDEODRIVER", "wayland", true); // configure SDL to use Wayland auto const client = options1->get(test_client_opt); - log(logging::Severity::informational, "mir::examples", "Starting test client: %s", client.c_str()); + log(logging::Severity::informational, "mir::examples", "Starting test client: {}", client); execlp(client.c_str(), client.c_str(), static_cast(nullptr)); // If execl() returns then something is badly wrong - log(logging::Severity::critical, "mir::examples", - "Failed to execute client (%s) error: %s", client.c_str(), mir::errno_to_cstr(errno)); + log(logging::Severity::critical, + "mir::examples", + "Failed to execute client ({}) error: {}", + client, + mir::errno_to_cstr(errno)); abort(); } else if (pid > 0) diff --git a/include/core/mir/log.h b/include/core/mir/log.h index 38939b66512..c8e88bbec51 100644 --- a/include/core/mir/log.h +++ b/include/core/mir/log.h @@ -21,17 +21,12 @@ #include // for Severity #include -#include +#include +#include #include namespace mir { -[[gnu::format (printf, 3, 0)]] -void logv(logging::Severity sev, const char *component, - char const* fmt, va_list va); -[[gnu::format (printf, 3, 4)]] -void log(logging::Severity sev, const char *component, - char const* fmt, ...); void log(logging::Severity sev, const char *component, std::string const& message); void log( @@ -40,6 +35,13 @@ void log( std::exception_ptr const& exception, std::string const& message); +template +inline void log( + logging::Severity sev, std::string_view const component, std::format_string fmt, Args&&... args) +{ + log(sev, component.data(), std::format(fmt, std::forward(args)...)); +} + /// Log a security event according to the OWASP specification /// /// \param severity The severity of the event @@ -67,34 +69,22 @@ inline void log_info(std::string const& message) MIR_LOG_COMPONENT, message); } -[[gnu::format (printf, 1, 2)]] -inline void log_info(char const* fmt, ...) +template +inline void log_info(std::format_string fmt, Args&&... args) { - va_list va; - va_start(va, fmt); - ::mir::logv(::mir::logging::Severity::informational, - MIR_LOG_COMPONENT, fmt, va); - va_end(va); + ::mir::log(::mir::logging::Severity::informational, MIR_LOG_COMPONENT, fmt, std::forward(args)...); } -[[gnu::format (printf, 1, 2)]] -inline void log_error(char const* fmt, ...) +template +inline void log_error(std::format_string fmt, Args&&... args) { - va_list va; - va_start(va, fmt); - ::mir::logv(::mir::logging::Severity::error, - MIR_LOG_COMPONENT, fmt, va); - va_end(va); + ::mir::log(::mir::logging::Severity::error, MIR_LOG_COMPONENT, fmt, std::forward(args)...); } -[[gnu::format (printf, 1, 2)]] -inline void log_debug(char const* fmt, ...) +template +inline void log_debug(std::format_string fmt, Args&&... args) { - va_list va; - va_start(va, fmt); - ::mir::logv(::mir::logging::Severity::debug, - MIR_LOG_COMPONENT, fmt, va); - va_end(va); + ::mir::log(::mir::logging::Severity::debug, MIR_LOG_COMPONENT, fmt, std::forward(args)...); } inline void log_critical(std::string const& message) @@ -103,14 +93,10 @@ inline void log_critical(std::string const& message) MIR_LOG_COMPONENT, message); } -[[gnu::format(printf, 1, 2)]] -inline void log_critical(char const* fmt, ...) +template +inline void log_critical(std::format_string fmt, Args&&... args) { - va_list va; - va_start(va, fmt); - ::mir::logv(::mir::logging::Severity::critical, - MIR_LOG_COMPONENT, fmt, va); - va_end(va); + ::mir::log(::mir::logging::Severity::critical, MIR_LOG_COMPONENT, fmt, std::forward(args)...); } inline void log_error(std::string const& message) @@ -125,14 +111,10 @@ inline void log_warning(std::string const& message) MIR_LOG_COMPONENT, message); } -[[gnu::format(printf, 1, 2)]] -inline void log_warning(char const* fmt, ...) +template +inline void log_warning(std::format_string fmt, Args&&... args) { - va_list va; - va_start(va, fmt); - ::mir::logv(::mir::logging::Severity::warning, - MIR_LOG_COMPONENT, fmt, va); - va_end(va); + ::mir::log(::mir::logging::Severity::warning, MIR_LOG_COMPONENT, fmt, std::forward(args)...); } } // (nested anonymous) namespace #endif diff --git a/include/core/mir/logging/logger.h b/include/core/mir/logging/logger.h index 743aebe21ba..348640c837f 100644 --- a/include/core/mir/logging/logger.h +++ b/include/core/mir/logging/logger.h @@ -17,6 +17,7 @@ #ifndef MIR_LOGGING_LOGGER_H_ #define MIR_LOGGING_LOGGER_H_ +#include #include #include #include @@ -44,15 +45,11 @@ class Logger const std::string& message, const std::string& component) = 0; - /* - * Those playing at home may wonder why we're saying the 4th argument is the format string, - * when it's the 3rd argument in the signature. - * - * The answer, of course, is that the attribute doesn't know about the implicit - * 'this' first parameter of C++! - */ - virtual void log(char const* component, Severity severity, char const* format, ...) - __attribute__ ((format (printf, 4, 5))); + template + void log(char const* component, Severity severity, std::format_string fmt, Args&&... args) + { + log(severity, std::format(fmt, std::forward(args)...), component); + } protected: Logger() {} diff --git a/src/common/handle_event_exception.h b/src/common/handle_event_exception.h index a5e107e36ff..16f5d166eff 100644 --- a/src/common/handle_event_exception.h +++ b/src/common/handle_event_exception.h @@ -23,6 +23,6 @@ } \ catch(std::exception const& e) \ { \ - mir::log_critical("%s", e.what()); \ + mir::log_critical("{}", e.what()); \ abort(); \ } diff --git a/src/common/sharedlibrary/shared_library.cpp b/src/common/sharedlibrary/shared_library.cpp index ae679edadc5..5ca28b94d47 100644 --- a/src/common/sharedlibrary/shared_library.cpp +++ b/src/common/sharedlibrary/shared_library.cpp @@ -63,7 +63,7 @@ void* mir::SharedLibrary::load_symbol(char const* function_name, char const* ver #ifdef MIR_DONT_USE_DLVSYM // Load the function without checking the version - log_debug("Cannot check \"%s\" symbol version is \"%s\": dlvsym() is unavailable", function_name, version); + log_debug("Cannot check \"{}\" symbol version is \"{}\": dlvsym() is unavailable", function_name, version); return load_symbol(function_name); #else if (void* result = dlvsym(so, function_name, version)) diff --git a/src/core/log.cpp b/src/core/log.cpp index 9fd1d9e98c4..099ec22f638 100644 --- a/src/core/log.cpp +++ b/src/core/log.cpp @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include @@ -27,36 +26,12 @@ namespace mir { -void logv(logging::Severity sev, char const* component, - char const* fmt, va_list va) -{ - char message[1024]; - int max = sizeof(message) - 1; - int len = vsnprintf(message, max, fmt, va); - if (len > max) - len = max; - message[len] = '\0'; - - // Suboptimal: Constructing a std::string for message/component. - logging::log(sev, message, component); -} - -void log(logging::Severity sev, char const* component, - char const* fmt, ...) -{ - va_list va; - va_start(va, fmt); - logv(sev, component, fmt, va); - va_end(va); -} - void log(logging::Severity sev, char const* component, std::string const& message) { logging::log(sev, message, component); } - void log( logging::Severity severity, char const* component, @@ -71,20 +46,22 @@ void log( { // TODO: We can probably format this better by pulling out // the boost::errinfo's ourselves. - mir::log( + logging::log( severity, component, - "%s: %s", - message.c_str(), - boost::diagnostic_information(err).c_str()); + std::format( + "{}: {}", + message.c_str(), + boost::diagnostic_information(err).c_str())); } catch(...) { - mir::log( + logging::log( severity, component, - "%s: unknown exception", - message.c_str()); + std::format( + "{}: unknown exception", + message)); } } diff --git a/src/core/logging/logger.cpp b/src/core/logging/logger.cpp index 175a898a3bd..0e07dd617d0 100644 --- a/src/core/logging/logger.cpp +++ b/src/core/logging/logger.cpp @@ -25,19 +25,6 @@ namespace ml = mir::logging; -void ml::Logger::log(char const* component, Severity severity, char const* format, ...) -{ - auto const bufsize = 4096; - va_list va; - va_start(va, format); - char message[bufsize]; - vsnprintf(message, bufsize, format, va); - va_end(va); - - // Inefficient, but maintains API: Constructing a std::string for message/component. - log(severity, std::string{message}, std::string{component}); -} - namespace { std::mutex log_mutex; diff --git a/src/miral/application_switcher.cpp b/src/miral/application_switcher.cpp index 06b4699b029..b51298d9bb2 100644 --- a/src/miral/application_switcher.cpp +++ b/src/miral/application_switcher.cpp @@ -79,7 +79,7 @@ struct ToplevelInfoPrinter if (FT_New_Face(lib, mir::default_font().c_str(), 0, &face)) { - mir::log_error("Failed to load find: %s", mir::default_font().c_str()); + mir::log_error("Failed to load find: {}", mir::default_font()); FT_Done_FreeType(lib); return; } diff --git a/src/miral/basic_window_manager.cpp b/src/miral/basic_window_manager.cpp index cb93d4cf0f0..9074ef4ffc4 100644 --- a/src/miral/basic_window_manager.cpp +++ b/src/miral/basic_window_manager.cpp @@ -132,8 +132,8 @@ void miral::BasicWindowManager::remove_session(std::shared_ptr c if (info == app_info.end()) { log_debug( - "BasicWindowManager::remove_session() called with unknown or already removed session %s (PID: %d)", - session->name().c_str(), + "BasicWindowManager::remove_session() called with unknown or already removed session {} (PID: {})", + session->name(), session->process_id()); return; } @@ -237,8 +237,8 @@ void miral::BasicWindowManager::remove_surface( if (app_info.find(session) == app_info.end()) { log_debug( - "BasicWindowManager::remove_surface() called with unknown or already removed session %s (PID: %d)", - session->name().c_str(), + "BasicWindowManager::remove_surface() called with unknown or already removed session {} (PID: {})", + session->name(), session->process_id()); return; } @@ -1773,10 +1773,7 @@ auto miral::BasicWindowManager::surface_known( else description = "null surface"; - log_debug( - "%s requested on %s", - action.c_str(), - description.c_str()); + log_debug("{} requested on {}", action, description); return false; } diff --git a/src/miral/bounce_keys.cpp b/src/miral/bounce_keys.cpp index 2531ab28d2a..a643e78a25f 100644 --- a/src/miral/bounce_keys.cpp +++ b/src/miral/bounce_keys.cpp @@ -171,8 +171,8 @@ miral::BounceKeys::BounceKeys(live_config::Store& config_store) : else { mir::log_warning( - "Config value %s does not support negative values. Ignoring the supplied value (%d)...", - key.to_string().c_str(), + "Config value {} does not support negative values. Ignoring the supplied value ({})...", + key.to_string(), *val); } } diff --git a/src/miral/config_file.cpp b/src/miral/config_file.cpp index 554b22a421f..cce5f9aff06 100644 --- a/src/miral/config_file.cpp +++ b/src/miral/config_file.cpp @@ -105,7 +105,7 @@ Watcher::Watcher(path file, miral::ConfigFile::Loader load_config) : { if (directory_watch_descriptor.has_value()) { - mir::log_debug("Monitoring %s for configuration changes", (directory.value()/filename).c_str()); + mir::log_debug("Monitoring {} for configuration changes", (directory.value() / filename).string()); } } @@ -143,7 +143,7 @@ miral::ConfigFile::Self::Self(MirRunner& runner, path file, Mode mode, Loader lo if (std::ifstream config_file{filepath}) { load_config(config_file, filepath); - mir::log_debug("Loaded %s", filepath.c_str()); + mir::log_debug("Loaded {}", filepath.string()); break; } } @@ -213,11 +213,11 @@ void Watcher::handler(int) const if (std::ifstream config_file{file}) { load_config(config_file, file); - mir::log_debug("(Re)loaded %s", file.c_str()); + mir::log_debug("(Re)loaded {}", file.string()); } else { - mir::log_debug("Failed to open %s", file.c_str()); + mir::log_debug("Failed to open {}", file.string()); } } } diff --git a/src/miral/cursor_scale.cpp b/src/miral/cursor_scale.cpp index 8d32e1dc90e..ba0eabe7646 100644 --- a/src/miral/cursor_scale.cpp +++ b/src/miral/cursor_scale.cpp @@ -157,8 +157,9 @@ miral::CursorScale::CursorScale(live_config::Store& config_store) : miral::Curso else { mir::log_warning( - "Config value %s does not support negative values. Ignoring the supplied value (%f)...", - key.to_string().c_str(), *val); + "Config value {} does not support negative values. Ignoring the supplied value ({})...", + key.to_string(), + *val); } } else diff --git a/src/miral/cursor_theme.cpp b/src/miral/cursor_theme.cpp index d4b0344f24b..053cc120a12 100644 --- a/src/miral/cursor_theme.cpp +++ b/src/miral/cursor_theme.cpp @@ -66,7 +66,7 @@ void miral::CursorTheme::operator()(mir::Server& server) const if (has_default_cursor(*xcursor_loader)) return xcursor_loader; - mir::log_warning("Failed to load cursor theme: %s", theme.c_str()); + mir::log_warning("Failed to load cursor theme: {}", theme); if ((i = j) != std::end(themes)) ++i; } diff --git a/src/miral/hover_click.cpp b/src/miral/hover_click.cpp index d7a9eb386c0..ab39b4ce5f3 100644 --- a/src/miral/hover_click.cpp +++ b/src/miral/hover_click.cpp @@ -84,8 +84,8 @@ miral::HoverClick::HoverClick(miral::live_config::Store& config_store) if (*val < 0) mir::log_warning( - "Config value %s does not support negative values. Ignoring the supplied value (%d)...", - key.to_string().c_str(), + "Config value {} does not support negative values. Ignoring the supplied value ({})...", + key.to_string(), *val); ovo(*val); diff --git a/src/miral/input_configuration.cpp b/src/miral/input_configuration.cpp index b4739f42c1f..91ad17ef076 100644 --- a/src/miral/input_configuration.cpp +++ b/src/miral/input_configuration.cpp @@ -115,10 +115,7 @@ class miral::InputConfiguration::Self else if (value == "left") mouse.handedness(mir_pointer_handedness_left); else - mir::log_warning( - "Config key '%s' has invalid value: %s", - key.to_string().c_str(), - std::format("{}",*val).c_str()); + mir::log_warning("Config key '{}' has invalid value: {}", key.to_string(), *val); } } @@ -137,10 +134,7 @@ class miral::InputConfiguration::Self else if (value == "button_down") touchpad.scroll_mode(mir_touchpad_scroll_mode_button_down_scroll); else - mir::log_warning( - "Config key '%s' has invalid value: %s", - key.to_string().c_str(), - std::format("{}",*val).c_str()); + mir::log_warning("Config key '{}' has invalid value: {}", key.to_string(), *val); } } @@ -156,8 +150,9 @@ class miral::InputConfiguration::Self else { mir::log_warning( - "Config value %s does not support negative values. Ignoring the supplied value (%d)...", - key.to_string().c_str(), *val); + "Config value {} does not support negative values. Ignoring the supplied value ({})...", + key.to_string(), + *val); } } } @@ -174,8 +169,9 @@ class miral::InputConfiguration::Self else { mir::log_warning( - "Config value %s does not support negative values. Ignoring the supplied value (%d)...", - key.to_string().c_str(), *val); + "Config value {} does not support negative values. Ignoring the supplied value ({})...", + key.to_string(), + *val); } } } @@ -198,10 +194,7 @@ class miral::InputConfiguration::Self } else { - mir::log_warning( - "Config key '%s' has invalid value: %s", - key.to_string().c_str(), - std::format("{}",val).c_str()); + mir::log_warning("Config key '{}' has invalid value: {}", key.to_string(), val); } } }; @@ -260,10 +253,7 @@ class miral::InputConfiguration::Self } else { - mir::log_warning( - "Config key '%s' has invalid value: %s", - key.to_string().c_str(), - std::format("{}",val).c_str()); + mir::log_warning("Config key '{}' has invalid value: {}", key.to_string(), val); } } }; @@ -308,10 +298,7 @@ class miral::InputConfiguration::Self } else { - mir::log_warning( - "Config key '%s' has invalid string value: %s", - key.to_string().c_str(), - std::format("{}",val).c_str()); + mir::log_warning("Config key '{}' has invalid string value: {}", key.to_string(), val); } } } @@ -329,10 +316,8 @@ class miral::InputConfiguration::Self if (clamped_value != opt_val) { - mir::log_warning("Config key '%s' value %f clamped to %f", - key.to_string().c_str(), - opt_val.value(), - clamped_value.value()); + mir::log_warning( + "Config key '{}' value {} clamped to {}", key.to_string(), opt_val.value(), clamped_value.value()); } return clamped_value; diff --git a/src/miral/input_device_config.cpp b/src/miral/input_device_config.cpp index 31f30ace861..c0101e14191 100644 --- a/src/miral/input_device_config.cpp +++ b/src/miral/input_device_config.cpp @@ -385,7 +385,7 @@ void miral::TouchpadInputConfiguration::apply_to(mi::Device& device) const { if (contains(device.capabilities(), mi::DeviceCapability::touchpad)) { - mir::log_debug("Configuring touchpad: '%s'", device.name().c_str()); + mir::log_debug("Configuring touchpad: '{}'", device.name()); if (auto const optional_pointer_config = device.pointer_configuration(); optional_pointer_config.is_set()) { MirPointerConfig pointer_config( optional_pointer_config.value() ); @@ -415,7 +415,7 @@ void miral::MouseInputConfiguration::apply_to(mi::Device& device) const { if (contains(device.capabilities(), mi::DeviceCapability::pointer)) { - mir::log_debug("Configuring pointer: '%s'", device.name().c_str()); + mir::log_debug("Configuring pointer: '{}'", device.name()); if (auto optional_pointer_config = device.pointer_configuration(); optional_pointer_config.is_set()) { MirPointerConfig pointer_config( optional_pointer_config.value() ); diff --git a/src/miral/keymap.cpp b/src/miral/keymap.cpp index 81a5e6fa838..b2375b634b2 100644 --- a/src/miral/keymap.cpp +++ b/src/miral/keymap.cpp @@ -336,8 +336,14 @@ auto read_keymap(Connection const& connection) -> std::optional if (error) { - mir::log_info("Dbus error=%s, dest=%s, object_path=%s, properties_interface=%s, method_name=%s, interface_name=%s", - error->message, bus_name, object_path, properties_interface, method_name, interface_name); + mir::log_info( + "Dbus error={}, dest={}, object_path={}, properties_interface={}, method_name={}, interface_name={}", + error->message, + bus_name, + object_path, + properties_interface, + method_name, + interface_name); } return std::nullopt; diff --git a/src/miral/launch_app.cpp b/src/miral/launch_app.cpp index 1583de73ef0..32f0db7234f 100644 --- a/src/miral/launch_app.cpp +++ b/src/miral/launch_app.cpp @@ -135,7 +135,7 @@ auto execute_with_environment(std::vector const app, Environment& a // unnecessary execvpe(exec_args[0], const_cast(exec_args.data()), const_cast(exec_env.data())); - mir::log_warning("Failed to execute client (\"%s\") error: %s", exec_args[0], mir::errno_to_cstr(errno)); + mir::log_warning("Failed to execute client (\"{}\") error: {}", exec_args[0], mir::errno_to_cstr(errno)); _exit(EXIT_FAILURE); } diff --git a/src/miral/live_config_ini_file.cpp b/src/miral/live_config_ini_file.cpp index 9a3d0b16b3d..12ca0182765 100644 --- a/src/miral/live_config_ini_file.cpp +++ b/src/miral/live_config_ini_file.cpp @@ -74,7 +74,7 @@ void mlc::IniFile::Self::add_key( if (attribute_handlers.erase(key) || array_attribute_handlers.erase(key)) { // if a key is registered multiple times, the last time is used: drop existing earlier registrations - mir::log_warning("Config attribute handler for '%s' overwritten", key.to_string().c_str()); + mir::log_warning("Config attribute handler for '{}' overwritten", key.to_string()); } attribute_handlers.emplace(key, AttributeDetails{handler, std::string{description}, preset, std::nullopt}); @@ -94,7 +94,7 @@ void mlc::IniFile::Self::add_key(Key const& key, std::string_view description, if (attribute_handlers.erase(key) || array_attribute_handlers.erase(key)) { // if a key is registered multiple times, the last time is used: drop existing earlier registrations - mir::log_warning("Config attribute handler for '%s' overwritten", key.to_string().c_str()); + mir::log_warning("Config attribute handler for '{}' overwritten", key.to_string()); } array_attribute_handlers.emplace(key, ArrayAttributeDetails{handler, std::string{description}, preset, std::vector{}}); @@ -134,7 +134,7 @@ void mlc::IniFile::Self::load_file(std::istream& istream, std::filesystem::path } catch (const std::exception& e) { - mir::log_warning("Error processing '%s': %s", path.c_str(), e.what()); + mir::log_warning("Error processing '{}': {}", path.string(), e.what()); } } @@ -145,7 +145,7 @@ void mlc::IniFile::Self::load_file(std::istream& istream, std::filesystem::path } catch (const std::exception& e) { - mir::log_warning("Error processing '%s': %s", path.c_str(), e.what()); + mir::log_warning("Error processing '{}': {}", path.string(), e.what()); } for (auto const& [key, details] : array_attribute_handlers) @@ -155,7 +155,7 @@ void mlc::IniFile::Self::load_file(std::istream& istream, std::filesystem::path } catch (const std::exception& e) { - mir::log_warning("Error processing '%s': %s", path.c_str(), e.what()); + mir::log_warning("Error processing '{}': {}", path.string(), e.what()); } for (auto const& h : done_handlers) @@ -165,7 +165,7 @@ void mlc::IniFile::Self::load_file(std::istream& istream, std::filesystem::path } catch (const std::exception& e) { - mir::log_warning("Error processing '%s': %s", path.c_str(), e.what()); + mir::log_warning("Error processing '{}': {}", path.string(), e.what()); } } @@ -238,7 +238,7 @@ void process_as(std::functionmessage, dest, object_path, interface_name, method_name, id.c_str()); + mir::log_info( + "Dbus error={}, dest={}, object_path={}, interface_name={}, method_name={}, id={}", + error->message, + dest, + object_path, + interface_name, + method_name, + id); g_error_free(error); } } diff --git a/src/miral/output.cpp b/src/miral/output.cpp index 7c1e3aca4b8..14e2904755a 100644 --- a/src/miral/output.cpp +++ b/src/miral/output.cpp @@ -117,7 +117,7 @@ auto miral::Output::attribute(std::string const& key) const -> std::optionalfilter(new_filter); } diff --git a/src/miral/simulated_secondary_click.cpp b/src/miral/simulated_secondary_click.cpp index 659b6d75d04..a5ab3d397de 100644 --- a/src/miral/simulated_secondary_click.cpp +++ b/src/miral/simulated_secondary_click.cpp @@ -77,8 +77,8 @@ miral::SimulatedSecondaryClick::SimulatedSecondaryClick(live_config::Store& conf if (*val < 0) { mir::log_warning( - "Config value %s does not support negative values. Ignoring the supplied value (%f)...", - key.to_string().c_str(), + "Config value {} does not support negative values. Ignoring the supplied value ({})...", + key.to_string(), *val); return; } @@ -97,8 +97,8 @@ miral::SimulatedSecondaryClick::SimulatedSecondaryClick(live_config::Store& conf if (*val < 0) { mir::log_warning( - "Config value %s does not support negative values. Ignoring the supplied value (%d)...", - key.to_string().c_str(), + "Config value {} does not support negative values. Ignoring the supplied value ({})...", + key.to_string(), *val); return; } diff --git a/src/miral/slow_keys.cpp b/src/miral/slow_keys.cpp index cb1ee4df173..9da68515936 100644 --- a/src/miral/slow_keys.cpp +++ b/src/miral/slow_keys.cpp @@ -95,8 +95,8 @@ miral::SlowKeys::SlowKeys(miral::live_config::Store& config_store) : else { mir::log_warning( - "Config value %s does not support negative values. Ignoring the supplied value (%d)...", - key.to_string().c_str(), + "Config value {} does not support negative values. Ignoring the supplied value ({})...", + key.to_string(), *val); } } diff --git a/src/miral/static_display_config.cpp b/src/miral/static_display_config.cpp index 64e3b848de0..bcfe1c44d67 100644 --- a/src/miral/static_display_config.cpp +++ b/src/miral/static_display_config.cpp @@ -130,7 +130,7 @@ miral::StaticDisplayConfig::StaticDisplayConfig(std::string const& filename) : } else { - mir::log_info("Cannot read static display configuration file: '" + filename + "'"); + mir::log_info("Cannot read static display configuration file: '{}'", filename); } } namespace @@ -343,7 +343,7 @@ try std::lock_guard lock{mutex}; config = new_config; - mir::log_debug("Loaded display configuration file: %s", filename.c_str()); + mir::log_debug("Loaded display configuration file: {}", filename); } catch (YAML::Exception const& x) { @@ -365,7 +365,7 @@ void miral::YamlFileDisplayConfig::apply_to(mg::DisplayConfiguration& conf) if (current_config != end(config)) { - mir::log_debug("Display config using layout: '%s'", layout.c_str()); + mir::log_debug("Display config using layout: '{}'", layout); conf.for_each_output([&config=current_config->second.matchers2config](mg::UserDisplayConfigurationOutput& conf_output) { @@ -435,11 +435,11 @@ void miral::YamlFileDisplayConfig::apply_to(mg::DisplayConfiguration& conf) if (i != std::end(layout_strategies)) { - mir::log_debug("Display config using layout strategy: '%s'", layout.c_str()); + mir::log_debug("Display config using layout strategy: '{}'", layout); } else { - mir::log_warning("Display config does not contain layout '%s'", layout.c_str()); + mir::log_warning("Display config does not contain layout '{}'", layout); mir::log_debug("Display config using layout strategy: 'default'"); apply_default_configuration(conf); } @@ -617,13 +617,18 @@ void miral::YamlFileDisplayConfig::apply_to_output(mg::UserDisplayConfigurationO { if (conf.refresh.is_set()) { - mir::log_warning("Display config contains unmatched mode: '%dx%d@%2.1f'", - conf.size.value().width.as_int(), conf.size.value().height.as_int(), conf.refresh.value()); + mir::log_warning( + "Display config contains unmatched mode: '{}x{}@{:2.1f}'", + conf.size.value().width.as_int(), + conf.size.value().height.as_int(), + conf.refresh.value()); } else { - mir::log_warning("Display config contains unmatched mode: '%dx%d'", - conf.size.value().width.as_int(), conf.size.value().height.as_int()); + mir::log_warning( + "Display config contains unmatched mode: '{}x{}'", + conf.size.value().width.as_int(), + conf.size.value().height.as_int()); } } } @@ -685,12 +690,12 @@ auto miral::YamlFileDisplayConfig::layout_userdata(std::string const& key) -> st if (second.userdata.contains(key)) return second.userdata.at(key); - mir::log_info("Parsing display configuration: No user data on layout=%s for key=%s", layout.c_str(), key.c_str()); + mir::log_info("Parsing display configuration: No user data on layout={} for key={}", layout, key); return std::nullopt; } } - mir::log_warning("Parsing display configuration: Cannot find layout: %s", layout.c_str()); + mir::log_warning("Parsing display configuration: Cannot find layout: {}", layout); return std::nullopt; } @@ -773,10 +778,7 @@ void miral::ReloadingYamlFileDisplayConfig::confirm(mir::graphics::DisplayConfig serialize_configuration(out, *resulting_layout); } - mir::log_debug( - "%s display configuration template: %s", - out ? "Wrote" : "Failed writing", - filename.c_str()); + mir::log_debug("{} display configuration template: {}", out ? "Wrote" : "Failed writing", filename); } } } @@ -844,7 +846,7 @@ void miral::ReloadingYamlFileDisplayConfig::auto_reload() } else { - mir::log_warning("Failed to open display configuration: %s", filename.c_str()); + mir::log_warning("Failed to open display configuration: {}", filename); } } else if (event.name == basename + layout_suffix) @@ -865,7 +867,7 @@ void miral::ReloadingYamlFileDisplayConfig::auto_reload() } catch (mir::AbnormalExit const& except) { - mir::log_warning("Failed to reload display configuration: %s", except.what()); + mir::log_warning("Failed to reload display configuration: {}", except.what()); } raw_buffer += sizeof_inotify_event+event.len; diff --git a/src/miral/window_management_trace.cpp b/src/miral/window_management_trace.cpp index 177fe243ef9..52632d99a58 100644 --- a/src/miral/window_management_trace.cpp +++ b/src/miral/window_management_trace.cpp @@ -40,7 +40,7 @@ catch (std::exception const& x)\ {\ std::stringstream out;\ mir::report_exception(out);\ - mir::log_warning("%s throws %s", __func__, out.str().c_str());\ + mir::log_warning("{} throws {}", __func__, out.str());\ throw;\ } @@ -368,7 +368,7 @@ auto miral::WindowManagementTrace::count_applications() const -> unsigned int try { log_input(); auto const result = wrapped.count_applications(); - mir::log_info("%s -> %d", __func__, result); + mir::log_info("{} -> {}", __func__, result); trace_count++; return result; } @@ -377,7 +377,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::for_each_application(std::function const& functor) try { log_input(); - mir::log_info("%s", __func__); + mir::log_info("{}", __func__); trace_count++; wrapped.for_each_application(functor); } @@ -388,7 +388,7 @@ auto miral::WindowManagementTrace::find_application(std::function %s", __func__, dump_of(result).c_str()); + mir::log_info("{} -> {}", __func__, dump_of(result)); trace_count++; return result; } @@ -398,7 +398,7 @@ auto miral::WindowManagementTrace::info_for(std::weak_ptr c try { log_input(); auto& result = wrapped.info_for(session); - mir::log_info("%s -> %s", __func__, result.application()->name().c_str()); + mir::log_info("{} -> {}", __func__, result.application()->name()); trace_count++; return result; } @@ -408,7 +408,7 @@ auto miral::WindowManagementTrace::info_for(std::weak_ptr c try { log_input(); auto& result = wrapped.info_for(surface); - mir::log_info("%s -> %s", __func__, result.name().c_str()); + mir::log_info("{} -> {}", __func__, result.name()); trace_count++; return result; } @@ -418,7 +418,7 @@ auto miral::WindowManagementTrace::info_for(Window const& window) const -> Windo try { log_input(); auto& result = wrapped.info_for(window); - mir::log_info("%s -> %s", __func__, result.name().c_str()); + mir::log_info("{} -> {}", __func__, result.name()); trace_count++; return result; } @@ -427,7 +427,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::ask_client_to_close(miral::Window const& window) try { log_input(); - mir::log_info("%s -> %s", __func__, dump_of(window).c_str()); + mir::log_info("{} -> {}", __func__, dump_of(window)); trace_count++; wrapped.ask_client_to_close(window); } @@ -437,7 +437,7 @@ auto miral::WindowManagementTrace::active_window() const -> Window try { log_input(); auto result = wrapped.active_window(); - mir::log_info("%s -> %s", __func__, dump_of(result).c_str()); + mir::log_info("{} -> {}", __func__, dump_of(result)); trace_count++; return result; } @@ -447,7 +447,7 @@ auto miral::WindowManagementTrace::select_active_window(Window const& hint) -> W try { log_input(); auto result = wrapped.select_active_window(hint); - mir::log_info("%s hint=%s -> %s", __func__, dump_of(hint).c_str(), dump_of(result).c_str()); + mir::log_info("{} hint={} -> {}", __func__, dump_of(hint), dump_of(result)); trace_count++; return result; } @@ -459,7 +459,7 @@ try { auto result = wrapped.window_at(cursor); std::stringstream out; out << cursor << " -> " << dump_of(result); - mir::log_info("%s cursor=%s", __func__, out.str().c_str()); + mir::log_info("{} cursor={}", __func__, out.str()); trace_count++; return result; } @@ -471,7 +471,7 @@ try { auto result = wrapped.active_output(); std::stringstream out; out << result; - mir::log_info("%s -> %s", __func__, out.str().c_str()); + mir::log_info("{} -> {}", __func__, out.str()); trace_count++; return result; } @@ -483,7 +483,7 @@ try { auto result = wrapped.active_application_zone(); std::stringstream out; out << result.extents(); - mir::log_info("%s -> %s", __func__, out.str().c_str()); + mir::log_info("{} -> {}", __func__, out.str()); trace_count++; return result; } @@ -495,7 +495,7 @@ auto miral::WindowManagementTrace::info_for_window_id(std::string const& id) con try { log_input(); auto& result = wrapped.info_for_window_id(id); - mir::log_info("%s id=%s -> %s", __func__, id.c_str(), dump_of(result).c_str()); + mir::log_info("{} id={} -> {}", __func__, id, dump_of(result)); trace_count++; return result; } @@ -505,7 +505,7 @@ auto miral::WindowManagementTrace::id_for_window(Window const& window) const -> try { log_input(); auto result = wrapped.id_for_window(window); - mir::log_info("%s window=%s -> %s", __func__, dump_of(window).c_str(), result.c_str()); + mir::log_info("{} window={} -> {}", __func__, dump_of(window), result); trace_count++; return result; } @@ -516,7 +516,7 @@ void miral::WindowManagementTrace::place_and_size_for_state( WindowSpecification& modifications, WindowInfo const& window_info) const try { log_input(); - mir::log_info("%s modifications=%s window_info=%s", __func__, dump_of(modifications).c_str(), dump_of(window_info).c_str()); + mir::log_info("{} modifications={} window_info={}", __func__, dump_of(modifications), dump_of(window_info)); wrapped.place_and_size_for_state(modifications, window_info); } MIRAL_TRACE_EXCEPTION @@ -526,7 +526,7 @@ try { log_input(); std::stringstream out; out << movement; - mir::log_info("%s movement=%s", __func__, out.str().c_str()); + mir::log_info("{} movement={}", __func__, out.str()); trace_count++; wrapped.drag_active_window(movement); } @@ -537,7 +537,7 @@ try { log_input(); std::stringstream out; out << movement; - mir::log_info("%s window=%s -> %s", __func__, dump_of(window).c_str(), out.str().c_str()); + mir::log_info("{} window={} -> {}", __func__, dump_of(window), out.str()); trace_count++; wrapped.drag_window(window, movement); } @@ -546,7 +546,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::focus_next_application() try { log_input(); - mir::log_info("%s", __func__); + mir::log_info("{}", __func__); trace_count++; wrapped.focus_next_application(); } @@ -555,7 +555,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::focus_prev_application() try { log_input(); - mir::log_info("%s", __func__); + mir::log_info("{}", __func__); trace_count++; wrapped.focus_next_application(); } @@ -564,7 +564,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::focus_next_within_application() try { log_input(); - mir::log_info("%s", __func__); + mir::log_info("{}", __func__); trace_count++; wrapped.focus_next_within_application(); } @@ -573,7 +573,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::focus_prev_within_application() try { log_input(); - mir::log_info("%s", __func__); + mir::log_info("{}", __func__); trace_count++; wrapped.focus_prev_within_application(); } @@ -582,7 +582,7 @@ MIRAL_TRACE_EXCEPTION auto miral::WindowManagementTrace::window_to_select_application(Application const app) const -> std::optional try { log_input(); - mir::log_info("%s app=%s", __func__, dump_of(app).c_str()); + mir::log_info("{} app={}", __func__, dump_of(app)); trace_count++; return wrapped.window_to_select_application(app); } @@ -591,7 +591,7 @@ MIRAL_TRACE_EXCEPTION auto miral::WindowManagementTrace::can_select_window(miral::Window const& window) const -> bool try { log_input(); - mir::log_info("%s app=%s", __func__, dump_of(window).c_str()); + mir::log_info("{} app={}", __func__, dump_of(window)); trace_count++; return wrapped.can_select_window(window); } @@ -600,7 +600,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::raise_tree(miral::Window const& root) try { log_input(); - mir::log_info("%s root=%s", __func__, dump_of(root).c_str()); + mir::log_info("{} root={}", __func__, dump_of(root)); trace_count++; wrapped.raise_tree(root); } @@ -609,7 +609,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::swap_tree_order(Window const& first, Window const& second) try { log_input(); - mir::log_info("%s first=%s second=%s", __func__, dump_of(first).c_str(), dump_of(second).c_str()); + mir::log_info("{} first={} second={}", __func__, dump_of(first), dump_of(second)); trace_count++; wrapped.swap_tree_order(first, second); } @@ -618,7 +618,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::send_tree_to_back(const miral::Window &root) try { log_input(); - mir::log_info("%s root=%s", __func__, dump_of(root).c_str()); + mir::log_info("{} root={}", __func__, dump_of(root)); trace_count++; wrapped.send_tree_to_back(root); } @@ -628,8 +628,7 @@ void miral::WindowManagementTrace::modify_window( miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) try { log_input(); - mir::log_info("%s window_info=%s, modifications=%s", - __func__, dump_of(window_info).c_str(), dump_of(modifications).c_str()); + mir::log_info("{} window_info={}, modifications={}", __func__, dump_of(window_info), dump_of(modifications)); trace_count++; wrapped.modify_window(window_info, modifications); } @@ -637,14 +636,14 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::invoke_under_lock(std::function const& callback) try { - mir::log_info("%s", __func__); + mir::log_info("{}", __func__); wrapped.invoke_under_lock(callback); } MIRAL_TRACE_EXCEPTION auto miral::WindowManagementTrace::create_workspace() -> std::shared_ptr try { - mir::log_info("%s", __func__); + mir::log_info("{}", __func__); return wrapped.create_workspace(); } MIRAL_TRACE_EXCEPTION @@ -652,7 +651,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::add_tree_to_workspace( miral::Window const& window, std::shared_ptr const& workspace) try { - mir::log_info("%s window=%s, workspace =%p", __func__, dump_of(window).c_str(), static_cast(workspace.get())); + mir::log_info("{} window={}, workspace ={}", __func__, dump_of(window), static_cast(workspace.get())); wrapped.add_tree_to_workspace(window, workspace); } MIRAL_TRACE_EXCEPTION @@ -660,7 +659,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::remove_tree_from_workspace( miral::Window const& window, std::shared_ptr const& workspace) try { - mir::log_info("%s window=%s, workspace =%p", __func__, dump_of(window).c_str(), static_cast(workspace.get())); + mir::log_info("{} window={}, workspace ={}", __func__, dump_of(window), static_cast(workspace.get())); wrapped.remove_tree_from_workspace(window, workspace); } MIRAL_TRACE_EXCEPTION @@ -668,7 +667,11 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::move_workspace_content_to_workspace( std::shared_ptr const& to_workspace, std::shared_ptr const& from_workspace) try { - mir::log_info("%s to_workspace=%p, from_workspace=%p", __func__, static_cast(to_workspace.get()), static_cast(from_workspace.get())); + mir::log_info( + "{} to_workspace={}, from_workspace={}", + __func__, + static_cast(to_workspace.get()), + static_cast(from_workspace.get())); wrapped.move_workspace_content_to_workspace(to_workspace, from_workspace); } MIRAL_TRACE_EXCEPTION @@ -676,7 +679,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::for_each_workspace_containing( miral::Window const& window, std::function const&)> const& callback) try { - mir::log_info("%s window=%s", __func__, dump_of(window).c_str()); + mir::log_info("{} window={}", __func__, dump_of(window)); wrapped.for_each_workspace_containing(window, callback); } MIRAL_TRACE_EXCEPTION @@ -684,7 +687,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::for_each_window_in_workspace( std::shared_ptr const& workspace, std::function const& callback) try { - mir::log_info("%s workspace =%p", __func__, static_cast(workspace.get())); + mir::log_info("{} workspace ={}", __func__, static_cast(workspace.get())); wrapped.for_each_window_in_workspace(workspace, callback); } MIRAL_TRACE_EXCEPTION @@ -694,15 +697,19 @@ auto miral::WindowManagementTrace::place_new_window( WindowSpecification const& requested_specification) -> WindowSpecification try { auto const result = policy->place_new_window(app_info, requested_specification); - mir::log_info("%s app_info=%s, requested_specification=%s -> %s", - __func__, dump_of(app_info).c_str(), dump_of(requested_specification).c_str(), dump_of(result).c_str()); + mir::log_info( + "{} app_info={}, requested_specification={} -> {}", + __func__, + dump_of(app_info), + dump_of(requested_specification), + dump_of(result)); return result; } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::handle_window_ready(miral::WindowInfo& window_info) try { - mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str()); + mir::log_info("{} window_info={}", __func__, dump_of(window_info)); policy->handle_window_ready(window_info); } MIRAL_TRACE_EXCEPTION @@ -710,15 +717,14 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::handle_modify_window( miral::WindowInfo& window_info, miral::WindowSpecification const& modifications) try { - mir::log_info("%s window_info=%s, modifications=%s", - __func__, dump_of(window_info).c_str(), dump_of(modifications).c_str()); + mir::log_info("{} window_info={}, modifications={}", __func__, dump_of(window_info), dump_of(modifications)); policy->handle_modify_window(window_info, modifications); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::handle_raise_window(miral::WindowInfo& window_info) try { - mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str()); + mir::log_info("{} window_info={}", __func__, dump_of(window_info)); policy->handle_raise_window(window_info); } MIRAL_TRACE_EXCEPTION @@ -727,7 +733,7 @@ bool miral::WindowManagementTrace::handle_keyboard_event(MirKeyboardEvent const* try { log_input = [event, this] { - mir::log_info("handle_keyboard_event event=%s", dump_of(event).c_str()); + mir::log_info("handle_keyboard_event event={}", dump_of(event)); log_input = []{}; }; @@ -739,7 +745,7 @@ bool miral::WindowManagementTrace::handle_touch_event(MirTouchEvent const* event try { log_input = [event, this] { - mir::log_info("handle_touch_event event=%s", dump_of(event).c_str()); + mir::log_info("handle_touch_event event={}", dump_of(event)); log_input = []{}; }; @@ -751,7 +757,7 @@ bool miral::WindowManagementTrace::handle_pointer_event(MirPointerEvent const* e try { log_input = [event, this] { - mir::log_info("handle_pointer_event event=%s", dump_of(event).c_str()); + mir::log_info("handle_pointer_event event={}", dump_of(event)); log_input = []{}; }; @@ -764,7 +770,7 @@ auto miral::WindowManagementTrace::confirm_inherited_move(WindowInfo const& wind try { std::stringstream out; out << movement; - mir::log_info("%s window_info=%s, movement=%s", __func__, dump_of(window_info).c_str(), out.str().c_str()); + mir::log_info("{} window_info={}, movement={}", __func__, dump_of(window_info), out.str()); return policy->confirm_inherited_move(window_info, movement); } @@ -788,77 +794,77 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_new_app(miral::ApplicationInfo& application) try { - mir::log_info("%s application=%s", __func__, dump_of(application).c_str()); + mir::log_info("{} application={}", __func__, dump_of(application)); policy->advise_new_app(application); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_delete_app(miral::ApplicationInfo const& application) try { - mir::log_info("%s application=%s", __func__, dump_of(application).c_str()); + mir::log_info("{} application={}", __func__, dump_of(application)); policy->advise_delete_app(application); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_new_window(miral::WindowInfo const& window_info) try { - mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str()); + mir::log_info("{} window_info={}", __func__, dump_of(window_info)); policy->advise_new_window(window_info); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_focus_lost(miral::WindowInfo const& window_info) try { - mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str()); + mir::log_info("{} window_info={}", __func__, dump_of(window_info)); policy->advise_focus_lost(window_info); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_focus_gained(miral::WindowInfo const& window_info) try { - mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str()); + mir::log_info("{} window_info={}", __func__, dump_of(window_info)); policy->advise_focus_gained(window_info); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_state_change(miral::WindowInfo const& window_info, MirWindowState state) try { - mir::log_info("%s window_info=%s, state=%s", __func__, dump_of(window_info).c_str(), dump_of(state).c_str()); + mir::log_info("{} window_info={}, state={}", __func__, dump_of(window_info), dump_of(state)); policy->advise_state_change(window_info, state); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_move_to(miral::WindowInfo const& window_info, mir::geometry::Point top_left) try { - mir::log_info("%s window_info=%s, top_left=%s", __func__, dump_of(window_info).c_str(), dump_of(top_left).c_str()); + mir::log_info("{} window_info={}, top_left={}", __func__, dump_of(window_info), dump_of(top_left)); policy->advise_move_to(window_info, top_left); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_resize(miral::WindowInfo const& window_info, mir::geometry::Size const& new_size) try { - mir::log_info("%s window_info=%s, new_size=%s", __func__, dump_of(window_info).c_str(), dump_of(new_size).c_str()); + mir::log_info("{} window_info={}, new_size={}", __func__, dump_of(window_info), dump_of(new_size)); policy->advise_resize(window_info, new_size); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_delete_window(miral::WindowInfo const& window_info) try { - mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str()); + mir::log_info("{} window_info={}", __func__, dump_of(window_info)); policy->advise_delete_window(window_info); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_raise(std::vector const& windows) try { - mir::log_info("%s window_info=%s", __func__, dump_of(windows).c_str()); + mir::log_info("{} window_info={}", __func__, dump_of(windows)); policy->advise_raise(windows); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::handle_request_move(miral::WindowInfo& window_info, MirInputEvent const* input_event) try { - mir::log_info("%s window_info=%s", __func__, dump_of(window_info).c_str()); + mir::log_info("{} window_info={}", __func__, dump_of(window_info)); policy->handle_request_move(window_info, input_event); } MIRAL_TRACE_EXCEPTION @@ -866,7 +872,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::handle_request_resize( miral::WindowInfo& window_info, MirInputEvent const* input_event, MirResizeEdge edge) try { - mir::log_info("%s window_info=%s, edge=0x%1x", __func__, dump_of(window_info).c_str(), edge); + mir::log_info("{} window_info={}, edge=0x{:x}", __func__, dump_of(window_info), static_cast(edge)); policy->handle_request_resize(window_info, input_event, edge); } MIRAL_TRACE_EXCEPTION @@ -874,7 +880,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_adding_to_workspace( std::shared_ptr const& workspace, std::vector const& windows) try { - mir::log_info("%s workspace=%p, windows=%s", __func__, static_cast(workspace.get()), dump_of(windows).c_str()); + mir::log_info("{} workspace={}, windows={}", __func__, static_cast(workspace.get()), dump_of(windows)); policy->advise_adding_to_workspace(workspace, windows); } MIRAL_TRACE_EXCEPTION @@ -882,7 +888,7 @@ MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_removing_from_workspace( std::shared_ptr const& workspace, std::vector const& windows) try { - mir::log_info("%s workspace=%p, windows=%s", __func__, static_cast(workspace.get()), dump_of(windows).c_str()); + mir::log_info("{} workspace={}, windows={}", __func__, static_cast(workspace.get()), dump_of(windows)); policy->advise_removing_from_workspace(workspace, windows); } MIRAL_TRACE_EXCEPTION @@ -894,50 +900,55 @@ auto miral::WindowManagementTrace::confirm_placement_on_display( Rectangle const& new_placement) -> Rectangle try { auto const& result = policy->confirm_placement_on_display(window_info, new_state, new_placement); - mir::log_info("%s window_info=%s, new_state= %s, new_placement= %s -> %s", __func__, - dump_of(window_info).c_str(), dump_of(new_state).c_str(), dump_of(new_placement).c_str(), dump_of(result).c_str()); + mir::log_info( + "{} window_info={}, new_state= {}, new_placement= {} -> {}", + __func__, + dump_of(window_info), + dump_of(new_state), + dump_of(new_placement), + dump_of(result)); return result; } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_output_create(Output const& output) try { - mir::log_info("%s output=%s", __func__, dump_of(output).c_str()); + mir::log_info("{} output={}", __func__, dump_of(output)); return policy->advise_output_create(output); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_output_update(Output const& updated, Output const& original) try { - mir::log_info("%s updated=%s, original=%s", __func__, dump_of(updated).c_str(), dump_of(original).c_str()); + mir::log_info("{} updated={}, original={}", __func__, dump_of(updated), dump_of(original)); return policy->advise_output_update(updated, original); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_output_delete(Output const& output) try { - mir::log_info("%s output=%s", __func__, dump_of(output).c_str()); + mir::log_info("{} output={}", __func__, dump_of(output)); return policy->advise_output_delete(output); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_application_zone_create(Zone const& application_zone) try { - mir::log_info("%s application_zone=%s", __func__, dump_of(application_zone).c_str()); + mir::log_info("{} application_zone={}", __func__, dump_of(application_zone)); return policy->advise_application_zone_create(application_zone); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_application_zone_update(Zone const& updated, Zone const& original) try { - mir::log_info("%s updated=%s, original=%s", __func__, dump_of(updated).c_str(), dump_of(original).c_str()); + mir::log_info("{} updated={}, original={}", __func__, dump_of(updated), dump_of(original)); return policy->advise_application_zone_update(updated, original); } MIRAL_TRACE_EXCEPTION void miral::WindowManagementTrace::advise_application_zone_delete(Zone const& application_zone) try { - mir::log_info("%s application_zone=%s", __func__, dump_of(application_zone).c_str()); + mir::log_info("{} application_zone={}", __func__, dump_of(application_zone)); return policy->advise_application_zone_delete(application_zone); } MIRAL_TRACE_EXCEPTION @@ -946,7 +957,7 @@ void miral::WindowManagementTrace::move_cursor_to(mir::geometry::PointF point) try { std::stringstream out; out << point; - mir::log_info("%s point=%s", __func__, out.str().c_str()); + mir::log_info("{} point={}", __func__, out.str()); wrapped.move_cursor_to(point); } MIRAL_TRACE_EXCEPTION diff --git a/src/platform/graphics/cpu_addressable_fb.cpp b/src/platform/graphics/cpu_addressable_fb.cpp index 34312496075..8230ff160e7 100644 --- a/src/platform/graphics/cpu_addressable_fb.cpp +++ b/src/platform/graphics/cpu_addressable_fb.cpp @@ -52,7 +52,7 @@ class mg::CPUAddressableFB::Buffer : public mir::renderer::software::RWMappable if (::munmap(const_cast::type *>(data_), len_) == -1) { // It's unclear how this could happen, but tell *someone* about it if it does! - log_error("Failed to unmap CPU buffer: %s (%i)", mir::errno_to_cstr(errno), errno); + log_error("Failed to unmap CPU buffer: {} ({})", mir::errno_to_cstr(errno), errno); } } @@ -101,7 +101,7 @@ class mg::CPUAddressableFB::Buffer : public mir::renderer::software::RWMappable if (auto const err = drmIoctl(drm_fd, DRM_IOCTL_MODE_DESTROY_DUMB, ¶ms)) { - log_error("Failed destroy CPU-accessible buffer: %s (%i)", mir::errno_to_cstr(-err), -err); + log_error("Failed destroy CPU-accessible buffer: {} ({})", mir::errno_to_cstr(-err), -err); } } diff --git a/src/platform/graphics/drm_formats.cpp b/src/platform/graphics/drm_formats.cpp index b90c251c153..56cdd61eee4 100644 --- a/src/platform/graphics/drm_formats.cpp +++ b/src/platform/graphics/drm_formats.cpp @@ -491,7 +491,9 @@ auto mg::DRMFormat::info() const -> std::optional if (!unknown_formats->contains(fourcc)) { mir::log_warning( - "Detailed info for format %s missing; please report this to https://github.com/canonical/mir/issues/new so this can be added", name()); + "Detailed info for format {} missing; please report this to https://github.com/canonical/mir/issues/new so " + "this can be added", + name()); unknown_formats->insert(fourcc); } return std::nullopt; diff --git a/src/platform/graphics/egl_logger.cpp b/src/platform/graphics/egl_logger.cpp index 38a97f85730..1f34841e24e 100644 --- a/src/platform/graphics/egl_logger.cpp +++ b/src/platform/graphics/egl_logger.cpp @@ -54,9 +54,7 @@ void egl_debug_logger( case EGL_DEBUG_MSG_CRITICAL_KHR: return mir::logging::Severity::critical; default: - mir::log_error( - "Unexpected EGL log level encountered: %i. This is a Mir programming error.", - egl_severity); + mir::log_error("Unexpected EGL log level encountered: {}. This is a Mir programming error.", egl_severity); // Shrug. Let's pick error? return mir::logging::Severity::error; } @@ -65,7 +63,7 @@ void egl_debug_logger( mir::log( severity, MIR_LOG_COMPONENT, - "[%s] on [%s]: %s (%s): %s", + "[{}] on [{}]: {} ({}): {}", thread_id, object_id, command, diff --git a/src/platform/graphics/linux_dmabuf.cpp b/src/platform/graphics/linux_dmabuf.cpp index 2468dbe6354..1e12345c6c4 100644 --- a/src/platform/graphics/linux_dmabuf.cpp +++ b/src/platform/graphics/linux_dmabuf.cpp @@ -101,7 +101,7 @@ class mg::DmaBufFormatDescriptors if (returned_formats != num_formats) { mir::log_warning( - "eglQueryDmaBufFormats returned unexpected number of formats (got %i, expected %i)", + "eglQueryDmaBufFormats returned unexpected number of formats (got {}, expected {})", returned_formats, num_formats); resize(returned_formats); @@ -121,9 +121,10 @@ class mg::DmaBufFormatDescriptors nullptr, &num_modifiers) != EGL_TRUE) { - mir::log_warning("eglQueryDmaBufModifiers failed for format %s: %s", + mir::log_warning( + "eglQueryDmaBufModifiers failed for format {}: {}", mg::drm_format_to_string(static_cast(format)), - mg::egl_category().message(eglGetError()).c_str()); + mg::egl_category().message(eglGetError())); // Remove that format and its modifiers from our list formats.erase(formats.begin() + i); @@ -151,8 +152,8 @@ class mg::DmaBufFormatDescriptors if (returned_modifiers != num_modifiers) { mir::log_warning( - "eglQueryDmaBufModifiers return unexpected number of modifiers for format 0x%ux" - " (expected %i, got %i)", + "eglQueryDmaBufModifiers return unexpected number of modifiers for format 0x{}x" + " (expected {}, got {})", format, returned_modifiers, num_modifiers); @@ -820,7 +821,7 @@ class LinuxDmaBufParams : public mir::wayland::LinuxBufferParamsV1 /* The client should handle this fine, but let's make sure we can see * any failures that might happen. */ - mir::log_debug("Failed to import client dmabufs: %s", err.what()); + mir::log_debug("Failed to import client dmabufs: {}", err.what()); send_failed_event(); } consumed = true; @@ -1449,15 +1450,13 @@ dev_t get_devnum(EGLDisplay dpy) const char *device_path = device_query_ext.eglQueryDeviceStringEXT(device, EGL_DRM_DEVICE_FILE_EXT); if (device_path == nullptr) { - mir::log_info( - "Unable to determine linux-dmabuf device: no device path returned from EGL"); + mir::log_info("Unable to determine linux-dmabuf device: no device path returned from EGL"); return 0; } struct stat device_stat = {}; if (stat(device_path, &device_stat) == -1) { - mir::log_info( - "Unable to determine linux-dmabuf device: unable to stat device path: %s", mir::errno_to_cstr(errno)); + mir::log_info("Unable to determine linux-dmabuf device: unable to stat device path: {}", mir::errno_to_cstr(errno)); return 0; } @@ -1465,8 +1464,7 @@ dev_t get_devnum(EGLDisplay dpy) } catch (std::runtime_error const& error) { - mir::log_info( - "Unable to determine linux-dmabuf device: %s", error.what()); + mir::log_info("Unable to determine linux-dmabuf device: {}", error.what()); return 0; } } diff --git a/src/platform/graphics/quirk_common.cpp b/src/platform/graphics/quirk_common.cpp index 2312cbc9422..0ecdf7a25a1 100644 --- a/src/platform/graphics/quirk_common.cpp +++ b/src/platform/graphics/quirk_common.cpp @@ -115,17 +115,17 @@ auto mir::graphics::common::apply_quirk( { if (auto p = devnode_quirks.find(std::string{devnode}); p != devnode_quirks.end()) { - mir::log_debug("Quirks(%s): forcing %s implementation", message, p->second.c_str()); + mir::log_debug("Quirks({}): forcing {} implementation", message, p->second); return p->second; } if (auto p = driver_quirks.find(std::string{driver}); p != driver_quirks.end()) { - mir::log_debug("Quirks(%s): forcing %s implementation", message, p->second.c_str()); + mir::log_debug("Quirks({}): forcing {} implementation", message, p->second); return p->second; } - log_debug("Quirks(%s): using default implementation for %s driver", message, driver); + log_debug("Quirks({}): using default implementation for {} driver", message, driver); // Not specified return std::string{driver}; diff --git a/src/platform/graphics/shm_buffer.cpp b/src/platform/graphics/shm_buffer.cpp index 085f1c68758..53df3411cec 100644 --- a/src/platform/graphics/shm_buffer.cpp +++ b/src/platform/graphics/shm_buffer.cpp @@ -194,9 +194,9 @@ class mgc::ShmBuffer::ShmBufferTexture : public gl::Texture else { mir::log_error( - "Buffer %i has non-GL-compatible pixel format %i; rendering will be incomplete", + "Buffer {} has non-GL-compatible pixel format {}; rendering will be incomplete", id.as_value(), - pixel_format); + static_cast(pixel_format)); } uploaded = true; diff --git a/src/platform/options/program_option.cpp b/src/platform/options/program_option.cpp index e338bda8e94..c230055036e 100644 --- a/src/platform/options/program_option.cpp +++ b/src/platform/options/program_option.cpp @@ -95,7 +95,7 @@ void mo::ProgramOption::parse_file( } catch (const po::error& error) { - log_warning("Error in %s: %s", filename.c_str(), error.what()); + log_warning("Error in {}: {}", filename, error.what()); } } diff --git a/src/platform/renderers/gl/renderer.cpp b/src/platform/renderers/gl/renderer.cpp index 205d55a9e82..850492c85bf 100644 --- a/src/platform/renderers/gl/renderer.cpp +++ b/src/platform/renderers/gl/renderer.cpp @@ -611,7 +611,7 @@ mrg::Renderer::Renderer( GLint max_texture_size = 0; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size); - mir::log_info("GL max texture size = %d", max_texture_size); + mir::log_info("GL max texture size = {}", max_texture_size); GLint rbits = 0, gbits = 0, bbits = 0, abits = 0, dbits = 0, sbits = 0; glGetIntegerv(GL_RED_BITS, &rbits); @@ -620,8 +620,7 @@ mrg::Renderer::Renderer( glGetIntegerv(GL_ALPHA_BITS, &abits); glGetIntegerv(GL_DEPTH_BITS, &dbits); glGetIntegerv(GL_STENCIL_BITS, &sbits); - mir::log_info("GL framebuffer bits: RGBA=%d%d%d%d, depth=%d, stencil=%d", - rbits, gbits, bbits, abits, dbits, sbits); + mir::log_info("GL framebuffer bits: RGBA={}{}{}{}, depth={}, stencil={}", rbits, gbits, bbits, abits, dbits, sbits); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -678,7 +677,7 @@ auto mrg::Renderer::render(mg::RenderableList const& renderables) const -> std:: // Report any GL errors after commit, to catch any *during* commit while (auto const gl_error = glGetError()) - mir::log_debug("GL error: %d", gl_error); + mir::log_debug("GL error: {}", gl_error); return output; } diff --git a/src/platforms/atomic-kms/server/display_helpers.cpp b/src/platforms/atomic-kms/server/display_helpers.cpp index dcf75d25c14..1929cd1b462 100644 --- a/src/platforms/atomic-kms/server/display_helpers.cpp +++ b/src/platforms/atomic-kms/server/display_helpers.cpp @@ -68,7 +68,7 @@ mgmh::DRMHelper::open_all_devices( { if (quirks.should_skip(device)) { - mir::log_info("Ignoring device %s due to specified quirk", device.devnode()); + mir::log_info("Ignoring device {} due to specified quirk", device.devnode()); continue; } @@ -84,9 +84,7 @@ mgmh::DRMHelper::open_all_devices( catch (std::exception const& error) { mir::log_warning( - "Failed to open DRM device node %s: %s", - device.devnode(), - boost::diagnostic_information(error).c_str()); + "Failed to open DRM device node {}: {}", device.devnode(), boost::diagnostic_information(error)); continue; } @@ -94,7 +92,7 @@ mgmh::DRMHelper::open_all_devices( if (tmp_fd == mir::Fd::invalid) { mir::log_critical( - "Opening the DRM device %s succeeded, but provided an invalid descriptor!", + "Opening the DRM device {} succeeded, but provided an invalid descriptor!", device.devnode()); mir::log_critical( "This is probably a logic error in Mir, please report to https://github.com/canonical/mir/issues"); @@ -111,7 +109,7 @@ mgmh::DRMHelper::open_all_devices( if ((error = -drmSetInterfaceVersion(tmp_fd, &sv))) { mir::log_warning( - "Failed to set DRM interface version on device %s: %i (%s)", + "Failed to set DRM interface version on device {}: {} ({})", device.devnode(), error, mir::errno_to_cstr(error)); @@ -124,9 +122,7 @@ mgmh::DRMHelper::open_all_devices( if (!busid) { - mir::log_warning( - "Failed to query BusID for device %s; cannot check if KMS is available", - device.devnode()); + mir::log_warning("Failed to query BusID for device {}; cannot check if KMS is available", device.devnode()); } else { @@ -137,7 +133,7 @@ mgmh::DRMHelper::open_all_devices( case ENOSYS: if (quirks.require_modesetting_support(device)) { - mir::log_info("Ignoring non-KMS DRM device %s", device.devnode()); + mir::log_info("Ignoring non-KMS DRM device {}", device.devnode()); error = ENOSYS; continue; } @@ -145,13 +141,14 @@ mgmh::DRMHelper::open_all_devices( [[fallthrough]]; case EINVAL: mir::log_warning( - "Failed to detect whether device %s supports KMS, but continuing anyway", - device.devnode()); + "Failed to detect whether device {} supports KMS, but continuing anyway", device.devnode()); break; default: - mir::log_warning("Unexpected error from drmCheckModesettingSupported(): %s (%i), but continuing anyway", - mir::errno_to_cstr(err), err); + mir::log_warning( + "Unexpected error from drmCheckModesettingSupported(): {} ({}), but continuing anyway", + mir::errno_to_cstr(err), + err); mir::log_warning("Please file a bug at https://github.com/canonical/mir/issues containing this message"); } } @@ -162,7 +159,7 @@ mgmh::DRMHelper::open_all_devices( new DRMHelper{ std::move(tmp_fd), std::move(device_handle)}}); - mir::log_info("Using DRM device %s", device.devnode()); + mir::log_info("Using DRM device {}", device.devnode()); } if (opened_devices.size() == 0) diff --git a/src/platforms/atomic-kms/server/gbm_display_allocator.cpp b/src/platforms/atomic-kms/server/gbm_display_allocator.cpp index 13191325a81..8f689263e9f 100644 --- a/src/platforms/atomic-kms/server/gbm_display_allocator.cpp +++ b/src/platforms/atomic-kms/server/gbm_display_allocator.cpp @@ -156,8 +156,7 @@ auto create_gbm_surface( if (!surface) { - mir::log_info( - "Failed to create display buffer surface with correct flags. Attempting to create one without flags"); + mir::log_info("Failed to create display buffer surface with correct flags. Attempting to create one without flags"); // Try allocating without flags // Covers Nvidia cards before 575 surface = try_create_surface(0); diff --git a/src/platforms/atomic-kms/server/kms/atomic_kms_output.cpp b/src/platforms/atomic-kms/server/kms/atomic_kms_output.cpp index 4f96d36e5cc..14ea6520acf 100644 --- a/src/platforms/atomic-kms/server/kms/atomic_kms_output.cpp +++ b/src/platforms/atomic-kms/server/kms/atomic_kms_output.cpp @@ -161,10 +161,7 @@ class mga::AtomicKMSOutput::PropertyBlob { if (auto err = drmModeDestroyPropertyBlob(drm_fd, handle_)) { - mir::log_warning( - "Failed to free DRM property blob: %s (%i)", - mir::errno_to_cstr(-err), - -err); + mir::log_warning("Failed to free DRM property blob: {} ({})", mir::errno_to_cstr(-err), -err); } } @@ -250,7 +247,8 @@ void mga::AtomicKMSOutput::reset() if (auto err = drmModeAtomicCommit(drm_fd(), update, DRM_MODE_ATOMIC_ALLOW_MODESET, nullptr)) { - mir::log_warning("Failed release resources for disconnected output: %s (%i)", mir::errno_to_cstr(-err), -err); + mir::log_warning( + "Failed release resources for disconnected output: {} ({})", mir::errno_to_cstr(-err), -err); } conf->crtc_props = nullptr; @@ -304,8 +302,7 @@ bool mga::AtomicKMSOutput::set_crtc(FBHandle const& fb) auto conf = configuration.lock(); if (!ensure_crtc(*conf)) { - mir::log_error("Output %s has no associated CRTC to set a framebuffer on", - mgk::connector_name(conf->connector).c_str()); + mir::log_error("Output {} has no associated CRTC to set a framebuffer on", mgk::connector_name(conf->connector)); return false; } @@ -339,7 +336,7 @@ bool mga::AtomicKMSOutput::set_crtc(FBHandle const& fb) auto ret = drmModeAtomicCommit(drm_fd_, update, DRM_MODE_ATOMIC_ALLOW_MODESET, nullptr); if (ret) { - mir::log_error("Failed to set CRTC: %s (%i)", mir::errno_to_cstr(-ret), -ret); + mir::log_error("Failed to set CRTC: {} ({})", mir::errno_to_cstr(-ret), -ret); conf->current_crtc = nullptr; return false; } @@ -356,7 +353,7 @@ bool mga::AtomicKMSOutput::has_crtc_mismatch() auto conf = configuration.lock(); if (!ensure_crtc(*conf)) { - mir::log_error("Output %s has no associated CRTC to get ", mgk::connector_name(conf->connector).c_str()); + mir::log_error("Output {} has no associated CRTC to get ", mgk::connector_name(conf->connector)); return true; } @@ -400,10 +397,7 @@ void mga::AtomicKMSOutput::clear_crtc() * * Whatever we're switching to can handle the CRTCs; this should not be fatal. */ - mir::log_info("Couldn't clear output %s (drmModeSetCrtc: %s (%i))", - mgk::connector_name(conf->connector).c_str(), - mir::errno_to_cstr(-result), - -result); + mir::log_info("Couldn't clear output {} (drmModeSetCrtc: {} ({}))", mgk::connector_name(conf->connector), mir::errno_to_cstr(-result), -result); } else { @@ -420,8 +414,7 @@ bool mga::AtomicKMSOutput::page_flip(FBHandle const& fb) auto conf = configuration.lock(); if (!ensure_crtc(*conf)) { - mir::log_error("Output %s has no associated CRTC to set a framebuffer on", - mgk::connector_name(conf->connector).c_str()); + mir::log_error("Output {} has no associated CRTC to set a framebuffer on", mgk::connector_name(conf->connector)); return false; } @@ -469,7 +462,7 @@ bool mga::AtomicKMSOutput::page_flip(FBHandle const& fb) nullptr); if (ret) { - mir::log_error("Failed to schedule page flip: %s (%i)", mir::errno_to_cstr(-ret), -ret); + mir::log_error("Failed to schedule page flip: {} ({})", mir::errno_to_cstr(-ret), -ret); conf->current_crtc = nullptr; return false; } @@ -489,7 +482,7 @@ void mga::AtomicKMSOutput::set_cursor_image(gbm_bo* buffer) gbm_bo_get_width(buffer), gbm_bo_get_height(buffer))) { - mir::log_warning("set_cursor: drmModeSetCursor failed (%s)", mir::errno_to_cstr(-result)); + mir::log_warning("set_cursor: drmModeSetCursor failed ({})", mir::errno_to_cstr(-result)); } cursor_image_set = true; } @@ -502,7 +495,7 @@ void mga::AtomicKMSOutput::move_cursor(geometry::Point destination) if (auto result = drmModeMoveCursor(drm_fd_, conf->current_crtc->crtc_id, destination.x.as_int(), destination.y.as_int())) { - mir::log_warning("move_cursor: drmModeMoveCursor failed (%s)", mir::errno_to_cstr(-result)); + mir::log_warning("move_cursor: drmModeMoveCursor failed ({})", mir::errno_to_cstr(-result)); } } } @@ -515,7 +508,7 @@ bool mga::AtomicKMSOutput::clear_cursor() result = drmModeSetCursor(drm_fd_, conf->current_crtc->crtc_id, 0, 0, 0); if (result) - mir::log_warning("clear_cursor: drmModeSetCursor failed (%s)", mir::errno_to_cstr(-result)); + mir::log_warning("clear_cursor: drmModeSetCursor failed ({})", mir::errno_to_cstr(-result)); } cursor_image_set = false; @@ -576,7 +569,8 @@ void mga::AtomicKMSOutput::set_power_mode(MirPowerMode mode) update.add_property(*conf->crtc_props, "ACTIVE", should_be_active); if (auto err = drmModeAtomicCommit(drm_fd_, update, DRM_MODE_ATOMIC_ALLOW_MODESET, nullptr)) { - mir::log_warning("Failed to set DPMS %s (%s [%i])", should_be_active ? "active" : "off", mir::errno_to_cstr(-err), -err); + mir::log_warning( + "Failed to set DPMS {} ({} [{}])", should_be_active ? "active" : "off", mir::errno_to_cstr(-err), -err); } } else if (should_be_active) @@ -597,8 +591,7 @@ void mga::AtomicKMSOutput::set_gamma(mg::GammaCurves const& gamma) auto conf = configuration.lock(); if (!ensure_crtc(*conf)) { - mir::log_warning("Output %s has no associated CRTC to set gamma on", - mgk::connector_name(conf->connector).c_str()); + mir::log_warning("Output {} has no associated CRTC to set gamma on", mgk::connector_name(conf->connector)); return; } @@ -721,7 +714,7 @@ std::vector edid_for_connector(mir::Fd const& drm_fd, uint32_t connecto if (!property) { mir::log_warning( - "Failed to get EDID property for connector %u: %i (%s)", + "Failed to get EDID property for connector {}: {} ({})", connector_id, errno, mir::errno_to_cstr(errno)); @@ -730,10 +723,7 @@ std::vector edid_for_connector(mir::Fd const& drm_fd, uint32_t connecto if (!drm_property_type_is(property.get(), DRM_MODE_PROP_BLOB)) { - mir::log_warning( - "EDID property on connector %u has unexpected type %u", - connector_id, - property->flags); + mir::log_warning("EDID property on connector {} has unexpected type {}", connector_id, property->flags); return edid; } @@ -744,7 +734,7 @@ std::vector edid_for_connector(mir::Fd const& drm_fd, uint32_t connecto * Log a debug message only. This will trigger for broken monitors which * don't provide an EDID, which is not as unusual as you might think... */ - mir::log_debug("No EDID data available on connector %u", connector_id); + mir::log_debug("No EDID data available on connector {}", connector_id); return edid; } @@ -760,7 +750,7 @@ std::vector edid_for_connector(mir::Fd const& drm_fd, uint32_t connecto { // Failing to read the EDID property is weird, but shouldn't be fatal mir::log_warning( - "Failed to get EDID property blob for connector %u: %i (%s)", + "Failed to get EDID property blob for connector {}: {} ({})", connector_id, err.code().value(), err.what()); diff --git a/src/platforms/atomic-kms/server/kms/display.cpp b/src/platforms/atomic-kms/server/kms/display.cpp index 474323643d4..f646a8df2a3 100644 --- a/src/platforms/atomic-kms/server/kms/display.cpp +++ b/src/platforms/atomic-kms/server/kms/display.cpp @@ -93,7 +93,7 @@ void log_drm_details(mir::Fd const& drm_fd) }; mir::log_info( - "%s: using driver %s [%s] (version: %i.%i.%i driver date: %s)", + "{}: using driver {} [{}] (version: {}.{}.{} driver date: {})", device_name.get(), version->name, version->desc, @@ -108,13 +108,11 @@ void log_drm_details(mir::Fd const& drm_fd) for (auto const& connector : resources.connectors()) { mir::log_info( - "\tOutput: %s (%s)", - mg::kms::connector_name(connector).c_str(), - describe_connection_status(*connector)); + "\tOutput: {} ({})", mg::kms::connector_name(connector), describe_connection_status(*connector)); for (auto i = 0; i < connector->count_modes; ++i) { mir::log_info( - "\t\tMode: %i×%i@%.2f", + "\t\tMode: {}×{}@{:.2f}", connector->modes[i].hdisplay, connector->modes[i].vdisplay, calculate_vrefresh_hz(connector->modes[i])); @@ -123,9 +121,7 @@ void log_drm_details(mir::Fd const& drm_fd) } catch (std::exception const& error) { - mir::log_info( - "\tKMS not supported (%s)", - error.what()); + mir::log_info("\tKMS not supported ({})", error.what()); } } @@ -216,7 +212,7 @@ void mga::Display::register_configuration_change_handler( monitor.process_events([conf_change_handler, this] (mir::udev::Monitor::EventType type, mir::udev::Device const& device) { - mir::log_debug("Processing UDEV event for %s: %i", device.syspath(), type); + mir::log_debug("Processing UDEV event for {}: {}", device.syspath(), static_cast(type)); dirty_configuration = true; conf_change_handler(); }); diff --git a/src/platforms/atomic-kms/server/kms/display_buffer.cpp b/src/platforms/atomic-kms/server/kms/display_buffer.cpp index f7c753e9d8d..620d917fd9f 100644 --- a/src/platforms/atomic-kms/server/kms/display_buffer.cpp +++ b/src/platforms/atomic-kms/server/kms/display_buffer.cpp @@ -294,9 +294,9 @@ auto import_gbm_bo( if (!gbm_bo) { mir::log_debug( - "Failed to import buffer type %s:%s (%s [%i])", + "Failed to import buffer type {}:{} ({} [{}])", buffer->format().name(), - mg::drm_modifier_to_string(buffer->modifier().value_or(DRM_FORMAT_MOD_INVALID)).c_str(), + mg::drm_modifier_to_string(buffer->modifier().value_or(DRM_FORMAT_MOD_INVALID)), mir::errno_to_cstr(errno), errno); return {}; @@ -346,7 +346,7 @@ auto drm_fb_id_from_dma_buffer( if (ret) { - mir::log_warning("drmModeAddFB2WithModifiers returned an error: %d", ret); + mir::log_warning("drmModeAddFB2WithModifiers returned an error: {}", ret); return {}; } diff --git a/src/platforms/atomic-kms/server/kms/egl_helper.cpp b/src/platforms/atomic-kms/server/kms/egl_helper.cpp index 3226e0b244a..e310a67ebaf 100644 --- a/src/platforms/atomic-kms/server/kms/egl_helper.cpp +++ b/src/platforms/atomic-kms/server/kms/egl_helper.cpp @@ -260,9 +260,7 @@ auto mgmh::EGLHelper::egl_config_for_format(EGLint gbm_format) -> EGLConfig EGLint id; if (eglGetConfigAttrib(egl_display, config, EGL_NATIVE_VISUAL_ID, &id) == EGL_FALSE) { - mir::log_warning( - "Failed to query GBM format of EGLConfig: %s", - mg::egl_category().message(eglGetError()).c_str()); + mir::log_warning("Failed to query GBM format of EGLConfig: {}", mg::egl_category().message(eglGetError())); continue; } diff --git a/src/platforms/atomic-kms/server/kms/platform_symbols.cpp b/src/platforms/atomic-kms/server/kms/platform_symbols.cpp index a4b82df290b..c36825b3a75 100644 --- a/src/platforms/atomic-kms/server/kms/platform_symbols.cpp +++ b/src/platforms/atomic-kms/server/kms/platform_symbols.cpp @@ -144,8 +144,7 @@ auto probe_display_platform( // …maybe we support the old pre-standardised Mesa GBM platform? if (strstr(client_extensions, "EGL_MESA_platform_gbm") == nullptr) { - mir::log_info( - "Unsupported: EGL platform supports neither EGL_KHR_platform_gbm nor EGL_MESA_platform_gbm"); + mir::log_info("Unsupported: EGL platform supports neither EGL_KHR_platform_gbm nor EGL_MESA_platform_gbm"); return {}; } } @@ -158,7 +157,7 @@ auto probe_display_platform( { if (quirks.should_skip(device)) { - mir::log_info("Not probing device %s due to specified quirk", device.devnode()); + mir::log_info("Not probing device {} due to specified quirk", device.devnode()); continue; } @@ -207,7 +206,7 @@ auto probe_display_platform( if (!mgk::get_cap_checked(tmp_fd, DRM_CLIENT_CAP_ATOMIC)) { - mir::log_info("KMS device %s does not support Atomic KMS", device.devnode()); + mir::log_info("KMS device {} does not support Atomic KMS", device.devnode()); continue; } @@ -229,7 +228,8 @@ auto probe_display_platform( using namespace std::literals::string_literals; if ("llvmpipe"s == renderer_string) { - mir::log_info("KMS device only has associated software renderer: %s, device unsuitable", renderer_string); + mir::log_info( + "KMS device only has associated software renderer: {}, device unsuitable", renderer_string); supported_devices.back().support_level = mg::probe::unsupported; continue; } @@ -245,9 +245,7 @@ auto probe_display_platform( if (!busid) { - mir::log_warning( - "Failed to query BusID for device %s; cannot check if KMS is available", - device.devnode()); + mir::log_warning("Failed to query BusID for device {}; cannot check if KMS is available", device.devnode()); supported_devices.back().support_level = mg::probe::supported; } else @@ -279,14 +277,12 @@ auto probe_display_platform( [[fallthrough]]; case EINVAL: - mir::log_warning( - "Failed to detect whether device %s supports KMS, continuing with lower confidence", - device.devnode()); + mir::log_warning("Failed to detect whether device {} supports KMS, continuing with lower confidence", device.devnode()); supported_devices.back().support_level = mg::probe::supported; break; default: - mir::log_warning("Unexpected error from drmCheckModesettingSupported(): %s (%i), " + mir::log_warning("Unexpected error from drmCheckModesettingSupported(): {} ({}), " "but continuing anyway", mir::errno_to_cstr(err), err); mir::log_warning("Please file a bug at " "https://github.com/canonical/mir/issues containing this message"); diff --git a/src/platforms/atomic-kms/server/kms/quirks.cpp b/src/platforms/atomic-kms/server/kms/quirks.cpp index 45e967cfeba..ed6a99eadde 100644 --- a/src/platforms/atomic-kms/server/kms/quirks.cpp +++ b/src/platforms/atomic-kms/server/kms/quirks.cpp @@ -104,12 +104,12 @@ class mga::Quirks::Impl // If we didn't process above, we're ignoring... // clangd really can't format this... mir::log_warning( - "Ignoring unexpected value for %s option: %s " - "(expects value of the form “{skip, allow}:{driver,devnode}:”" - ", “disable-kms-probe:{driver,devnode}:”, " - "or “{gbm-surface-has-free-buffers}:{driver,devnode}::{default,skip}”)", + "Ignoring unexpected value for {} option: {} " + "(expects value of the form “{{skip, allow}}:{{driver,devnode}}:”" + ", “disable-kms-probe:{{driver,devnode}}:”, " + "or “{{gbm-surface-has-free-buffers}}:{{driver,devnode}}::{{default,skip}}”)", quirks_option_name, - quirk.c_str()); + quirk); } } } @@ -120,18 +120,18 @@ class mga::Quirks::Impl auto const parent_device = device.parent(); auto const driver = mgc::get_device_driver(parent_device.get()); - mir::log_debug("Quirks(skip/allow): checking device with devnode: %s, driver %s", device.devnode(), driver); + mir::log_debug("Quirks(skip/allow): checking device with devnode: {}, driver {}", devnode, driver); bool const should_skip_devnode = completely_skip.skipped_devnodes.contains(devnode); if (should_skip_devnode) { - mir::log_info("Quirks(skip/allow): skipping device %s (matches devnode quirk %s)", devnode, devnode); + mir::log_info("Quirks(skip/allow): skipping device {} (matches devnode quirk {})", devnode, devnode); } bool const should_skip_driver = completely_skip.skipped_drivers.contains(driver); if (should_skip_driver) { - mir::log_info("Quirks(skip/allow): skipping device %s (matches driver quirk %s)", devnode, driver); + mir::log_info("Quirks(skip/allow): skipping device {} (matches driver quirk {})", devnode, driver); } return should_skip_driver || should_skip_devnode; @@ -142,19 +142,18 @@ class mga::Quirks::Impl auto const devnode = value_or(device.devnode(), ""); auto const parent_device = device.parent(); auto const driver = mgc::get_device_driver(parent_device.get()); - mir::log_debug( - "Quirks(disable-kms-probe): checking device with devnode: %s, driver %s", device.devnode(), driver); + mir::log_debug("Quirks(disable-kms-probe): checking device with devnode: {}, driver {}", devnode, driver); bool const should_skip_devnode = disable_kms_probe.skipped_devnodes.contains(devnode); if (should_skip_devnode) { - mir::log_info("Quirks(disable-kms-probe): skipping device %s (matches devnode quirk %s)", devnode, devnode); + mir::log_info("Quirks(disable-kms-probe): skipping device {} (matches devnode quirk {})", devnode, devnode); } bool const should_skip_driver = disable_kms_probe.skipped_drivers.contains(driver); if (should_skip_driver) { - mir::log_info("Quirks(disable-kms-probe): skipping device %s (matches driver quirk %s)", devnode, driver); + mir::log_info("Quirks(disable-kms-probe): skipping device {} (matches driver quirk {})", devnode, driver); } return !(should_skip_driver || should_skip_devnode); @@ -181,7 +180,8 @@ class mga::Quirks::Impl auto const driver = mgc::get_device_driver(device.parent().get()); auto const devnode = device.devnode(); - mir::log_debug("Quirks(gbm-surface-has-free-buffers): checking device with devnode: %s, driver %s", devnode, driver); + mir::log_debug( + "Quirks(gbm-surface-has-free-buffers): checking device with devnode: {}, driver {}", devnode, driver); auto surface_has_free_buffers_impl_name = mgc::apply_quirk( devnode, diff --git a/src/platforms/eglstream-kms/server/buffer_allocator.cpp b/src/platforms/eglstream-kms/server/buffer_allocator.cpp index 475190984d5..eb25fb4e91f 100644 --- a/src/platforms/eglstream-kms/server/buffer_allocator.cpp +++ b/src/platforms/eglstream-kms/server/buffer_allocator.cpp @@ -856,9 +856,7 @@ auto mge::GLRenderingProvider::surface_for_sink( } catch (std::exception const& err) { - mir::log_info( - "Failed to create EGLStream-backed output surface: %s", - err.what()); + mir::log_info("Failed to create EGLStream-backed output surface: {}", err.what()); } } if (auto cpu_provider = sink.acquire_compatible_allocator()) diff --git a/src/platforms/eglstream-kms/server/display.cpp b/src/platforms/eglstream-kms/server/display.cpp index 56736553538..493582d0acf 100644 --- a/src/platforms/eglstream-kms/server/display.cpp +++ b/src/platforms/eglstream-kms/server/display.cpp @@ -254,9 +254,7 @@ class DisplaySink * * We've failed to submit the flip, though, so cancel the pending flip event */ - mir::log_info("Failed to submit page flip (%s (%i))", - error->message().c_str(), - error->value()); + mir::log_info("Failed to submit page flip ({} ({}))", error->message(), error->value()); event_handler->cancel_flip_events(output->crtc_id()); return; } @@ -291,9 +289,7 @@ class DisplaySink * * Assume this is a transient VT-switch failure :( */ - mir::log_info("Failed to submit page flip (%s (%i))", - error->message().c_str(), - error->value()); + mir::log_info("Failed to submit page flip ({} ({}))", error->message(), error->value()); event_handler->cancel_flip_events(output->crtc_id()); return; } diff --git a/src/platforms/eglstream-kms/server/platform.cpp b/src/platforms/eglstream-kms/server/platform.cpp index ada6899dc91..bcba86d2d54 100644 --- a/src/platforms/eglstream-kms/server/platform.cpp +++ b/src/platforms/eglstream-kms/server/platform.cpp @@ -99,7 +99,7 @@ class BasicEGLContext : public mir::renderer::gl::Context { if (eglDestroyContext(dpy, ctx) != EGL_TRUE) { - mir::log_critical("Failed to destroy EGLContext: %s", mg::egl_category().message(eglGetError()).c_str()); + mir::log_critical("Failed to destroy EGLContext: {}", mg::egl_category().message(eglGetError())); } } diff --git a/src/platforms/eglstream-kms/server/platform_symbols.cpp b/src/platforms/eglstream-kms/server/platform_symbols.cpp index 047ff5c7898..82cca38c5cd 100644 --- a/src/platforms/eglstream-kms/server/platform_symbols.cpp +++ b/src/platforms/eglstream-kms/server/platform_symbols.cpp @@ -150,17 +150,17 @@ auto probe_rendering_platform( message << " " << missing_extension; } - mir::log_debug("EGLStream platform is unsupported: %s", - message.str().c_str()); + mir::log_debug("EGLStream platform is unsupported: {}", message.str()); return {}; } int device_count{0}; if (eglQueryDevicesEXT(0, nullptr, &device_count) != EGL_TRUE) { - mir::log_info("Platform claims to support EGL_EXT_device_base, but " - "eglQueryDevicesEXT falied: %s", - mg::egl_category().message(eglGetError()).c_str()); + mir::log_info( + "Platform claims to support EGL_EXT_device_base, but " + "eglQueryDevicesEXT falied: {}", + mg::egl_category().message(eglGetError())); return {}; } @@ -184,7 +184,7 @@ auto probe_rendering_platform( } catch (std::exception const& e) { - mir::log_debug("Failed to find kernel device for EGLDevice: %s", e.what()); + mir::log_debug("Failed to find kernel device for EGLDevice: {}", e.what()); continue; } @@ -215,7 +215,7 @@ auto probe_rendering_platform( if (display == EGL_NO_DISPLAY) { - mir::log_debug("Failed to create EGLDisplay: %s", mg::egl_category().message(eglGetError()).c_str()); + mir::log_debug("Failed to create EGLDisplay: {}", mg::egl_category().message(eglGetError())); continue; } } @@ -227,7 +227,7 @@ auto probe_rendering_platform( EGLint major_ver{1}, minor_ver{4}; if (!eglInitialize(display, &major_ver, &minor_ver)) { - mir::log_debug("Failed to initialise EGL: %s", mg::egl_category().message(eglGetError()).c_str()); + mir::log_debug("Failed to initialise EGL: {}", mg::egl_category().message(eglGetError())); display = EGL_NO_DISPLAY; } } @@ -256,7 +256,7 @@ auto probe_rendering_platform( for (auto const missing_extension: missing_extensions) { - mir::log_info("EGLDevice found but unsuitable. Missing extension %s", missing_extension); + mir::log_info("EGLDevice found but unsuitable. Missing extension {}", missing_extension); } if (missing_extensions.empty()) @@ -284,8 +284,7 @@ auto probe_rendering_platform( return device.support_level > mg::probe::unsupported; })) { - mir::log_debug( - "EGLDeviceEXTs found, but none are suitable for Mir"); + mir::log_debug("EGLDeviceEXTs found, but none are suitable for Mir"); } return supported_devices; @@ -339,17 +338,17 @@ auto probe_display_platform( message << " " << missing_extension; } - mir::log_debug("EGLStream platform is unsupported: %s", - message.str().c_str()); + mir::log_debug("EGLStream platform is unsupported: {}", message.str()); return {}; } int device_count{0}; if (eglQueryDevicesEXT(0, nullptr, &device_count) != EGL_TRUE) { - mir::log_info("Platform claims to support EGL_EXT_device_base, but " - "eglQueryDevicesEXT falied: %s", - mg::egl_category().message(eglGetError()).c_str()); + mir::log_info( + "Platform claims to support EGL_EXT_device_base, but " + "eglQueryDevicesEXT falied: {}", + mg::egl_category().message(eglGetError())); return {}; } @@ -366,8 +365,7 @@ auto probe_display_platform( auto device_extensions = eglQueryDeviceStringEXT(device, EGL_EXTENSIONS); if (device_extensions) { - mir::log_debug("Found EGLDeviceEXT with device extensions: %s", - device_extensions); + mir::log_debug("Found EGLDeviceEXT with device extensions: {}", device_extensions); // TODO: This test is not strictly correct (will incorrectly match // EGL_EXT_device_drmish_but_not_drm) if (strstr(device_extensions, "EGL_EXT_device_drm") != NULL) @@ -392,13 +390,12 @@ auto probe_display_platform( } catch (std::exception const& e) { - mir::log_info("Failed to query DRM node for EGLDevice: %s", e.what()); + mir::log_info("Failed to query DRM node for EGLDevice: {}", e.what()); continue; } if (drm_fd == mir::Fd::invalid) { - mir::log_debug( - "EGL_EXT_device_drm found, but can't acquire DRM node."); + mir::log_debug("EGL_EXT_device_drm found, but can't acquire DRM node."); continue; } @@ -411,10 +408,7 @@ auto probe_display_platform( if (auto error = -drmSetInterfaceVersion(drm_fd, &sv)) { - mir::log_warning( - "Failed to set DRM interface version on device: %i (%s)", - error, - mir::errno_to_cstr(error)); + mir::log_warning("Failed to set DRM interface version on device: {} ({})", error, mir::errno_to_cstr(error)); continue; } @@ -431,11 +425,7 @@ auto probe_display_platform( } else { - mir::log_warning( - "Failed to check DRM modesetting support for device %s: %s (%i)", - busid.get(), - mir::errno_to_cstr(-err), - -err); + mir::log_warning("Failed to check DRM modesetting support for device {}: {} ({})", busid.get(), mir::errno_to_cstr(-err), -err); } continue; } @@ -455,7 +445,7 @@ auto probe_display_platform( if (display == EGL_NO_DISPLAY) { - mir::log_debug("Failed to create EGLDisplay: %s", mg::egl_category().message(eglGetError()).c_str()); + mir::log_debug("Failed to create EGLDisplay: {}", mg::egl_category().message(eglGetError())); continue; } @@ -465,7 +455,7 @@ auto probe_display_platform( EGLint major_ver{1}, minor_ver{4}; if (!eglInitialize(display, &major_ver, &minor_ver)) { - mir::log_debug("Failed to initialise EGL: %s", mg::egl_category().message(eglGetError()).c_str()); + mir::log_debug("Failed to initialise EGL: {}", mg::egl_category().message(eglGetError())); display = EGL_NO_DISPLAY; } }, @@ -516,7 +506,7 @@ auto probe_display_platform( if (ctx == EGL_NO_CONTEXT) { - mir::log_warning("Failed to create EGL context: %s", mg::egl_category().message(eglGetError()).c_str()); + mir::log_warning("Failed to create EGL context: {}", mg::egl_category().message(eglGetError())); continue; } @@ -529,17 +519,12 @@ auto probe_display_platform( } else if (auto version = mge::parse_nvidia_version(gl_version)) { - mir::log_debug("Detected NVIDIA driver version %i.%i", version->major, version->minor); + mir::log_debug("Detected NVIDIA driver version {}.{}", version->major, version->minor); if (version->major < 396) { - mir::log_warning( - "Detected NVIDIA driver version %i.%i is older than 396.xx", - version->major, - version->minor); - mir::log_warning( - "This driver is known to interact badly with Mir. See https://github.com/canonical/mir/issues/650"); - mir::log_warning( - "Mir will not auto-load the eglstream-kms platform on this driver. To proceed anyway, manually specify the platform library."); + mir::log_warning("Detected NVIDIA driver version {}.{} is older than 396.xx", version->major, version->minor); + mir::log_warning("This driver is known to interact badly with Mir. See https://github.com/canonical/mir/issues/650"); + mir::log_warning("Mir will not auto-load the eglstream-kms platform on this driver. To proceed anyway, manually specify the platform library."); continue; } } @@ -557,7 +542,7 @@ auto probe_display_platform( else { mir::log_debug("EGL_EXT_device_drm found, but missing EGL_EXT_output_base extension."); - mir::log_debug("Available extensions are: %s", eglQueryString(display, EGL_EXTENSIONS)); + mir::log_debug("Available extensions are: {}", eglQueryString(display, EGL_EXTENSIONS)); } } } @@ -568,8 +553,7 @@ auto probe_display_platform( } if (supported_devices.empty()) { - mir::log_debug( - "EGLDeviceEXTs found, but none are suitable for Mir"); + mir::log_debug("EGLDeviceEXTs found, but none are suitable for Mir"); } return supported_devices; diff --git a/src/platforms/evdev-rs/platform_bridge.cpp b/src/platforms/evdev-rs/platform_bridge.cpp index 6de01904d33..b23914965aa 100644 --- a/src/platforms/evdev-rs/platform_bridge.cpp +++ b/src/platforms/evdev-rs/platform_bridge.cpp @@ -34,7 +34,7 @@ miers::PlatformBridge::PlatformBridge( std::unique_ptr miers::PlatformBridge::acquire_device(int major, int minor) const { - mir::log_info("Acquiring device: %d.%d", major, minor); + mir::log_info("Acquiring device: {}.{}", major, minor); auto observer = platform->create_device_observer(); DeviceObserverWithFd* raw_observer = observer.get(); auto future = console->acquire_device(major, minor, std::move(observer)); diff --git a/src/platforms/evdev/fd_store.cpp b/src/platforms/evdev/fd_store.cpp index cc98c1767a2..9ba297854b6 100644 --- a/src/platforms/evdev/fd_store.cpp +++ b/src/platforms/evdev/fd_store.cpp @@ -40,10 +40,10 @@ mir::Fd mie::FdStore::take_fd(char const* path) { if (removed.first == path) { - mir::log_warning("Requested fd for path %s was removed", path); + mir::log_warning("Requested fd for path {} was removed", path); return fds.insert(std::move(removed)).first->second; } - mir::log_warning("Failed to find requested fd for path %s", path); + mir::log_warning("Failed to find requested fd for path {}", path); } return mir::Fd{}; } @@ -60,7 +60,7 @@ void mie::FdStore::remove_fd(int fd) if (element == fds.end()) { - mir::log_warning("Attempted to remove unmanaged fd %i", fd); + mir::log_warning("Attempted to remove unmanaged fd {}", fd); } else { diff --git a/src/platforms/evdev/libinput_device.cpp b/src/platforms/evdev/libinput_device.cpp index 245d99e87aa..f3202083217 100644 --- a/src/platforms/evdev/libinput_device.cpp +++ b/src/platforms/evdev/libinput_device.cpp @@ -617,7 +617,11 @@ void apply_scroll_mode(libinput_device* dev, MirTouchpadScrollMode scroll_mode) if (LIBINPUT_CONFIG_STATUS_SUCCESS != libinput_device_config_scroll_set_method(dev, method)) { auto const default_method = libinput_device_config_scroll_get_default_method(dev); - mir::log_info("On device '%s': Failed to set scroll method to %d, using default (%d)", libinput_device_get_name(dev), method, default_method); + mir::log_info( + "On device '{}': Failed to set scroll method to {}, using default ({})", + libinput_device_get_name(dev), + static_cast(method), + static_cast(default_method)); libinput_device_config_scroll_set_method(dev, default_method); } }; @@ -649,7 +653,11 @@ void apply_click_mode(libinput_device* dev, MirTouchpadClickMode click_mode) if (LIBINPUT_CONFIG_STATUS_SUCCESS != libinput_device_config_click_set_method(dev, method)) { auto const default_method = libinput_device_config_click_get_default_method(dev); - mir::log_info("On device '%s': Failed to set click method to %d, using default (%d)", libinput_device_get_name(dev), method, default_method); + mir::log_info( + "On device '{}': Failed to set click method to {}, using default ({})", + libinput_device_get_name(dev), + static_cast(method), + static_cast(default_method)); libinput_device_config_click_set_method(dev, default_method); } }; diff --git a/src/platforms/evdev/platform.cpp b/src/platforms/evdev/platform.cpp index 816b99eb019..e451dbdb161 100644 --- a/src/platforms/evdev/platform.cpp +++ b/src/platforms/evdev/platform.cpp @@ -365,8 +365,10 @@ void mie::Platform::start() } catch (std::exception const&) { - auto const message = "Failed to handle UDev " + event_type + " event for " + device.syspath(); - log(logging::Severity::warning, MIR_LOG_COMPONENT, std::current_exception(), message); + log(logging::Severity::warning, + MIR_LOG_COMPONENT, + std::current_exception(), + std::format("Failed to handle UDev {} event for {}", event_type, device.syspath())); } }); @@ -426,7 +428,7 @@ void mie::Platform::device_added(libinput_device* dev) auto device_it = find_device(device_ptr.get()); if (end(devices) != device_it) { - log_debug("Device %s is an already opened device", libinput_device_get_sysname(dev)); + log_debug("Device {} is an already opened device", libinput_device_get_sysname(dev)); return; } @@ -436,11 +438,11 @@ void mie::Platform::device_added(libinput_device* dev) input_device_registry->add_device(devices.back()); - log_info("Opened device: %s", describe(dev).c_str()); + log_info("Opened device: {}", describe(dev)); } catch(...) { - log_error("Failure opening device %s", describe(dev).c_str()); + log_error("Failure opening device {}", describe(dev)); } } @@ -454,7 +456,7 @@ void mie::Platform::device_removed(libinput_device* dev) input_device_registry->remove_device(*known_device_pos); devices.erase(known_device_pos); - log_info("Removed device: %s", describe(dev).c_str()); + log_info("Removed device: {}", describe(dev)); } auto mie::Platform::find_device(libinput_device* dev) -> decltype(devices)::iterator diff --git a/src/platforms/gbm-kms/server/buffer_allocator.cpp b/src/platforms/gbm-kms/server/buffer_allocator.cpp index abea0cb5cd9..3329fb52cae 100644 --- a/src/platforms/gbm-kms/server/buffer_allocator.cpp +++ b/src/platforms/gbm-kms/server/buffer_allocator.cpp @@ -148,8 +148,7 @@ void mgg::BufferAllocator::bind_display(wl_display* display, std::shared_ptrname, version->desc, @@ -119,13 +119,11 @@ void log_drm_details(mir::Fd const& drm_fd) for (auto const& connector : resources.connectors()) { mir::log_info( - "\tOutput: %s (%s)", - mg::kms::connector_name(connector).c_str(), - describe_connection_status(*connector)); + "\tOutput: {} ({})", mg::kms::connector_name(connector), describe_connection_status(*connector)); for (auto i = 0; i < connector->count_modes; ++i) { mir::log_info( - "\t\tMode: %i×%i@%.2f", + "\t\tMode: {}×{}@{:.2f}", connector->modes[i].hdisplay, connector->modes[i].vdisplay, calculate_vrefresh_hz(connector->modes[i])); @@ -134,9 +132,7 @@ void log_drm_details(mir::Fd const& drm_fd) } catch (std::exception const& error) { - mir::log_info( - "\tKMS not supported (%s)", - error.what()); + mir::log_info("\tKMS not supported ({})", error.what()); } } @@ -230,7 +226,7 @@ void mgg::Display::register_configuration_change_handler( monitor.process_events([conf_change_handler, this] (mir::udev::Monitor::EventType type, mir::udev::Device const& device) { - mir::log_debug("Processing UDEV event for %s: %i", device.syspath(), type); + mir::log_debug("Processing UDEV event for {}: {}", device.syspath(), static_cast(type)); dirty_configuration = true; conf_change_handler(); }); @@ -512,7 +508,7 @@ auto mgg::GBMDisplayProvider::is_same_device(mir::udev::Device const& render_dev std::unique_ptr primary_node{drmGetPrimaryDeviceNameFromFd(fd)}; std::unique_ptr render_node{drmGetRenderDeviceNameFromFd(fd)}; - mir::log_debug("Checking whether %s is the same device as (%s, %s)...", render_device.devnode(), primary_node.get(), render_node.get()); + mir::log_debug("Checking whether {} is the same device as ({}, {})...", render_device.devnode(), primary_node.get(), render_node.get()); if (primary_node) { diff --git a/src/platforms/gbm-kms/server/kms/egl_helper.cpp b/src/platforms/gbm-kms/server/kms/egl_helper.cpp index 4c930020fdf..e0a9f3527ee 100644 --- a/src/platforms/gbm-kms/server/kms/egl_helper.cpp +++ b/src/platforms/gbm-kms/server/kms/egl_helper.cpp @@ -259,9 +259,7 @@ auto mgmh::EGLHelper::egl_config_for_format(EGLint gbm_format) -> EGLConfig EGLint id; if (eglGetConfigAttrib(egl_display, config, EGL_NATIVE_VISUAL_ID, &id) == EGL_FALSE) { - mir::log_warning( - "Failed to query GBM format of EGLConfig: %s", - mg::egl_category().message(eglGetError()).c_str()); + mir::log_warning("Failed to query GBM format of EGLConfig: {}", mg::egl_category().message(eglGetError())); continue; } diff --git a/src/platforms/gbm-kms/server/kms/platform.cpp b/src/platforms/gbm-kms/server/kms/platform.cpp index 642d6701ef7..6d0c120bc6d 100644 --- a/src/platforms/gbm-kms/server/kms/platform.cpp +++ b/src/platforms/gbm-kms/server/kms/platform.cpp @@ -387,8 +387,7 @@ auto maybe_make_dmabuf_provider( } catch (std::runtime_error const& error) { - mir::log_info( - "Cannot enable linux-dmabuf import support: %s", error.what()); + mir::log_info("Cannot enable linux-dmabuf import support: {}", error.what()); mir::log( mir::logging::Severity::debug, MIR_LOG_COMPONENT, @@ -453,7 +452,7 @@ auto mgg::RenderingPlatform::maybe_create_provider( auto cap_result = drmGetCap(raw_fd, DRM_CAP_SYNCOBJ_TIMELINE, &has_timeline); if (cap_result != 0) { - mir::log_debug("Failed to query DRM_CAP_SYNCOBJ_TIMELINE: %s", mir::errno_to_cstr(-cap_result)); + mir::log_debug("Failed to query DRM_CAP_SYNCOBJ_TIMELINE: {}", mir::errno_to_cstr(-cap_result)); return nullptr; } if (!has_timeline) diff --git a/src/platforms/gbm-kms/server/kms/platform_symbols.cpp b/src/platforms/gbm-kms/server/kms/platform_symbols.cpp index 213695b12be..a9d100fde90 100644 --- a/src/platforms/gbm-kms/server/kms/platform_symbols.cpp +++ b/src/platforms/gbm-kms/server/kms/platform_symbols.cpp @@ -152,8 +152,7 @@ auto probe_display_platform( // …maybe we support the old pre-standardised Mesa GBM platform? if (strstr(client_extensions, "EGL_MESA_platform_gbm") == nullptr) { - mir::log_info( - "Unsupported: EGL platform supports neither EGL_KHR_platform_gbm nor EGL_MESA_platform_gbm"); + mir::log_info("Unsupported: EGL platform supports neither EGL_KHR_platform_gbm nor EGL_MESA_platform_gbm"); return {}; } } @@ -166,14 +165,16 @@ auto probe_display_platform( { if (quirks.should_skip(device)) { - mir::log_info("Not probing device %s due to specified quirk", device.devnode()); + mir::log_info("Not probing device {} due to specified quirk", device.devnode()); continue; } auto driver_name = mg::common::get_device_driver(device.parent().get()); if(std::strcmp(driver_name, "nvidia") == 0) { - mir::log_info("Not probing device %s due to the GBM display platform being incompatible with Nvidia", device.devnode()); + mir::log_info( + "Not probing device {} due to the GBM display platform being incompatible with Nvidia", + device.devnode()); continue; } @@ -238,7 +239,8 @@ auto probe_display_platform( using namespace std::literals::string_literals; if ("llvmpipe"s == renderer_string) { - mir::log_info("KMS device only has associated software renderer: %s, device unsuitable", renderer_string); + mir::log_info( + "KMS device only has associated software renderer: {}, device unsuitable", renderer_string); supported_devices.back().support_level = mg::probe::unsupported; continue; } @@ -254,9 +256,7 @@ auto probe_display_platform( if (!busid) { - mir::log_warning( - "Failed to query BusID for device %s; cannot check if KMS is available", - device.devnode()); + mir::log_warning("Failed to query BusID for device {}; cannot check if KMS is available", device.devnode()); supported_devices.back().support_level = mg::probe::supported; } else @@ -288,14 +288,12 @@ auto probe_display_platform( [[fallthrough]]; case EINVAL: - mir::log_warning( - "Failed to detect whether device %s supports KMS, continuing with lower confidence", - device.devnode()); + mir::log_warning("Failed to detect whether device {} supports KMS, continuing with lower confidence", device.devnode()); supported_devices.back().support_level = mg::probe::supported; break; default: - mir::log_warning("Unexpected error from drmCheckModesettingSupported(): %s (%i), " + mir::log_warning("Unexpected error from drmCheckModesettingSupported(): {} ({}), " "but continuing anyway", mir::errno_to_cstr(err), err); mir::log_warning("Please file a bug at " "https://github.com/canonical/mir/issues containing this message"); @@ -381,8 +379,7 @@ auto probe_rendering_platform( // …maybe we support the old pre-standardised Mesa GBM platform? if (strstr(client_extensions, "EGL_MESA_platform_gbm") == nullptr) { - mir::log_info( - "Unsupported: EGL platform supports neither EGL_KHR_platform_gbm nor EGL_MESA_platform_gbm"); + mir::log_info("Unsupported: EGL platform supports neither EGL_KHR_platform_gbm nor EGL_MESA_platform_gbm"); return {}; } } @@ -393,7 +390,7 @@ auto probe_rendering_platform( { if (quirks.should_skip(device)) { - mir::log_info("Not probing device %s due to specified quirk", device.devnode()); + mir::log_info("Not probing device {} due to specified quirk", device.devnode()); continue; } auto const device_node = device.devnode(); @@ -456,7 +453,7 @@ auto probe_rendering_platform( renderer_string, mir::strlen_c("llvmpipe")) == 0) { - mir::log_info("Detected software renderer: %s", renderer_string); + mir::log_info("Detected software renderer: {}", renderer_string); // Leave the priority at ::unsupported; if we've got a software renderer then // we're not successfully using *this* rendernode. } diff --git a/src/platforms/gbm-kms/server/kms/quirks.cpp b/src/platforms/gbm-kms/server/kms/quirks.cpp index 80029bcee65..0700e4c54a0 100644 --- a/src/platforms/gbm-kms/server/kms/quirks.cpp +++ b/src/platforms/gbm-kms/server/kms/quirks.cpp @@ -96,13 +96,13 @@ class mgg::Quirks::Impl // If we didn't process above, we're ignoring... // clangd really can't format this... mir::log_warning( - "Ignoring unexpected value for %s option: %s " - "(expects value of the form “{skip, allow}:{driver,devnode}:”" - ", “disable-kms-probe:{driver,devnode}:”, " - "“egl-destroy-surface:{driver,devnode}:{default:leak}”), " - "or “gbm-surface-has-free-buffers:{driver,devnode}::{default,skip}”)", + "Ignoring unexpected value for {} option: {} " + "(expects value of the form “{{skip, allow}}:{{driver,devnode}}:”" + ", “disable-kms-probe:{{driver,devnode}}:”, " + "“egl-destroy-surface:{{driver,devnode}}:{{default:leak}}”), " + "or “gbm-surface-has-free-buffers:{{driver,devnode}}::{{default,skip}}”)", quirks_option_name, - quirk.c_str()); + quirk); } } } @@ -113,18 +113,18 @@ class mgg::Quirks::Impl auto const parent_device = device.parent(); auto const driver = mgc::get_device_driver(parent_device.get()); - mir::log_debug("Quirks(skip/allow): checking device with devnode: %s, driver %s", device.devnode(), driver); + mir::log_debug("Quirks(skip/allow): checking device with devnode: {}, driver {}", devnode, driver); bool const should_skip_devnode = completely_skip.skipped_devnodes.contains(devnode); if (should_skip_devnode) { - mir::log_info("Quirks(skip/allow): skipping device %s (matches devnode quirk %s)", devnode, devnode); + mir::log_info("Quirks(skip/allow): skipping device {} (matches devnode quirk {})", devnode, devnode); } bool const should_skip_driver = completely_skip.skipped_drivers.contains(driver); if (should_skip_driver) { - mir::log_info("Quirks(skip/allow): skipping device %s (matches driver quirk %s)", devnode, driver); + mir::log_info("Quirks(skip/allow): skipping device {} (matches driver quirk {})", devnode, driver); } return should_skip_driver || should_skip_devnode; @@ -135,19 +135,18 @@ class mgg::Quirks::Impl auto const devnode = mgc::value_or(device.devnode(), ""); auto const parent_device = device.parent(); auto const driver = mgc::get_device_driver(parent_device.get()); - mir::log_debug( - "Quirks(disable-kms-probe): checking device with devnode: %s, driver %s", device.devnode(), driver); + mir::log_debug("Quirks(disable-kms-probe): checking device with devnode: {}, driver {}", devnode, driver); bool const should_skip_devnode = disable_kms_probe.skipped_devnodes.contains(devnode); if (should_skip_devnode) { - mir::log_info("Quirks(disable-kms-probe): skipping device %s (matches devnode quirk %s)", devnode, devnode); + mir::log_info("Quirks(disable-kms-probe): skipping device {} (matches devnode quirk {})", devnode, devnode); } bool const should_skip_driver = disable_kms_probe.skipped_drivers.contains(driver); if (should_skip_driver) { - mir::log_info("Quirks(disable-kms-probe): skipping device %s (matches driver quirk %s)", devnode, driver); + mir::log_info("Quirks(disable-kms-probe): skipping device {} (matches driver quirk {})", devnode, driver); } return !(should_skip_driver || should_skip_devnode); @@ -173,8 +172,8 @@ class mgg::Quirks::Impl }; auto const driver = mgc::get_device_driver(device.parent().get()); - auto const devnode = device.devnode(); - mir::log_debug("Quirks(egl-destroy-surface): checking device with devnode: %s, driver %s", devnode, driver); + auto const devnode = mgc::value_or(device.devnode(), ""); + mir::log_debug("Quirks(egl-destroy-surface): checking device with devnode: {}, driver {}", devnode, driver); auto egl_destroy_surface_impl_name = mgc::apply_quirk( devnode, driver, egl_destroy_surface.devnodes, egl_destroy_surface.drivers, "egl-destroy-surface"); @@ -203,7 +202,7 @@ class mgg::Quirks::Impl } }; - mir::log_debug("Quirks(gbm-surface-has-free-buffers): checking device with devnode: %s, driver %s", devnode, driver); + mir::log_debug("Quirks(gbm-surface-has-free-buffers): checking device with devnode: {}, driver {}", devnode, driver); auto surface_has_free_buffers_impl_name = mgc::apply_quirk( devnode, diff --git a/src/platforms/gbm-kms/server/kms/real_kms_output.cpp b/src/platforms/gbm-kms/server/kms/real_kms_output.cpp index 25208d4f198..94a2ec80486 100644 --- a/src/platforms/gbm-kms/server/kms/real_kms_output.cpp +++ b/src/platforms/gbm-kms/server/kms/real_kms_output.cpp @@ -151,8 +151,7 @@ bool mgg::RealKMSOutput::set_crtc(FBHandle const& fb) { if (!ensure_crtc()) { - mir::log_error("Output %s has no associated CRTC to set a framebuffer on", - mgk::connector_name(connector).c_str()); + mir::log_error("Output {} has no associated CRTC to set a framebuffer on", mgk::connector_name(connector)); return false; } @@ -162,7 +161,7 @@ bool mgg::RealKMSOutput::set_crtc(FBHandle const& fb) &connector->modes[mode_index]); if (ret) { - mir::log_error("Failed to set CRTC: %s (%i)", mir::errno_to_cstr(-ret), -ret); + mir::log_error("Failed to set CRTC: {} ({})", mir::errno_to_cstr(-ret), -ret); current_crtc = nullptr; return false; } @@ -175,7 +174,7 @@ bool mgg::RealKMSOutput::has_crtc_mismatch() { if (!ensure_crtc()) { - mir::log_error("Output %s has no associated CRTC to get ", mgk::connector_name(connector).c_str()); + mir::log_error("Output {} has no associated CRTC to get ", mgk::connector_name(connector)); return true; } @@ -212,10 +211,7 @@ void mgg::RealKMSOutput::clear_crtc() * * Whatever we're switching to can handle the CRTCs; this should not be fatal. */ - mir::log_info("Couldn't clear output %s (drmModeSetCrtc: %s (%i))", - mgk::connector_name(connector).c_str(), - mir::errno_to_cstr(-result), - -result); + mir::log_info("Couldn't clear output {} (drmModeSetCrtc: {} ({}))", mgk::connector_name(connector), mir::errno_to_cstr(-result), -result); } else { @@ -234,8 +230,7 @@ bool mgg::RealKMSOutput::schedule_page_flip(FBHandle const& fb) return true; if (!current_crtc) { - mir::log_error("Output %s has no associated CRTC to schedule page flips on", - mgk::connector_name(connector).c_str()); + mir::log_error("Output {} has no associated CRTC to schedule page flips on", mgk::connector_name(connector)); return false; } return page_flipper->schedule_flip( @@ -272,8 +267,7 @@ bool mgg::RealKMSOutput::set_cursor_image(gbm_bo* buffer) if (result) { has_cursor_ = false; - mir::log_warning("set_cursor: drmModeSetCursor failed (%s)", - mir::errno_to_cstr(-result)); + mir::log_warning("set_cursor: drmModeSetCursor failed ({})", mir::errno_to_cstr(-result)); } } return !result; @@ -287,8 +281,7 @@ void mgg::RealKMSOutput::move_cursor(geometry::Point destination) destination.x.as_int(), destination.y.as_int())) { - mir::log_warning("move_cursor: drmModeMoveCursor failed (%s)", - mir::errno_to_cstr(-result)); + mir::log_warning("move_cursor: drmModeMoveCursor failed ({})", mir::errno_to_cstr(-result)); } } } @@ -301,8 +294,7 @@ bool mgg::RealKMSOutput::clear_cursor() result = drmModeSetCursor(drm_fd_, current_crtc->crtc_id, 0, 0, 0); if (result) - mir::log_warning("clear_cursor: drmModeSetCursor failed (%s)", - mir::errno_to_cstr(-result)); + mir::log_warning("clear_cursor: drmModeSetCursor failed ({})", mir::errno_to_cstr(-result)); has_cursor_ = false; } @@ -369,8 +361,7 @@ void mgg::RealKMSOutput::set_gamma(mg::GammaCurves const& gamma) if (!ensure_crtc()) { - mir::log_warning("Output %s has no associated CRTC to set gamma on", - mgk::connector_name(connector).c_str()); + mir::log_warning("Output {} has no associated CRTC to set gamma on", mgk::connector_name(connector)); return; } @@ -391,7 +382,7 @@ void mgg::RealKMSOutput::set_gamma(mg::GammaCurves const& gamma) int err = -ret; if (err) - mir::log_warning("drmModeCrtcSetGamma failed: %s", mir::errno_to_cstr(err)); + mir::log_warning("drmModeCrtcSetGamma failed: {}", mir::errno_to_cstr(err)); // TODO: return bool in future? Then do what with it? } @@ -477,7 +468,7 @@ std::vector edid_for_connector(int drm_fd, uint32_t connector_id) if (!property) { mir::log_warning( - "Failed to get EDID property for connector %u: %i (%s)", + "Failed to get EDID property for connector {}: {} ({})", connector_id, errno, mir::errno_to_cstr(errno)); @@ -486,10 +477,7 @@ std::vector edid_for_connector(int drm_fd, uint32_t connector_id) if (!drm_property_type_is(property.get(), DRM_MODE_PROP_BLOB)) { - mir::log_warning( - "EDID property on connector %u has unexpected type %u", - connector_id, - property->flags); + mir::log_warning("EDID property on connector {} has unexpected type {}", connector_id, property->flags); return edid; } @@ -500,7 +488,7 @@ std::vector edid_for_connector(int drm_fd, uint32_t connector_id) * Log a debug message only. This will trigger for broken monitors which * don't provide an EDID, which is not as unusual as you might think... */ - mir::log_debug("No EDID data available on connector %u", connector_id); + mir::log_debug("No EDID data available on connector {}", connector_id); return edid; } @@ -509,7 +497,7 @@ std::vector edid_for_connector(int drm_fd, uint32_t connector_id) if (!blob) { mir::log_warning( - "Failed to get EDID property blob for connector %u: %i (%s)", + "Failed to get EDID property blob for connector {}: {} ({})", connector_id, errno, mir::errno_to_cstr(errno)); diff --git a/src/platforms/renderer-generic-egl/buffer_allocator.cpp b/src/platforms/renderer-generic-egl/buffer_allocator.cpp index 770a291bdb0..15dcf3810ac 100644 --- a/src/platforms/renderer-generic-egl/buffer_allocator.cpp +++ b/src/platforms/renderer-generic-egl/buffer_allocator.cpp @@ -240,8 +240,7 @@ void mge::BufferAllocator::bind_display(wl_display* display, std::shared_ptrroot); auto const screen_reply = mir::make_unique_cptr(xcb_randr_get_screen_info_reply(conn, screen_cookie, nullptr)); auto refresh_rate = static_cast(screen_reply->rate); - mir::log_debug("Detected %.2fHz host output refresh rate.", refresh_rate); + mir::log_debug("Detected {:.2}Hz host output refresh rate.", refresh_rate); return screen_reply->rate; } diff --git a/src/server/console/default_configuration.cpp b/src/server/console/default_configuration.cpp index 19abcb827b6..4465b09af9f 100644 --- a/src/server/console/default_configuration.cpp +++ b/src/server/console/default_configuration.cpp @@ -114,9 +114,7 @@ std::shared_ptr mir::DefaultServerConfiguration::the_conso } catch (std::exception const& e) { - mir::log_debug( - "Not using logind for session management: %s", - e.what()); + mir::log_debug("Not using logind for session management: {}", e.what()); throw; } }; @@ -137,9 +135,7 @@ std::shared_ptr mir::DefaultServerConfiguration::the_conso } catch (std::exception const& e) { - mir::log_debug( - "Not using Linux VT subsystem for session management: %s", - e.what()); + mir::log_debug("Not using Linux VT subsystem for session management: {}", e.what()); throw; } }; diff --git a/src/server/console/ioctl_vt_switcher.cpp b/src/server/console/ioctl_vt_switcher.cpp index de329db30d5..ad242c2a052 100644 --- a/src/server/console/ioctl_vt_switcher.cpp +++ b/src/server/console/ioctl_vt_switcher.cpp @@ -32,6 +32,7 @@ void mir::console::IoctlVTSwitcher::switch_to( { if (ioctl(vt_fd, VT_ACTIVATE, vt_number) == -1) { - mir::log_error("%s:%d: Kernel request to change VT switch failed: %s", __FILE__, __LINE__, mir::errno_to_cstr(errno)); + mir::log_error( + "{}:{}: Kernel request to change VT switch failed: {}", __FILE__, __LINE__, mir::errno_to_cstr(errno)); } } diff --git a/src/server/console/linux_virtual_terminal.cpp b/src/server/console/linux_virtual_terminal.cpp index a65068e009b..5c91ea960ff 100644 --- a/src/server/console/linux_virtual_terminal.cpp +++ b/src/server/console/linux_virtual_terminal.cpp @@ -264,7 +264,7 @@ class EvdevDevice : public mir::LinuxVirtualTerminal::Device * It might result in this Mir server receiving unexpected input, however, so * we should log something. */ - mir::log_warning("Failed to revoke input access: %s (%i)", mir::errno_to_cstr(errno), errno); + mir::log_warning("Failed to revoke input access: {} ({})", mir::errno_to_cstr(errno), errno); } } // Don't keep the device FD open if nothing else needs it now. diff --git a/src/server/console/logind_console_services.cpp b/src/server/console/logind_console_services.cpp index f5d5aff953c..772573c09f9 100644 --- a/src/server/console/logind_console_services.cpp +++ b/src/server/console/logind_console_services.cpp @@ -112,7 +112,7 @@ std::unique_ptr simple_proxy_on_system if (error) { - mir::log_error("Proxy is non-null, but has error set?! Error: %s", error->message); + mir::log_error("Proxy is non-null, but has error set?! Error: {}", error->message); } return proxy; @@ -153,7 +153,7 @@ std::unique_ptr simple_seat_proxy_on_syst if (error) { - mir::log_error("Proxy is non-null, but has error set?! Error: %s", error->message); + mir::log_error("Proxy is non-null, but has error set?! Error: {}", error->message); } return proxy; @@ -186,7 +186,7 @@ std::string object_path_for_current_session(LogindSeat* seat_proxy) BOOST_THROW_EXCEPTION((std::runtime_error{"Seat has no active session"})); } - mir::log_debug("Discovered object path for current session = %s", object_path); + mir::log_debug("Discovered object path for current session = {}", object_path); return {object_path}; } @@ -281,7 +281,7 @@ mir::LogindConsoleServices::LogindConsoleServices( if (!logind_session_call_set_type_sync(session_proxy.get(), "wayland", nullptr, &error)) { - mir::log_debug("Failed to set logind session type: %s", error ? error->message : "unknown error"); + mir::log_debug("Failed to set logind session type: {}", error ? error->message : "unknown error"); } g_signal_connect( @@ -490,9 +490,7 @@ void complete_release_device_call( { auto const error_message = error ? error->message : "unknown error"; - mir::log_warning( - "ReleaseDevice call failed: %s", - error_message); + mir::log_warning("ReleaseDevice call failed: {}", error_message); } } } @@ -546,10 +544,7 @@ std::future> mir::LogindConsoleServices::acquire_de nullptr, &error)) { - mir::log_info("Failed to release device %i:%i: %s", - major(devnum), - minor(devnum), - error->message); + mir::log_info("Failed to release device {}:{}: {}", major(devnum), minor(devnum), error->message); } } } @@ -682,7 +677,7 @@ void complete_pause_device_complete( result, &err)) { - mir::log_warning("PauseDeviceComplete failed: %s", err->message); + mir::log_warning("PauseDeviceComplete failed: {}", err->message); } } } @@ -702,7 +697,7 @@ void mir::LogindConsoleServices::on_pause_device( using namespace std::literals::string_literals; if ("pause"s == suspend_type) { - mir::log_info("Received logind pause event for device %i:%i", major, minor); + mir::log_info("Received logind pause event for device {}:{}", major, minor); it->second->emit_suspended(); logind_session_call_pause_device_complete( me->session_proxy.get(), @@ -713,7 +708,7 @@ void mir::LogindConsoleServices::on_pause_device( } else if ("force"s == suspend_type) { - mir::log_info("Received logind force-pause event for device %i:%i", major, minor); + mir::log_info("Received logind force-pause event for device {}:{}", major, minor); it->second->emit_suspended(); } else if ("gone"s == suspend_type) @@ -733,9 +728,7 @@ void mir::LogindConsoleServices::on_pause_device( * A DRM device is quite unlikely to *actually* be gone, so just ignore * PauseDevice("gone") signals for DRM devices. */ - mir::log_debug( - "Ignoring logind PauseDevice(\"gone\") event for DRM device %i:%i", - major, minor); + mir::log_debug("Ignoring logind PauseDevice(\"gone\") event for DRM device {}:{}", major, minor); return; } it->second->emit_removed(); @@ -753,7 +746,7 @@ void mir::LogindConsoleServices::on_pause_device( } else { - mir::log_warning("Received unhandled PauseDevice type: %s", suspend_type); + mir::log_warning("Received unhandled PauseDevice type: {}", suspend_type); } } } @@ -901,7 +894,7 @@ class LogindVTSwitcher : public mir::VTSwitcher result, &error)) { - mir::log_error("%s:%d: Logind request to switch vt failed: %s", __FILE__, __LINE__, error->message); + mir::log_error("{}:{}: Logind request to switch vt failed: {}", __FILE__, __LINE__, error->message); } } diff --git a/src/server/frontend_wayland/desktop_file_manager.cpp b/src/server/frontend_wayland/desktop_file_manager.cpp index ef2fa893f46..c9e0bbacaae 100644 --- a/src/server/frontend_wayland/desktop_file_manager.cpp +++ b/src/server/frontend_wayland/desktop_file_manager.cpp @@ -70,13 +70,13 @@ std::string mf::DesktopFileManager::resolve_app_id(const scene::Surface* surface // https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/src/shell-window-tracker.c?ref_type=heads#L387 auto app_id = surface->application_id(); rtrim(app_id); // Sometimes, the app id has a space at the end - mir::log_info("Attempting to resolve app id from app_id=%s", app_id.c_str()); + mir::log_info("Attempting to resolve app id from app_id={}", app_id); // First, let's see if this is just a WM_CLASS auto app = cache->lookup_by_wm_class(app_id); if (app) { - mir::log_info("Successfully resolved app id from wm_class, id=%s", app->id.c_str()); + mir::log_info("Successfully resolved app id from wm_class, id={}", app->id); return app->id; } @@ -84,7 +84,7 @@ std::string mf::DesktopFileManager::resolve_app_id(const scene::Surface* surface { if (q.first == app_id) { - mir::log_info("Successfully resolved app id from quirk, id=%s", q.second.c_str()); + mir::log_info("Successfully resolved app id from quirk, id={}", q.second); return q.second; } } @@ -93,7 +93,7 @@ std::string mf::DesktopFileManager::resolve_app_id(const scene::Surface* surface auto found = lookup_basename(app_id); if (found) { - mir::log_info("Successfully resolved app id from basename, id=%s", found->id.c_str()); + mir::log_info("Successfully resolved app id from basename, id={}", found->id); return found->id; } @@ -105,7 +105,7 @@ std::string mf::DesktopFileManager::resolve_app_id(const scene::Surface* surface found = lookup_basename(lowercase_desktop_file); if (found) { - mir::log_info("Successfully resolved app id from lowercase basename, id=%s", found->id.c_str()); + mir::log_info("Successfully resolved app id from lowercase basename, id={}", found->id); return found->id; } @@ -117,7 +117,7 @@ std::string mf::DesktopFileManager::resolve_app_id(const scene::Surface* surface found = resolve_if_snap(pid, socket_fd); if (found) { - mir::log_info("Successfully resolved app id from snap, id=%s", found->id.c_str()); + mir::log_info("Successfully resolved app id from snap, id={}", found->id); return found->id; } @@ -125,7 +125,7 @@ std::string mf::DesktopFileManager::resolve_app_id(const scene::Surface* surface found = resolve_if_flatpak(pid); if (found) { - mir::log_info("Successfully resolved app id from flatpak, id=%s", found->id.c_str()); + mir::log_info("Successfully resolved app id from flatpak, id={}", found->id); return found->id; } @@ -133,7 +133,7 @@ std::string mf::DesktopFileManager::resolve_app_id(const scene::Surface* surface found = resolve_if_executable_matches(pid); if (found) { - mir::log_info("Successfully resolved app id from executable, id=%s", found->id.c_str()); + mir::log_info("Successfully resolved app id from executable, id={}", found->id); return found->id; } @@ -141,7 +141,7 @@ std::string mf::DesktopFileManager::resolve_app_id(const scene::Surface* surface // 1. Resolving from the list of internally running apps using the PID // 2. Resolving via a startup notification // 3. Resolving from a GApplicationID, which GTK sends over DBUS - mir::log_warning("Failed to resolve app id, returning %s", app_id.c_str()); + mir::log_warning("Failed to resolve app id, returning {}", app_id); return app_id; } @@ -199,7 +199,7 @@ std::shared_ptr mf::DesktopFileManager::resolve_if_snap(int pid if (aa_getpeercon(socket_fd, &label_cstr, &mode_cstr) >= 0) { - mir::log_info("Attempting to resolve desktop file via AppArmor for pid: %d", pid); + mir::log_info("Attempting to resolve desktop file via AppArmor for pid: {}", pid); std::string const label{label_cstr}; free(label_cstr); // mode_cstr should NOT be freed, as it's from the same buffer as label_cstr @@ -209,7 +209,7 @@ std::shared_ptr mf::DesktopFileManager::resolve_if_snap(int pid { if (auto file = cache->lookup_by_app_id(sandboxed_app_id)) { - mir::log_info("Successfully resolved desktop file via AppArmor for pid: %d", pid); + mir::log_info("Successfully resolved desktop file via AppArmor for pid: {}", pid); return file; } } @@ -224,11 +224,12 @@ std::shared_ptr mf::DesktopFileManager::resolve_if_snap(int pid #endif // If that fails, try to read /proc//attr/current - mir::log_info("Attempting to resolve desktop file via proc directory for pid: %d", pid); + mir::log_info("Attempting to resolve desktop file via proc directory for pid: {}", pid); std::string attr_file = "/proc/" + std::to_string(pid) + "/attr/current"; if (!std::filesystem::exists(attr_file)) { - mir::log_warning("Failed to resolve desktop file via proc directory for pid %d: %s does not exist", pid, attr_file.c_str()); + mir::log_warning( + "Failed to resolve desktop file via proc directory for pid {}: {} does not exist", pid, attr_file); return nullptr; } @@ -238,7 +239,7 @@ std::shared_ptr mf::DesktopFileManager::resolve_if_snap(int pid auto sandboxed_app_id = parse_snap_security_profile_to_desktop_id(contents); if (sandboxed_app_id.empty()) { - mir::log_info("Failed to resolve desktop file from sandboxed_app_id for pid %d", pid); + mir::log_info("Failed to resolve desktop file from sandboxed_app_id for pid {}", pid); return nullptr; } @@ -247,7 +248,7 @@ std::shared_ptr mf::DesktopFileManager::resolve_if_snap(int pid auto file = cache->lookup_by_app_id(sandboxed_app_id); if (file) { - mir::log_info("Successfully resolved desktop file via proc directory for pid: %d", pid); + mir::log_info("Successfully resolved desktop file via proc directory for pid: {}", pid); return file; } diff --git a/src/server/frontend_wayland/foreign_toplevel_list_v1.cpp b/src/server/frontend_wayland/foreign_toplevel_list_v1.cpp index d35de242a03..34bcfe7f60c 100644 --- a/src/server/frontend_wayland/foreign_toplevel_list_v1.cpp +++ b/src/server/frontend_wayland/foreign_toplevel_list_v1.cpp @@ -317,7 +317,7 @@ void mf::ForeignSceneObserver::create_surface_observer(std::shared_ptr(surface.get())); observer->cease_and_desist(); } @@ -329,7 +329,7 @@ void mf::ForeignSceneObserver::destroy_surface_observer(std::shared_ptr(surface.get())); } else diff --git a/src/server/frontend_wayland/foreign_toplevel_manager_v1.cpp b/src/server/frontend_wayland/foreign_toplevel_manager_v1.cpp index db26e9d381b..5d3a5ee50c7 100644 --- a/src/server/frontend_wayland/foreign_toplevel_manager_v1.cpp +++ b/src/server/frontend_wayland/foreign_toplevel_manager_v1.cpp @@ -264,7 +264,7 @@ void mf::ForeignSceneObserver::surface_removed(std::shared_ptr c if (iter == surface_observers.end()) { log_error( - "Can not remove ForeignSurfaceObserver: surface %p not in observers map", + "Can not remove ForeignSurfaceObserver: surface {} not in observers map", static_cast(surface.get())); } else @@ -293,7 +293,7 @@ void mf::ForeignSceneObserver::create_surface_observer(std::shared_ptr(surface.get())); observer->cease_and_desist(); } @@ -525,7 +525,7 @@ mf::GDesktopFileCache::GDesktopFileCache(const std::shared_ptr &main_l if (config_path_wd < 0) { - mir::log_error("Unable to watch directory %s", application_directory.c_str()); + mir::log_error("Unable to watch directory {}", application_directory); continue; } diff --git a/src/server/frontend_wayland/input_method_v1.cpp b/src/server/frontend_wayland/input_method_v1.cpp index e33a277677c..446ad645d87 100644 --- a/src/server/frontend_wayland/input_method_v1.cpp +++ b/src/server/frontend_wayland/input_method_v1.cpp @@ -252,7 +252,7 @@ class mf::InputMethodV1::Instance : wayland::InputMethodV1 } else { - log_warning("%s: invalid commit serial %d", interface_name, serial); + log_warning("{}: invalid commit serial {}", interface_name, serial); } change.reset(); @@ -537,7 +537,7 @@ class mf::InputPanelV1::Instance : wayland::InputPanelV1 spec.attached_edges = MirPlacementGravity::mir_placement_gravity_south; } else - log_warning("Invalid position: %u", position); + log_warning("Invalid position: {}", position); apply_spec(spec); show(); diff --git a/src/server/frontend_wayland/input_method_v2.cpp b/src/server/frontend_wayland/input_method_v2.cpp index ec79f20020c..0ab1665eeb5 100644 --- a/src/server/frontend_wayland/input_method_v2.cpp +++ b/src/server/frontend_wayland/input_method_v2.cpp @@ -314,7 +314,7 @@ void mf::InputMethodV2::commit(uint32_t serial) } else { - log_warning("%s: invalid commit serial %d", interface_name, serial); + log_warning("{}: invalid commit serial {}", interface_name, serial); } pending_change = ms::TextInputChange{{}}; } diff --git a/src/server/frontend_wayland/layer_shell_v1.cpp b/src/server/frontend_wayland/layer_shell_v1.cpp index 1388b861afc..3af9093a8db 100644 --- a/src/server/frontend_wayland/layer_shell_v1.cpp +++ b/src/server/frontend_wayland/layer_shell_v1.cpp @@ -247,7 +247,7 @@ auto mf::LayerShellV1::get_window(wl_resource* surface) -> std::shared_ptr(surface)); + log_debug("No window currently associated with wayland::LayerSurfaceV1 {}", static_cast(surface)); } return {}; @@ -707,7 +707,7 @@ void mf::LayerSurfaceV1::surface_destroyed() // Until it gets fixed we ignore this error for layer shell specifically. // See: https://gitlab.gnome.org/World/Phosh/squeekboard/-/issues/285 log_warning( - "Ignoring layer shell protocol violation: wl_surface destroyed before associated zwlr_layer_surface_v1@%u", + "Ignoring layer shell protocol violation: wl_surface destroyed before associated zwlr_layer_surface_v1@{}", wl_resource_get_id(resource)); } } diff --git a/src/server/frontend_wayland/virtual_pointer_v1.cpp b/src/server/frontend_wayland/virtual_pointer_v1.cpp index 17af823c462..03fc997404f 100644 --- a/src/server/frontend_wayland/virtual_pointer_v1.cpp +++ b/src/server/frontend_wayland/virtual_pointer_v1.cpp @@ -249,7 +249,7 @@ void mf::VirtualPointerV1::button(uint32_t time, uint32_t button, uint32_t state else { // Since the set of allowed buttons is not clearly defined, we warn instead of throwing a protocol error - log_warning("%s.button given unknown button %d", interface_name, button); + log_warning("{}.button given unknown button {}", interface_name, button); } } diff --git a/src/server/frontend_wayland/wayland_connector.cpp b/src/server/frontend_wayland/wayland_connector.cpp index 0313dfbfd26..359d88e8f4b 100644 --- a/src/server/frontend_wayland/wayland_connector.cpp +++ b/src/server/frontend_wayland/wayland_connector.cpp @@ -478,7 +478,10 @@ void mf::WaylandConnector::stop() { if (eventfd_write(pause_signal, 1) < 0) { - log_error("WaylandConnector::stop() failed to send IPC eventloop pause signal: %s (%i)", mir::errno_to_cstr(errno), errno); + log_error( + "WaylandConnector::stop() failed to send IPC eventloop pause signal: {} ({})", + mir::errno_to_cstr(errno), + errno); } if (dispatch_thread.joinable()) { @@ -511,9 +514,7 @@ int mf::WaylandConnector::client_socket_fd() const if (!wl_client_create(display, socket)) { mir::log_error( - "Failed to create Wayland client object: %s (errno %i)", - mir::errno_to_cstr(errno), - errno); + "Failed to create Wayland client object: {} (errno {})", mir::errno_to_cstr(errno), errno); } }); } @@ -545,7 +546,7 @@ int mf::WaylandConnector::client_socket_fd( if (!wl_client_create(display, socket)) { mir::log_error( - "Failed to create Wayland client object: %s (errno %i)", + "Failed to create Wayland client object: {} (errno {})", mir::errno_to_cstr(errno), errno); } diff --git a/src/server/frontend_wayland/wayland_default_configuration.cpp b/src/server/frontend_wayland/wayland_default_configuration.cpp index 5478f65c6db..30ff95b8a2b 100644 --- a/src/server/frontend_wayland/wayland_default_configuration.cpp +++ b/src/server/frontend_wayland/wayland_default_configuration.cpp @@ -364,7 +364,7 @@ auto configure_wayland_extensions( for (auto const& name : remaining_extension_names) { - mir::log_warning("Wayland extension %s not supported", name.c_str()); + mir::log_warning("Wayland extension {} not supported", name); } return std::make_unique(std::move(enabled_internal_builders), std::move(enabled_external_hooks)); diff --git a/src/server/frontend_wayland/wayland_executor.cpp b/src/server/frontend_wayland/wayland_executor.cpp index dd17567029a..6232b82c029 100644 --- a/src/server/frontend_wayland/wayland_executor.cpp +++ b/src/server/frontend_wayland/wayland_executor.cpp @@ -237,10 +237,7 @@ int mf::WaylandExecutor::State::on_notify(int fd, uint32_t, void* data) eventfd_t unused; if (auto err = eventfd_read(fd, &unused)) { - mir::log_error( - "eventfd_read failed to consume wakeup notification: %s (%i)", - mir::errno_to_cstr(err), - err); + mir::log_error("eventfd_read failed to consume wakeup notification: {} ({})", mir::errno_to_cstr(err), err); } while (auto work = state->get_work()) @@ -328,7 +325,7 @@ mf::WaylandExecutor::~WaylandExecutor() if (auto err = eventfd_write(notify_fd, 1)) { mir::log_critical( - "Failed to create event notification for ~WaylandExecutor: %s (%i)", + "Failed to create event notification for ~WaylandExecutor: {} ({})", mir::errno_to_cstr(err), err); } diff --git a/src/server/frontend_wayland/window_wl_surface_role.cpp b/src/server/frontend_wayland/window_wl_surface_role.cpp index 1ded14ef8b0..d781eb8f7d2 100644 --- a/src/server/frontend_wayland/window_wl_surface_role.cpp +++ b/src/server/frontend_wayland/window_wl_surface_role.cpp @@ -417,8 +417,9 @@ void mf::WindowWlSurfaceRole::surface_destroyed() // "When a client wants to destroy a wl_surface, they must destroy this 'role object' before the wl_surface" // NOTE: the wl_shell_surface specification seems contradictory, so this method is overridden in its implementation // NOTE: it's also overridden in layer shell, for reasons explained there - log_warning("wl_surface@%s destroyed before associated role", - (surface ? std::to_string(wl_resource_get_id(surface.value().resource)) : "?").c_str()); + log_warning( + "wl_surface@{} destroyed before associated role", + (surface ? std::to_string(wl_resource_get_id(surface.value().resource)) : "?")); // This isn't strictly correct (as it only applies to wl-shell) but is commonly assumed (e.g. by SDL2) and // implemented (e.g. Mutter for xdg-shell) diff --git a/src/server/frontend_wayland/wl_shell.cpp b/src/server/frontend_wayland/wl_shell.cpp index a807444007e..103b47b271b 100644 --- a/src/server/frontend_wayland/wl_shell.cpp +++ b/src/server/frontend_wayland/wl_shell.cpp @@ -294,7 +294,7 @@ auto mf::get_wl_shell_window(wl_resource* surface) -> std::shared_ptr(surface)); + log_debug("No window currently associated with wayland::Surface {}", static_cast(surface)); } return {}; diff --git a/src/server/frontend_wayland/wl_surface.cpp b/src/server/frontend_wayland/wl_surface.cpp index c2be29e8317..af892d3c4a3 100644 --- a/src/server/frontend_wayland/wl_surface.cpp +++ b/src/server/frontend_wayland/wl_surface.cpp @@ -212,7 +212,8 @@ void mf::WlSurface::add_subsurface(WlSubsurface* child) { if (std::find(children.begin(), children.end(), child) != children.end()) { - log_warning("Subsurface %p added to surface %p multiple times", static_cast(child), static_cast(this)); + log_warning( + "Subsurface {} added to surface {} multiple times", static_cast(child), static_cast(this)); return; } @@ -257,7 +258,7 @@ void mf::WlSurface::reorder_subsurface(WlSubsurface* child, WlSurface* sibling_s child_pos == pending_surface_order->end()) { log_warning( - "Subsurface (wl_surface@%u) attempted to reorder but not found in parent's (wl_surface@%u) children list", + "Subsurface (wl_surface@{}) attempted to reorder but not found in parent's (wl_surface@{}) children list", wl_resource_get_id(child->get_surface()->raw_resource()), wl_resource_get_id(raw_resource())); return; @@ -279,7 +280,8 @@ void mf::WlSurface::reorder_subsurface(WlSubsurface* child, WlSurface* sibling_s if (sibling_it == pending_surface_order->end()) { log_warning( - "Subsurface (wl_surface@%u) attempted to reorder relative to a sibling (wl_surface@%u) not found in parent's (wl_surface@%u) children list", + "Subsurface (wl_surface@{}) attempted to reorder relative to a sibling (wl_surface@{}) not found in " + "parent's (wl_surface@{}) children list", wl_resource_get_id(child->get_surface()->raw_resource()), wl_resource_get_id(sibling_surface->raw_resource()), wl_resource_get_id(raw_resource())); diff --git a/src/server/frontend_wayland/wl_touch.cpp b/src/server/frontend_wayland/wl_touch.cpp index 90669b891f8..5ecd9256275 100644 --- a/src/server/frontend_wayland/wl_touch.cpp +++ b/src/server/frontend_wayland/wl_touch.cpp @@ -130,12 +130,12 @@ void mf::WlTouch::motion( if (touch == touch_id_to_surface.end()) { - log_warning("WlTouch::motion(): invalid ID %d", touch_id); + log_warning("WlTouch::motion(): invalid ID {}", touch_id); return; } else if (!touch->second.surface) { - log_warning("WlTouch::motion(): ID %d maps to destroyed surface", touch_id); + log_warning("WlTouch::motion(): ID {} maps to destroyed surface", touch_id); return; } @@ -168,7 +168,7 @@ void mf::WlTouch::up(uint32_t serial, std::chrono::milliseconds const& ms, int32 } else { - log_warning("WlTouch::up() called with invalid ID %d", touch_id); + log_warning("WlTouch::up() called with invalid ID {}", touch_id); } } diff --git a/src/server/frontend_wayland/wlr_screencopy_v1.cpp b/src/server/frontend_wayland/wlr_screencopy_v1.cpp index cbbc4992b08..d9e728d1466 100644 --- a/src/server/frontend_wayland/wlr_screencopy_v1.cpp +++ b/src/server/frontend_wayland/wlr_screencopy_v1.cpp @@ -422,7 +422,8 @@ void mf::WlrScreencopyFrameV1::capture(geom::Rectangle buffer_space_damage) { if (!target) { - log_error("WlrScreencopyFrameV1::capture() called without a target, copy %s been called", + log_error( + "WlrScreencopyFrameV1::capture() called without a target, copy {} been called", copy_has_been_called ? "has" : "has not"); report_result(std::nullopt, buffer_space_damage); return; diff --git a/src/server/frontend_wayland/xdg_decoration_unstable_v1.cpp b/src/server/frontend_wayland/xdg_decoration_unstable_v1.cpp index 8297ccf8c02..594468a8727 100644 --- a/src/server/frontend_wayland/xdg_decoration_unstable_v1.cpp +++ b/src/server/frontend_wayland/xdg_decoration_unstable_v1.cpp @@ -206,7 +206,11 @@ auto mir::frontend::XdgToplevelDecorationV1::to_decorations_type(uint32_t mode) pid_t pid; wl_client_get_credentials(client->raw_client(), &pid, nullptr, nullptr); // null pointers are allowed - mir::log_warning("Client PID: %d, attempted to set invalid zxdg_toplevel_decoration_v1 mode (%d), defaulting to client side.", pid, mode); + mir::log_warning( + "Client PID: {}, attempted to set invalid zxdg_toplevel_decoration_v1 mode ({}), defaulting to client " + "side.", + pid, + mode); return DecorationStrategy::DecorationsType::csd; } diff --git a/src/server/frontend_wayland/xdg_output_v1.cpp b/src/server/frontend_wayland/xdg_output_v1.cpp index 73f79d554da..6dd944e8d78 100644 --- a/src/server/frontend_wayland/xdg_output_v1.cpp +++ b/src/server/frontend_wayland/xdg_output_v1.cpp @@ -132,8 +132,8 @@ mf::XdgOutputV1::XdgOutputV1( else { log_warning( - "xdg_output_v1 is v%d (meaning Mir must send wl_output.done), " - "but wl_output is only v%d (meaning it can't)", + "xdg_output_v1 is v{} (meaning Mir must send wl_output.done), " + "but wl_output is only v{} (meaning it can't)", wl_resource_get_version(resource), wl_resource_get_version(wl_output_resource)); } diff --git a/src/server/frontend_wayland/xdg_shell_stable.cpp b/src/server/frontend_wayland/xdg_shell_stable.cpp index 957221284b7..3f34a3834dd 100644 --- a/src/server/frontend_wayland/xdg_shell_stable.cpp +++ b/src/server/frontend_wayland/xdg_shell_stable.cpp @@ -901,7 +901,7 @@ auto mf::XdgShellStable::get_window(wl_resource* surface) -> std::shared_ptr(surface)); + log_debug("No window currently associated with wayland::XdgSurface {}", static_cast(surface)); } return {}; diff --git a/src/server/frontend_wayland/xdg_shell_v6.cpp b/src/server/frontend_wayland/xdg_shell_v6.cpp index 1969d73943d..66986bb292c 100644 --- a/src/server/frontend_wayland/xdg_shell_v6.cpp +++ b/src/server/frontend_wayland/xdg_shell_v6.cpp @@ -696,7 +696,7 @@ auto mf::XdgShellV6::get_window(wl_resource* surface) -> std::shared_ptr(surface)); + log_debug("No window currently associated with wayland::XdgSurfaceV6 {}", static_cast(surface)); } return {}; diff --git a/src/server/frontend_xwayland/xcb_connection.h b/src/server/frontend_xwayland/xcb_connection.h index 2b5a64888ad..57dfd9c8978 100644 --- a/src/server/frontend_xwayland/xcb_connection.h +++ b/src/server/frontend_xwayland/xcb_connection.h @@ -121,7 +121,7 @@ class XCBConnection : on_success{std::move(on_success)}, on_error{[](std::string const& message) { - log_error("XCB error: %s", message.c_str()); + log_error("XCB error: {}", message); }} { } diff --git a/src/server/frontend_xwayland/xwayland_client_manager.cpp b/src/server/frontend_xwayland/xwayland_client_manager.cpp index 7619de7c383..a3a03b1d003 100644 --- a/src/server/frontend_xwayland/xwayland_client_manager.cpp +++ b/src/server/frontend_xwayland/xwayland_client_manager.cpp @@ -60,7 +60,7 @@ mf::XWaylandClientManager::~XWaylandClientManager() if (!sessions_by_pid.empty()) { log_warning( - "XWaylandClientManager destroyed with %zu sessions in the map; " + "XWaylandClientManager destroyed with {} sessions in the map; " "if any XWaylandClientManager::Sessions are still alive, a crash is likely when they are destroyed", sessions_by_pid.size()); } @@ -81,7 +81,7 @@ auto mf::XWaylandClientManager::session_for_client(pid_t client_pid) -> std::sha { if (verbose_xwayland_logging_enabled()) { - log_info("Returning existing XWayland session for PID %d (use count %lu)", client_pid, session.use_count()); + log_info("Returning existing XWayland session for PID {} (use count {})", client_pid, session.use_count()); } } else @@ -91,8 +91,7 @@ auto mf::XWaylandClientManager::session_for_client(pid_t client_pid) -> std::sha struct stat proc_stat{}; if (stat(proc.c_str(), &proc_stat) == -1) { - log_debug("Failed to get uid & gid for PID %d using stat(%s, ...), falling back to get(uid,gid)", - client_pid, proc.c_str()); + log_debug("Failed to get uid & gid for PID {} using stat({}, ...), falling back to get(uid,gid)", client_pid, proc); proc_stat.st_uid = getuid(); proc_stat.st_gid = getgid(); @@ -100,14 +99,14 @@ auto mf::XWaylandClientManager::session_for_client(pid_t client_pid) -> std::sha if (!session_authorizer->connection_is_allowed({client_pid, proc_stat.st_uid, proc_stat.st_gid})) { - log_error("X11 session not authorized for PID %d, rejecting!", client_pid); + log_error("X11 session not authorized for PID {}, rejecting!", client_pid); return nullptr; } session = std::make_shared(this, client_pid); sessions_by_pid[client_pid] = session; if (verbose_xwayland_logging_enabled()) { - log_info("Created new XWayland session for PID %d", client_pid); + log_info("Created new XWayland session for PID {}", client_pid); } } @@ -128,11 +127,11 @@ void mf::XWaylandClientManager::drop_expired(pid_t client_pid) sessions_by_pid.erase(iter); if (verbose_xwayland_logging_enabled()) { - log_info("Closed XWayland session for PID %d", client_pid); + log_info("Closed XWayland session for PID {}", client_pid); } } else if (verbose_xwayland_logging_enabled()) { - log_info("XWaylandClientManager::drop_expired() called with PID %d, which is not expired", client_pid); + log_info("XWaylandClientManager::drop_expired() called with PID {}, which is not expired", client_pid); } } diff --git a/src/server/frontend_xwayland/xwayland_clipboard_provider.cpp b/src/server/frontend_xwayland/xwayland_clipboard_provider.cpp index f237a5f8971..dd949489738 100644 --- a/src/server/frontend_xwayland/xwayland_clipboard_provider.cpp +++ b/src/server/frontend_xwayland/xwayland_clipboard_provider.cpp @@ -255,7 +255,7 @@ class mf::XWaylandClipboardProvider::SelectionSender void notify_cancelled(const char* reason) const { - mir::log_warning("failed to send clipboard data to X11 client: %s", reason); + mir::log_warning("failed to send clipboard data to X11 client: {}", reason); send_selection_notify(*connection, time, requester, XCB_ATOM_NONE, selection, target); connection->flush(); } @@ -322,7 +322,7 @@ mf::XWaylandClipboardProvider::~XWaylandClipboardProvider() if (!pending_incremental_sends.empty()) { log_warning( - "XWaylandClipboardProvider destroyed with %zu incremental sends in progress", + "XWaylandClipboardProvider destroyed with {} incremental sends in progress", pending_incremental_sends.size()); } clipboard->unregister_interest(*clipboard_observer); @@ -370,9 +370,7 @@ void mf::XWaylandClipboardProvider::selection_request_event(xcb_selection_reques // This seems to happen during normal operation if (verbose_xwayland_logging_enabled()) { - log_info( - "XWayland selection request event with invalid target %s", - connection->query_name(event->target).c_str()); + log_info("XWayland selection request event with invalid target {}", connection->query_name(event->target)); } send_selection_notify(*connection, event->time, event->requestor, XCB_ATOM_NONE, event->selection, event->target); } @@ -445,7 +443,7 @@ void mf::XWaylandClipboardProvider::send_data( if (pipe2(fds, O_CLOEXEC) != 0) { - log_warning("failed to send clipboard data to X11 client: pipe2 error: %s", mir::errno_to_cstr(errno)); + log_warning("failed to send clipboard data to X11 client: pipe2 error: {}", mir::errno_to_cstr(errno)); send_selection_notify(*connection, time, requester, XCB_ATOM_NONE, connection->CLIPBOARD, target); return; } diff --git a/src/server/frontend_xwayland/xwayland_clipboard_source.cpp b/src/server/frontend_xwayland/xwayland_clipboard_source.cpp index 37461da2de7..ec46e4b162e 100644 --- a/src/server/frontend_xwayland/xwayland_clipboard_source.cpp +++ b/src/server/frontend_xwayland/xwayland_clipboard_source.cpp @@ -101,7 +101,7 @@ class mf::XWaylandClipboardSource::ClipboardSource : public ms::DataExchangeSour auto const target_type = mime_types_map.find(mime_type); if (target_type == mime_types_map.end()) { - log_error("X11 clipboard source given invalid mime type %s", mime_type.c_str()); + log_error("X11 clipboard source given invalid mime type {}", mime_type); return; } owner->initiate_send(target_type->second, receiver_fd); @@ -176,7 +176,7 @@ class mf::XWaylandClipboardSource::DataSender : public md::Dispatchable auto const len = write(destination_fd, &data[0], data.size()); if (len < 0) { - mir::log_error("failed to send X11 clipboard data: %s", mir::errno_to_cstr(errno)); + mir::log_error("failed to send X11 clipboard data: {}", mir::errno_to_cstr(errno)); return false; } data.erase(data.begin(), data.begin() + len); @@ -432,7 +432,7 @@ void mf::XWaylandClipboardSource::read_and_send_wl_selection_data(std::lock_guar }, [&](const std::string& error_message) { - log_error("Error getting selection property: %s", error_message.c_str()); + log_error("Error getting selection property: {}", error_message); in_progress_send.reset(); }}); @@ -456,7 +456,7 @@ void mf::XWaylandClipboardSource::add_data_to_in_progress_send( std::vector data{data_ptr, data_ptr + data_size}; if (verbose_xwayland_logging_enabled()) { - log_info("Writing %zu bytes of clipboard data from X11", data.size()); + log_info("Writing {} bytes of clipboard data from X11", data.size()); } if (in_progress_send->add_data(std::move(data))) diff --git a/src/server/frontend_xwayland/xwayland_connector.cpp b/src/server/frontend_xwayland/xwayland_connector.cpp index 48e16c7dad7..4e2cb73b578 100644 --- a/src/server/frontend_xwayland/xwayland_connector.cpp +++ b/src/server/frontend_xwayland/xwayland_connector.cpp @@ -70,7 +70,7 @@ void mf::XWaylandConnector::start() std::unique_lock lock{mutex}; is_started = true; maybe_create_spawner(lock); - mir::log_info("XWayland started on X11 display %s", spawner->x11_display().c_str()); + mir::log_info("XWayland started on X11 display {}", spawner->x11_display()); } } diff --git a/src/server/frontend_xwayland/xwayland_cursors.cpp b/src/server/frontend_xwayland/xwayland_cursors.cpp index dfe08fee111..cbad2e43879 100644 --- a/src/server/frontend_xwayland/xwayland_cursors.cpp +++ b/src/server/frontend_xwayland/xwayland_cursors.cpp @@ -133,7 +133,7 @@ auto mf::XWaylandCursors::Loader::get_xcursor_size() -> int } else { - log_warning("Could not parse XCURSOR_SIZE='%s'", size_env_var_string); + log_warning("Could not parse XCURSOR_SIZE='{}'", size_env_var_string); } } if (result == 0) diff --git a/src/server/frontend_xwayland/xwayland_server.cpp b/src/server/frontend_xwayland/xwayland_server.cpp index 51d4ee9eeca..0ec00529006 100644 --- a/src/server/frontend_xwayland/xwayland_server.cpp +++ b/src/server/frontend_xwayland/xwayland_server.cpp @@ -197,7 +197,7 @@ mf::XWaylandServer::~XWaylandServer() // Calling is_running() one more time will ensure the process is reaped if (is_running()) { - log_warning("Failed to kill Xwayland process with PID %d", xwayland.pid); + log_warning("Failed to kill Xwayland process with PID {}", xwayland.pid); } } diff --git a/src/server/frontend_xwayland/xwayland_spawner.cpp b/src/server/frontend_xwayland/xwayland_spawner.cpp index 54058abe85d..1143b155d5a 100644 --- a/src/server/frontend_xwayland/xwayland_spawner.cpp +++ b/src/server/frontend_xwayland/xwayland_spawner.cpp @@ -90,9 +90,7 @@ auto create_socket(std::vector& fds, struct sockaddr_un *addr, size_t p if (fd < 0) { mir::log_warning( - "Failed to create socket %c%s", - addr->sun_path[0] ? addr->sun_path[0] : '@', - addr->sun_path + 1); + "Failed to create socket {}{}", addr->sun_path[0] ? addr->sun_path[0] : '@', addr->sun_path + 1); return; } @@ -108,10 +106,7 @@ auto create_socket(std::vector& fds, struct sockaddr_un *addr, size_t p if (bind(fd, (struct sockaddr*)addr, size) < 0) { - mir::log_warning( - "Failed to bind socket %c%s", - addr->sun_path[0] ? addr->sun_path[0] : '@', - addr->sun_path + 1); + mir::log_warning("Failed to bind socket {}{}", addr->sun_path[0] ? addr->sun_path[0] : '@', addr->sun_path + 1); if (addr->sun_path[0]) { unlink(addr->sun_path); @@ -122,9 +117,7 @@ auto create_socket(std::vector& fds, struct sockaddr_un *addr, size_t p if (listen(fd, 1) < 0) { mir::log_warning( - "Failed to listen to socket %c%s", - addr->sun_path[0] ? addr->sun_path[0] : '@', - addr->sun_path + 1); + "Failed to listen to socket {}{}", addr->sun_path[0] ? addr->sun_path[0] : '@', addr->sun_path + 1); if (addr->sun_path[0]) { unlink(addr->sun_path); diff --git a/src/server/frontend_xwayland/xwayland_surface.cpp b/src/server/frontend_xwayland/xwayland_surface.cpp index 84f7c3867a6..1c98a514764 100644 --- a/src/server/frontend_xwayland/xwayland_surface.cpp +++ b/src/server/frontend_xwayland/xwayland_surface.cpp @@ -233,7 +233,7 @@ auto wm_window_type_to_mir_window_type( if (override_redirect) message << "\n\toverride_redirect"; - mir::log_debug("%s%s\n~~~~~~~~~~~~~~", __PRETTY_FUNCTION__ , message.str().c_str()); + mir::log_debug("{}{}\n~~~~~~~~~~~~~~", __PRETTY_FUNCTION__, message.str()); } // See https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm46515148839648 @@ -271,9 +271,7 @@ auto wm_window_type_to_mir_window_type( } else if (mir::verbose_xwayland_logging_enabled()) { - mir::log_debug( - "Ignoring unknown window type %s", - connection->query_name(wm_type).c_str()); + mir::log_debug("Ignoring unknown window type {}", connection->query_name(wm_type)); } } @@ -532,7 +530,7 @@ void mf::XWaylandSurface::take_focus() { if (verbose_xwayland_logging_enabled()) { - log_debug("%s taking focus", connection->window_debug_string(window).c_str()); + log_debug("{} taking focus", connection->window_debug_string(window)); } bool supports_take_focus; @@ -698,9 +696,9 @@ void mf::XWaylandSurface::attach_wl_surface(WlSurface* wl_surface) if (verbose_xwayland_logging_enabled()) { log_debug( - "Attaching wl_surface@%u to %s...", + "Attaching wl_surface@{} to {}...", wl_resource_get_id(wl_surface->resource), - connection->window_debug_string(window).c_str()); + connection->window_debug_string(window)); } auto state = StateTracker::make_withdrawn(); @@ -846,7 +844,7 @@ void mf::XWaylandSurface::move_resize(uint32_t detail) } else { - mir::log_warning("XWaylandSurface::move_resize() called with unknown detail %d", detail); + mir::log_warning("XWaylandSurface::move_resize() called with unknown detail {}", detail); } } @@ -941,9 +939,7 @@ auto mf::XWaylandSurface::StateTracker::with_net_wm_state_change( { if (mir::verbose_xwayland_logging_enabled()) { - mir::log_debug( - "Ignoring unknown _NET_WM_STATE %s", - conn.query_name(net_wm_state).c_str()); + mir::log_debug("Ignoring unknown _NET_WM_STATE {}", conn.query_name(net_wm_state)); } return *this; } @@ -1015,9 +1011,7 @@ void mf::XWaylandSurface::scene_surface_close_requested() { if (verbose_xwayland_logging_enabled()) { - log_debug( - "Sending WM_DELETE_WINDOW request to %s", - connection->window_debug_string(window).c_str()); + log_debug("Sending WM_DELETE_WINDOW request to {}", connection->window_debug_string(window)); } uint32_t const client_message_data[]{ connection->WM_DELETE_WINDOW, @@ -1030,8 +1024,8 @@ void mf::XWaylandSurface::scene_surface_close_requested() if (verbose_xwayland_logging_enabled()) { log_debug( - "Not closing %s (because it does not support WM_DELETE_WINDOW)", - connection->window_debug_string(window).c_str()); + "Not closing {} (because it does not support WM_DELETE_WINDOW)", + connection->window_debug_string(window)); } } connection->flush(); @@ -1041,7 +1035,7 @@ void mf::XWaylandSurface::wl_surface_destroyed() { if (verbose_xwayland_logging_enabled()) { - log_debug("%s's wl_surface destoyed", connection->window_debug_string(window).c_str()); + log_debug("{}'s wl_surface destoyed", connection->window_debug_string(window)); } close(); } @@ -1077,15 +1071,14 @@ void mf::XWaylandSurface::is_transient_for(xcb_window_t transient_for) { if (transient_for != XCB_WINDOW_NONE) { - log_debug("%s set as transient for %s", - connection->window_debug_string(window).c_str(), - connection->window_debug_string(transient_for).c_str()); + log_debug( + "{} set as transient for {}", + connection->window_debug_string(window), + connection->window_debug_string(transient_for)); } else { - log_debug( - "%s is not transient", - connection->window_debug_string(window).c_str()); + log_debug("{} is not transient", connection->window_debug_string(window)); } } @@ -1156,15 +1149,15 @@ void mf::XWaylandSurface::inform_client_of_geometry( while (inflight_configures.size() > 1000) { inflight_configures.pop_front(); - log_warning("%s inflight_configures buffer capped", connection->window_debug_string(window).c_str()); + log_warning("{} inflight_configures buffer capped", connection->window_debug_string(window)); } lock.unlock(); if (verbose_xwayland_logging_enabled()) { - log_debug("configuring %s:", connection->window_debug_string(window).c_str()); - log_debug(" position: %d, %d", geometry.left().as_int(), geometry.top().as_int()); - log_debug(" size: %dx%d", geometry.size.width.as_int(), geometry.size.height.as_int()); + log_debug("configuring {}:", connection->window_debug_string(window)); + log_debug(" position: {}, {}", geometry.left().as_int(), geometry.top().as_int()); + log_debug(" size: {}x{}", geometry.size.width.as_int(), geometry.size.height.as_int()); } connection->configure_window( @@ -1330,9 +1323,9 @@ auto mf::XWaylandSurface::plausible_parent(ProofOfMutexLock const&) -> std::shar if (verbose_xwayland_logging_enabled()) { log_debug( - "Set parent of %s from xwm->get_focused_window() (%s)", - connection->window_debug_string(window).c_str(), - connection->window_debug_string(focused_window.value()).c_str()); + "Set parent of {} from xwm->get_focused_window() ({})", + connection->window_debug_string(window), + connection->window_debug_string(focused_window.value())); } return parent; } @@ -1341,7 +1334,7 @@ auto mf::XWaylandSurface::plausible_parent(ProofOfMutexLock const&) -> std::shar if (verbose_xwayland_logging_enabled()) { - log_debug("Unable to find suitable parent for %s", connection->window_debug_string(window).c_str()); + log_debug("Unable to find suitable parent for {}", connection->window_debug_string(window)); } return {}; } @@ -1389,8 +1382,8 @@ void mf::XWaylandSurface::wm_hints(std::vector const& hints) if (verbose_xwayland_logging_enabled()) { log_debug( - "%s input hint set to %s", - connection->window_debug_string(window).c_str(), + "{} input hint set to {}", + connection->window_debug_string(window), hints[WmHintsIndices::INPUT] ? "true" : "false"); } } @@ -1403,7 +1396,7 @@ void mf::XWaylandSurface::wm_size_hints(std::vector const& hints) std::lock_guard lock{mutex}; if (hints.size() != WmSizeHintsIndices::END) { - log_error("WM_NORMAL_HINTS only has %zu element(s)", hints.size()); + log_error("WM_NORMAL_HINTS only has {} element(s)", hints.size()); return; } auto const flags = static_cast(hints[WmSizeHintsIndices::FLAGS]); @@ -1414,8 +1407,8 @@ void mf::XWaylandSurface::wm_size_hints(std::vector const& hints) if (verbose_xwayland_logging_enabled()) { log_debug( - "%s min size set to %dx%d", - connection->window_debug_string(window).c_str(), + "{} min size set to {}x{}", + connection->window_debug_string(window), hints[WmSizeHintsIndices::MIN_WIDTH], hints[WmSizeHintsIndices::MIN_HEIGHT]); } @@ -1427,8 +1420,8 @@ void mf::XWaylandSurface::wm_size_hints(std::vector const& hints) if (verbose_xwayland_logging_enabled()) { log_debug( - "%s max size set to %dx%d", - connection->window_debug_string(window).c_str(), + "{} max size set to {}x{}", + connection->window_debug_string(window), hints[WmSizeHintsIndices::MAX_WIDTH], hints[WmSizeHintsIndices::MAX_HEIGHT]); } @@ -1440,7 +1433,7 @@ void mf::XWaylandSurface::motif_wm_hints(std::vector const& hints) std::lock_guard lock{mutex}; if (hints.size() != MotifWmHintsIndices::END) { - log_error("_MOTIF_WM_HINTS value has incorrect size %zu", hints.size()); + log_error("_MOTIF_WM_HINTS value has incorrect size {}", hints.size()); return; } if (MotifWmHintsFlags::DECORATIONS & hints[MotifWmHintsIndices::FLAGS]) diff --git a/src/server/frontend_xwayland/xwayland_surface_role.cpp b/src/server/frontend_xwayland/xwayland_surface_role.cpp index edb21ab33bc..c41d4bb5251 100644 --- a/src/server/frontend_xwayland/xwayland_surface_role.cpp +++ b/src/server/frontend_xwayland/xwayland_surface_role.cpp @@ -43,7 +43,7 @@ mf::XWaylandSurfaceRole::XWaylandSurfaceRole( wl_surface->set_role(this); if (verbose_xwayland_logging_enabled()) { - log_debug("Created XWaylandSurfaceRole for wl_surface@%u", wl_resource_get_id(wl_surface->resource)); + log_debug("Created XWaylandSurfaceRole for wl_surface@{}", wl_resource_get_id(wl_surface->resource)); } } @@ -52,7 +52,7 @@ mf::XWaylandSurfaceRole::~XWaylandSurfaceRole() wl_surface->clear_role(); if (verbose_xwayland_logging_enabled()) { - log_debug("Destroyed XWaylandSurfaceRole for wl_surface@%u", wl_resource_get_id(wl_surface->resource)); + log_debug("Destroyed XWaylandSurfaceRole for wl_surface@{}", wl_resource_get_id(wl_surface->resource)); } } diff --git a/src/server/frontend_xwayland/xwayland_wm.cpp b/src/server/frontend_xwayland/xwayland_wm.cpp index 0ee48e9b298..0d2a58197c4 100644 --- a/src/server/frontend_xwayland/xwayland_wm.cpp +++ b/src/server/frontend_xwayland/xwayland_wm.cpp @@ -93,7 +93,7 @@ auto init_xfixes(mf::XCBConnection const& connection) -> xcb_query_extension_rep if (mir::verbose_xwayland_logging_enabled()) { - mir::log_debug("xfixes version: %d.%d", xfixes_reply->major_version, xfixes_reply->minor_version); + mir::log_debug("xfixes version: {}.{}", xfixes_reply->major_version, xfixes_reply->minor_version); } return xfixes; @@ -209,7 +209,7 @@ mf::XWaylandWM::XWaylandWM( { if (verbose_xwayland_logging_enabled()) { - log_debug("Window %s already exists", connection->window_debug_string(window).c_str()); + log_debug("Window {} already exists", connection->window_debug_string(window)); } auto const geometry_cookie = xcb_get_geometry(*connection, window); @@ -231,8 +231,8 @@ mf::XWaylandWM::XWaylandWM( else { log_warning( - "Failed to load geometry and attributes for %s", - connection->window_debug_string(window).c_str()); + "Failed to load geometry and attributes for {}", + connection->window_debug_string(window)); } }); } @@ -263,7 +263,7 @@ mf::XWaylandWM::~XWaylandWM() } if (verbose_xwayland_logging_enabled()) - log_debug("Closing %zu XWayland surface(s)...", local_surfaces.size()); + log_debug("Closing {} XWayland surface(s)...", local_surfaces.size()); for (auto const& surface : local_surfaces) { @@ -336,11 +336,7 @@ void mf::XWaylandWM::set_focus(xcb_window_t xcb_window, bool should_be_focused) if (verbose_xwayland_logging_enabled()) { - log_debug( - "%s %s %s...", - should_be_focused ? "Focusing" : "Unfocusing", - was_focused ? "focused" : "unfocused", - connection->window_debug_string(xcb_window).c_str()); + log_debug("{} {} {}...", should_be_focused ? "Focusing" : "Unfocusing", was_focused ? "focused" : "unfocused", connection->window_debug_string(xcb_window)); } if (should_be_focused == was_focused) @@ -445,10 +441,7 @@ void mf::XWaylandWM::restack_surfaces() { if (verbose_xwayland_logging_enabled()) { - log_debug( - "Stacking %s on top of %s", - connection->window_debug_string(window).c_str(), - connection->window_debug_string(window_below).c_str()); + log_debug("Stacking {} on top of {}", connection->window_debug_string(window), connection->window_debug_string(window_below)); } connection->configure_window( @@ -523,10 +516,7 @@ void mf::XWaylandWM::manage_window(xcb_window_t window, geom::Rectangle const& g auto const log_prop = [this, atom](std::string const& value) { auto const prop_name = connection->query_name(atom); - log_debug( - " | %s: %s", - prop_name.c_str(), - value.c_str()); + log_debug(" | {}: {}", prop_name, value); }; functions.push_back(connection->read_property( @@ -545,13 +535,13 @@ void mf::XWaylandWM::manage_window(xcb_window_t window, geom::Rectangle const& g })); } - log_debug("%s has %d initial propertie(s):", connection->window_debug_string(window).c_str(), prop_count); + log_debug("{} has {} initial propertie(s):", connection->window_debug_string(window), prop_count); for (auto const& f : functions) f(); } else { - log_debug("%s's initial properties failed to load", connection->window_debug_string(window).c_str()); + log_debug("{}'s initial properties failed to load", connection->window_debug_string(window)); } } @@ -688,21 +678,14 @@ void mf::XWaylandWM::handle_property_notify(xcb_property_notify_event_t *event) { if (event->state == XCB_PROPERTY_DELETE) { - log_debug( - "XCB_PROPERTY_NOTIFY (%s).%s: deleted", - connection->window_debug_string(event->window).c_str(), - connection->query_name(event->atom).c_str()); + log_debug("XCB_PROPERTY_NOTIFY ({}).{}: deleted", connection->window_debug_string(event->window), connection->query_name(event->atom)); } else { auto const log_prop = [this, event](std::string const& value) { auto const prop_name = connection->query_name(event->atom); - log_debug( - "XCB_PROPERTY_NOTIFY (%s).%s: %s", - connection->window_debug_string(event->window).c_str(), - prop_name.c_str(), - value.c_str()); + log_debug("XCB_PROPERTY_NOTIFY ({}).{}: {}", connection->window_debug_string(event->window), prop_name, value); }; auto const reply_function = connection->read_property( @@ -746,14 +729,14 @@ void mf::XWaylandWM::handle_create_notify(xcb_create_notify_event_t *event) { if (verbose_xwayland_logging_enabled()) { - log_debug("XCB_CREATE_NOTIFY parent: %s", connection->window_debug_string(event->parent).c_str()); - log_debug(" window: %s", connection->window_debug_string(event->window).c_str()); - log_debug(" position: %d, %d", event->x, event->y); - log_debug(" size: %dx%d", event->width, event->height); - log_debug(" override_redirect: %s", event->override_redirect ? "yes" : "no"); + log_debug("XCB_CREATE_NOTIFY parent: {}", connection->window_debug_string(event->parent)); + log_debug(" window: {}", connection->window_debug_string(event->window)); + log_debug(" position: {}, {}", event->x, event->y); + log_debug(" size: {}x{}", event->width, event->height); + log_debug(" override_redirect: {}", event->override_redirect ? "yes" : "no"); if (event->border_width) - log_warning("border width unsupported (border width %d)", event->border_width); + log_warning("border width unsupported (border width {})", event->border_width); } if (!connection->is_ours(event->window)) @@ -769,11 +752,11 @@ void mf::XWaylandWM::handle_motion_notify(xcb_motion_notify_event_t *event) { if (verbose_xwayland_logging_enabled()) { - log_debug("XCB_MOTION_NOTIFY root: %s", connection->window_debug_string(event->root).c_str()); - log_debug(" event: %s", connection->window_debug_string(event->event).c_str()); - log_debug(" child: %s", connection->window_debug_string(event->child).c_str()); - log_debug(" root pos: %d, %d", event->root_x, event->root_y); - log_debug(" event pos: %d, %d", event->event_x, event->event_y); + log_debug("XCB_MOTION_NOTIFY root: {}", connection->window_debug_string(event->root)); + log_debug(" event: {}", connection->window_debug_string(event->event)); + log_debug(" child: {}", connection->window_debug_string(event->child)); + log_debug(" root pos: {}, {}", event->root_x, event->root_y); + log_debug(" event pos: {}, {}", event->event_x, event->event_y); } } @@ -781,10 +764,7 @@ void mf::XWaylandWM::handle_destroy_notify(xcb_destroy_notify_event_t *event) { if (verbose_xwayland_logging_enabled()) { - log_debug( - "XCB_DESTROY_NOTIFY window: %s, event: %s", - connection->window_debug_string(event->window).c_str(), - connection->window_debug_string(event->event).c_str()); + log_debug("XCB_DESTROY_NOTIFY window: {}, event: {}", connection->window_debug_string(event->window), connection->window_debug_string(event->event)); } std::shared_ptr surface{nullptr}; @@ -815,10 +795,7 @@ void mf::XWaylandWM::handle_map_request(xcb_map_request_event_t *event) { if (verbose_xwayland_logging_enabled()) { - log_debug( - "XCB_MAP_REQUEST %s with parent %s", - connection->window_debug_string(event->window).c_str(), - connection->window_debug_string(event->parent).c_str()); + log_debug("XCB_MAP_REQUEST {} with parent {}", connection->window_debug_string(event->window), connection->window_debug_string(event->parent)); } if (auto const surface = get_wm_surface(event->window)) @@ -831,10 +808,7 @@ void mf::XWaylandWM::handle_unmap_notify(xcb_unmap_notify_event_t *event) { if (verbose_xwayland_logging_enabled()) { - log_debug( - "XCB_UNMAP_NOTIFY %s with event %s", - connection->window_debug_string(event->window).c_str(), - connection->window_debug_string(event->event).c_str()); + log_debug("XCB_UNMAP_NOTIFY {} with event {}", connection->window_debug_string(event->window), connection->window_debug_string(event->event)); } if (connection->is_ours(event->window)) @@ -850,11 +824,7 @@ void mf::XWaylandWM::handle_client_message(xcb_client_message_event_t *event) { if (verbose_xwayland_logging_enabled()) { - log_debug( - "XCB_CLIENT_MESSAGE %s on %s: %s", - connection->query_name(event->type).c_str(), - connection->window_debug_string(event->window).c_str(), - connection->client_message_debug_string(event).c_str()); + log_debug("XCB_CLIENT_MESSAGE {} on {}: {}", connection->query_name(event->type), connection->window_debug_string(event->window), connection->client_message_debug_string(event)); } if (auto const surface = get_wm_surface(event->window)) @@ -909,9 +879,7 @@ void mf::XWaylandWM::handle_surface_id( { if (verbose_xwayland_logging_enabled()) { - log_debug( - "wl_surface@%u created but surface or shell has been destroyed", - wl_resource_get_id(wl_surface->resource)); + log_debug("wl_surface@{} created but surface or shell has been destroyed", wl_resource_get_id(wl_surface->resource)); } } }); @@ -922,14 +890,14 @@ void mf::XWaylandWM::handle_configure_request(xcb_configure_request_event_t *eve { if (verbose_xwayland_logging_enabled()) { - log_debug("XCB_CONFIGURE_REQUEST parent: %s", connection->window_debug_string(event->parent).c_str()); - log_debug(" window: %s", connection->window_debug_string(event->window).c_str()); - log_debug(" sibling: %s", connection->window_debug_string(event->sibling).c_str()); - log_debug(" position: %d, %d", event->x, event->y); - log_debug(" size: %dx%d", event->width, event->height); + log_debug("XCB_CONFIGURE_REQUEST parent: {}", connection->window_debug_string(event->parent)); + log_debug(" window: {}", connection->window_debug_string(event->window)); + log_debug(" sibling: {}", connection->window_debug_string(event->sibling)); + log_debug(" position: {}, {}", event->x, event->y); + log_debug(" size: {}x{}", event->width, event->height); if (event->border_width) - log_warning("border width unsupported (border width %d)", event->border_width); + log_warning("border width unsupported (border width {})", event->border_width); } if (auto const surface = get_wm_surface(event->window)) @@ -942,15 +910,15 @@ void mf::XWaylandWM::handle_configure_notify(xcb_configure_notify_event_t *event { if (verbose_xwayland_logging_enabled()) { - log_debug("XCB_CONFIGURE_NOTIFY event: %s", connection->window_debug_string(event->event).c_str()); - log_debug(" window: %s", connection->window_debug_string(event->window).c_str()); - log_debug(" above_sibling: %s", connection->window_debug_string(event->above_sibling).c_str()); - log_debug(" position: %d, %d", event->x, event->y); - log_debug(" size: %dx%d", event->width, event->height); - log_debug(" override_redirect: %s", event->override_redirect ? "yes" : "no"); + log_debug("XCB_CONFIGURE_NOTIFY event: {}", connection->window_debug_string(event->event)); + log_debug(" window: {}", connection->window_debug_string(event->window)); + log_debug(" above_sibling: {}", connection->window_debug_string(event->above_sibling)); + log_debug(" position: {}, {}", event->x, event->y); + log_debug(" size: {}x{}", event->width, event->height); + log_debug(" override_redirect: {}", event->override_redirect ? "yes" : "no"); if (event->border_width) - log_warning("border width unsupported (border width %d)", event->border_width); + log_warning("border width unsupported (border width {})", event->border_width); } if (auto const surface = get_wm_surface(event->window)) @@ -963,10 +931,7 @@ void mf::XWaylandWM::handle_focus_in(xcb_focus_in_event_t* event) { if (verbose_xwayland_logging_enabled()) { - log_debug( - "XCB_FOCUS_IN %s on %s", - focus_mode_to_string(event->mode).c_str(), - connection->window_debug_string(event->event).c_str()); + log_debug("XCB_FOCUS_IN {} on {}", focus_mode_to_string(event->mode), connection->window_debug_string(event->event)); } // Ignore grabs @@ -983,6 +948,6 @@ void mf::XWaylandWM::handle_error(xcb_generic_error_t* event) { if (verbose_xwayland_logging_enabled()) { - log_warning("XWayland XCB error: %s", connection->error_debug_string(event).c_str()); + log_warning("XWayland XCB error: {}", connection->error_debug_string(event)); } } diff --git a/src/server/glib_main_loop_sources.cpp b/src/server/glib_main_loop_sources.cpp index af1ac6e695c..1f51932f52b 100644 --- a/src/server/glib_main_loop_sources.cpp +++ b/src/server/glib_main_loop_sources.cpp @@ -573,7 +573,7 @@ void md::SignalSources::dispatch_pending_signal() auto const sig = read_pending_signal(); if (sig.sig != -1) { - mir::log_debug("Handling %s from pid=%d", strsignal(sig.sig), sig.pid); + mir::log_debug("Handling {} from pid={}", strsignal(sig.sig), sig.pid); dispatch_signal(sig.sig); } } diff --git a/src/server/graphics/default_configuration.cpp b/src/server/graphics/default_configuration.cpp index 5ee8ccac6aa..02ee0f1e1e6 100644 --- a/src/server/graphics/default_configuration.cpp +++ b/src/server/graphics/default_configuration.cpp @@ -158,7 +158,7 @@ auto mir::DefaultServerConfiguration::the_display_platforms() -> std::vectorname, description->major_version, description->minor_version, @@ -167,7 +167,7 @@ auto mir::DefaultServerConfiguration::the_display_platforms() -> std::vectorname, description->major_version, description->minor_version, @@ -257,7 +257,7 @@ auto mir::DefaultServerConfiguration::the_rendering_platforms() -> MIR_SERVER_GRAPHICS_PLATFORM_VERSION); auto const descriptor = describe_module(); - mir::log_warning("Manually-specified rendering platform %s does not claim to support this system. Trying anyway...", descriptor->name); + mir::log_warning("Manually-specified rendering platform {} does not claim to support this system. Trying anyway...", descriptor->name); } } } @@ -280,7 +280,7 @@ auto mir::DefaultServerConfiguration::the_rendering_platforms() -> if (!device.device) { mir::log_info( - "Selected rendering driver: %s (version %d.%d.%d) for platform", + "Selected rendering driver: {} (version {}.{}.{}) for platform", description->name, description->major_version, description->minor_version, @@ -289,7 +289,7 @@ auto mir::DefaultServerConfiguration::the_rendering_platforms() -> else { mir::log_info( - "Selected rendering driver: %s (version %d.%d.%d) for device (%s: %s)", + "Selected rendering driver: {} (version {}.{}.{}) for device ({}: {})", description->name, description->major_version, description->minor_version, diff --git a/src/server/graphics/platform_probe.cpp b/src/server/graphics/platform_probe.cpp index 4e730348311..d7d24152474 100644 --- a/src/server/graphics/platform_probe.cpp +++ b/src/server/graphics/platform_probe.cpp @@ -44,12 +44,13 @@ auto probe_module( MIR_SERVER_GRAPHICS_PLATFORM_VERSION); auto desc = describe(); - mir::log_info("Found %s driver: %s (version %d.%d.%d)", - platform_type_name, - desc->name, - desc->major_version, - desc->minor_version, - desc->micro_version); + mir::log_info( + "Found {} driver: {} (version {}.{}.{})", + platform_type_name, + desc->name, + desc->major_version, + desc->minor_version, + desc->micro_version); auto supported_devices = probe(); if (supported_devices.empty()) @@ -75,7 +76,7 @@ auto probe_module( return "System"; } }(); - mir::log_info("\t%s (priority %i)", device_name.c_str(), device.support_level); + mir::log_info("\t{} (priority {})", device_name, device.support_level); } } return supported_devices; @@ -503,7 +504,7 @@ auto mg::select_display_modules( MIR_SERVER_GRAPHICS_PLATFORM_VERSION); auto const descriptor = describe_module(); - mir::log_warning("Manually-specified display platform %s does not claim to support this system. Trying anyway...", descriptor->name); + mir::log_warning("Manually-specified display platform {} does not claim to support this system. Trying anyway...", descriptor->name); // We're here only if the platform doesn't claim to support *any* of the detected devices // Add *all* the found devices into our platform list, and hope. diff --git a/src/server/input/default_configuration.cpp b/src/server/input/default_configuration.cpp index 739d8468d93..8f945b186da 100644 --- a/src/server/input/default_configuration.cpp +++ b/src/server/input/default_configuration.cpp @@ -97,7 +97,7 @@ mir::DefaultServerConfiguration::the_event_filter_chain_dispatcher() mir::log( mir::logging::Severity::informational, "VT switch key handler", - "No VT switching support available: %s", + "No VT switching support available: {}", err.what()); return {}; } diff --git a/src/server/input/default_input_device_hub.cpp b/src/server/input/default_input_device_hub.cpp index be85cf24d7f..931d03c866e 100644 --- a/src/server/input/default_input_device_hub.cpp +++ b/src/server/input/default_input_device_hub.cpp @@ -190,7 +190,7 @@ void mi::ExternalInputDeviceHub::Internal::changes_complete() for (auto const& dev : added) { if (auto handle = std::dynamic_pointer_cast(dev)) - log_info(std::format("Device configuration: {}", handle)); + log_info("Device configuration: {}", handle); handles.push_back(dev); } }); @@ -505,7 +505,7 @@ auto mi::DefaultInputDeviceHub::add_device(std::shared_ptr const& d } else { - log_error("Input device %s added twice", device->get_device_info().name.c_str()); + log_error("Input device {} added twice", device->get_device_info().name); BOOST_THROW_EXCEPTION(std::logic_error("Input device already managed by server")); } } @@ -543,7 +543,7 @@ void mi::DefaultInputDeviceHub::remove_device(std::shared_ptr const }); if (!removed) { - log_error("Input device %s not found", device->get_device_info().name.c_str()); + log_error("Input device {} not found", device->get_device_info().name); BOOST_THROW_EXCEPTION(std::logic_error("Input device not managed by server")); } } diff --git a/src/server/input/input_probe.cpp b/src/server/input/input_probe.cpp index 6ad579b8a06..9df0d452712 100644 --- a/src/server/input/input_probe.cpp +++ b/src/server/input/input_probe.cpp @@ -44,8 +44,11 @@ mir::UniqueModulePtr create_input_platform( auto result = create(options, cleanup_registry, registry, console, report); mir::log_info( - "Selected input driver: %s (version: %d.%d.%d)", - desc->name, desc->major_version, desc->minor_version, desc->micro_version); + "Selected input driver: {} (version: {}.{}.{})", + desc->name, + desc->major_version, + desc->minor_version, + desc->micro_version); return result; } diff --git a/src/server/report/logging/display_configuration_report.cpp b/src/server/report/logging/display_configuration_report.cpp index 31887f7b976..bb39840f177 100644 --- a/src/server/report/logging/display_configuration_report.cpp +++ b/src/server/report/logging/display_configuration_report.cpp @@ -68,13 +68,13 @@ void mrl::DisplayConfigurationReport::base_configuration_updated( void mrl::DisplayConfigurationReport::session_configuration_applied(std::shared_ptr const& session, std::shared_ptr const& config) { - logger->log(component, severity, "Session %s applied display configuration", session->name().c_str()); + logger->log(component, severity, "Session {} applied display configuration", session->name()); log_configuration(severity, *config); } void mrl::DisplayConfigurationReport::session_configuration_removed(std::shared_ptr const& session) { - logger->log(component, severity, "Session %s removed display configuration", session->name().c_str()); + logger->log(component, severity, "Session {} removed display configuration", session->name()); } void mrl::DisplayConfigurationReport::configuration_failed( @@ -84,7 +84,7 @@ void mrl::DisplayConfigurationReport::configuration_failed( logger->log(component, ml::Severity::error, "Failed to apply display configuration:"); log_configuration(ml::Severity::error, *attempted); logger->log(component, ml::Severity::error, "Error details:"); - logger->log(component, ml::Severity::error, "%s", boost::diagnostic_information(error).c_str()); + logger->log(component, ml::Severity::error, "{}", boost::diagnostic_information(error)); } void mrl::DisplayConfigurationReport::log_configuration( @@ -98,7 +98,7 @@ void mrl::DisplayConfigurationReport::log_configuration( char const indent[] = ". |_ "; logger->log(component, severity, - "* Output %d: %s %s", + "* Output {}: {} {}", out_id, type, !out.connected ? "disconnected" : out.used ? "connected, used" : @@ -109,22 +109,22 @@ void mrl::DisplayConfigurationReport::log_configuration( if (out.display_info.model) { logger->log(component, severity, - "%sEDID monitor name: %s", indent, out.display_info.model->c_str()); + "{}EDID monitor name: {}", indent, *out.display_info.model); } if (out.display_info.vendor) { logger->log(component, severity, - "%sEDID manufacturer: %s", indent, out.display_info.vendor->c_str()); + "{}EDID manufacturer: {}", indent, *out.display_info.vendor); } if (out.display_info.product_code) { logger->log(component, severity, - "%sEDID product code: %hu", indent, *out.display_info.product_code); + "{}EDID product code: {}", indent, *out.display_info.product_code); } if (out.display_info.serial) { logger->log(component, severity, - "%sEDID serial number: %s", indent, out.display_info.serial->c_str()); + "{}EDID serial number: {}", indent, *out.display_info.serial); } int width_mm = out.physical_size_mm.width.as_int(); @@ -133,13 +133,13 @@ void mrl::DisplayConfigurationReport::log_configuration( sqrtf(width_mm * width_mm + height_mm * height_mm) / 25.4; logger->log(component, severity, - "%sPhysical size %.1f\" %dx%dmm", + "{}Physical size {:.1f}\" {}x{}mm", indent, inches, width_mm, height_mm); static const char* const power_mode[] = {"on", "in standby", "suspended", "off"}; logger->log(component, severity, - "%sPower is %s", indent, power_mode[out.power_mode]); + "{}Power is {}", indent, power_mode[out.power_mode]); if (out.used) { @@ -147,7 +147,7 @@ void mrl::DisplayConfigurationReport::log_configuration( { auto const& mode = out.modes[out.current_mode_index]; logger->log(component, severity, - "%sCurrent mode %dx%d %.2fHz", + "{}Current mode {}x{} {:.2f}Hz", indent, mode.size.width.as_int(), mode.size.height.as_int(), @@ -158,7 +158,7 @@ void mrl::DisplayConfigurationReport::log_configuration( { auto const& mode = out.modes[out.preferred_mode_index]; logger->log(component, severity, - "%sPreferred mode %dx%d %.2fHz", + "{}Preferred mode {}x{} {:.2f}Hz", indent, mode.size.width.as_int(), mode.size.height.as_int(), @@ -169,24 +169,24 @@ void mrl::DisplayConfigurationReport::log_configuration( {"normal", "left", "inverted", "right"}; int degrees_ccw = out.orientation; logger->log(component, severity, - "%sOrientation %s", + "{}Orientation {}", indent, orientation[degrees_ccw / 90]); logger->log(component, severity, - "%sLogical size %dx%d", + "{}Logical size {}x{}", indent, out.extents().size.width.as_int(), out.extents().size.height.as_int()); logger->log(component, severity, - "%sLogical position %+d%+d", + "{}Logical position {:+d}{:+d}", indent, out.top_left.x.as_int(), out.top_left.y.as_int()); logger->log(component, severity, - "%sScaling factor: %.2f", + "{}Scaling factor: {:.2f}", indent, out.scale); } @@ -202,12 +202,12 @@ void mrl::DisplayConfigurationReport::catastrophic_configuration_error( logger->log(component, ml::Severity::critical, "Attempted to fall back to configuration:"); log_configuration(ml::Severity::critical, *failed_fallback); logger->log(component, ml::Severity::critical, "Error details:"); - logger->log(component, ml::Severity::critical, "%s", boost::diagnostic_information(error).c_str()); + logger->log(component, ml::Severity::critical, "{}", boost::diagnostic_information(error)); } void mrl::DisplayConfigurationReport::configuration_updated_for_session( std::shared_ptr const& session, std::shared_ptr const& /*config*/) { - logger->log(component, severity, "Sending display configuration to session %s:", session->name().c_str()); + logger->log(component, severity, "Sending display configuration to session {}:", session->name()); } diff --git a/src/server/report/logging/display_report.cpp b/src/server/report/logging/display_report.cpp index 4bdb1c28cc1..1a7b72527d1 100644 --- a/src/server/report/logging/display_report.cpp +++ b/src/server/report/logging/display_report.cpp @@ -181,7 +181,7 @@ void mrl::DisplayReport::report_vsync(unsigned int output_id, hz100 = 100000000LL / interval_us; logger->log(component(), ml::Severity::informational, - "vsync on %u: #%lld, %lld.%03lldms %s, interval %lld.%03lldms (%lld.%02lldHz)", + "vsync on {}: #{}, {}.{:03}ms {}, interval {}.{:03}ms ({}.{:02}Hz)", output_id, msc, llabs(age_us/1000), llabs(age_us%1000), diff --git a/src/server/shell/decoration/decoration_strategy.cpp b/src/server/shell/decoration/decoration_strategy.cpp index 3df430aabf1..b19bf067e86 100644 --- a/src/server/shell/decoration/decoration_strategy.cpp +++ b/src/server/shell/decoration/decoration_strategy.cpp @@ -459,7 +459,7 @@ auto RendererStrategy::Text::instance() -> std::shared_ptr } catch (std::runtime_error const& error) { - mir::log_warning("%s", error.what()); + mir::log_warning("{}", error.what()); shared = std::make_shared(); } singleton = shared; @@ -488,11 +488,11 @@ RendererStrategy::Text::Impl::Impl() RendererStrategy::Text::Impl::~Impl() { if (auto const error = FT_Done_Face(face)) - mir::log_warning("Failed to uninitialize font face with error %d", error); + mir::log_warning("Failed to uninitialize font face with error {}", error); face = nullptr; if (auto const error = FT_Done_FreeType(library)) - mir::log_warning("Failed to uninitialize FreeType with error %d", error); + mir::log_warning("Failed to uninitialize FreeType with error {}", error); library = nullptr; } @@ -521,7 +521,7 @@ void RendererStrategy::Text::Impl::render( } catch (std::runtime_error const& error) { - mir::log_warning("%s", error.what()); + mir::log_warning("{}", error.what()); return; } @@ -546,7 +546,7 @@ void RendererStrategy::Text::Impl::render( } catch (std::runtime_error const& error) { - mir::log_warning("%s", error.what()); + mir::log_warning("{}", error.what()); } } } @@ -653,7 +653,7 @@ auto RendererStrategy::Text::Impl::utf8_to_utf32(std::string const& text) -> std try { utf32_text = converter.from_bytes(text); } catch(const std::range_error& e) { - mir::log_warning("Window title %s is not valid UTF-8", text.c_str()); + mir::log_warning("Window title {} is not valid UTF-8", text); // fall back to ASCII for (char const c : text) { @@ -906,7 +906,8 @@ void RendererStrategy::redraw_titlebar_buttons(geom::Size const scaled_titlebar_ } else { - mir::log_warning("Could not render decoration button with unknown function %d\n", static_cast(button.function)); + mir::log_warning( + "Could not render decoration button with unknown function {}\n", static_cast(button.function)); } } } @@ -937,7 +938,8 @@ auto RendererStrategy::make_buffer(MirPixelFormat format, mir::geometry::Size si if (sizeof(Pixel) != MIR_BYTES_PER_PIXEL(buffer_format)) { - mir::log_warning("Failed to draw SSD: tried to create buffer with unsupported format: %d", buffer_format); + mir::log_warning( + "Failed to draw SSD: tried to create buffer with unsupported format: {}", static_cast(buffer_format)); return std::nullopt; } diff --git a/src/wayland/protocol_error.cpp b/src/wayland/protocol_error.cpp index ad9349759a8..58a46fdeb39 100644 --- a/src/wayland/protocol_error.cpp +++ b/src/wayland/protocol_error.cpp @@ -78,7 +78,7 @@ void mw::tried_to_send_unsupported_event(wl_client* client, wl_resource* resourc required_version); log_critical( - "Tried to send %s@%u.%s to object with version %d (requires version %d)", + "Tried to send {}@{}.{} to object with version {} (requires version {})", wl_resource_get_class(resource), wl_resource_get_id(resource), event, diff --git a/tests/mir_test_framework/test_wlcs_display_server.cpp b/tests/mir_test_framework/test_wlcs_display_server.cpp index cec3bc799ba..0c7a32ac184 100644 --- a/tests/mir_test_framework/test_wlcs_display_server.cpp +++ b/tests/mir_test_framework/test_wlcs_display_server.cpp @@ -275,7 +275,7 @@ class WaylandExecutor : public mir::Executor mir::log( mir::logging::Severity::error, "wlcs-integration", - "eventfd_read failed to consume wakeup notification: %s (%i)", + "eventfd_read failed to consume wakeup notification: {} ({})", mir::errno_to_cstr(err), err); }