Browse Source

Everywhere: Convert a bunch of dbgprintf() to dbgln()

Andreas Kling 4 years ago
parent
commit
f35a723f61

+ 1 - 1
Libraries/LibCore/Object.cpp

@@ -150,7 +150,7 @@ void Object::custom_event(CustomEvent&)
 void Object::start_timer(int ms, TimerShouldFireWhenNotVisible fire_when_not_visible)
 {
     if (m_timer_id) {
-        dbgprintf("Object{%p} already has a timer!\n", this);
+        dbgln("{} {:p} already has a timer!", class_name(), this);
         ASSERT_NOT_REACHED();
     }
 

+ 3 - 3
Libraries/LibGUI/Clipboard.cpp

@@ -83,11 +83,11 @@ Clipboard::DataAndType Clipboard::data_and_type() const
         return {};
     auto shared_buffer = SharedBuffer::create_from_shbuf_id(response->shbuf_id());
     if (!shared_buffer) {
-        dbgprintf("GUI::Clipboard::data() failed to attach to the shared buffer\n");
+        dbgln("GUI::Clipboard::data() failed to attach to the shared buffer");
         return {};
     }
     if (response->data_size() > shared_buffer->size()) {
-        dbgprintf("GUI::Clipboard::data() clipping contents size is greater than shared buffer size\n");
+        dbgln("GUI::Clipboard::data() clipping contents size is greater than shared buffer size");
         return {};
     }
     auto data = ByteBuffer::copy(shared_buffer->data<void>(), response->data_size());
@@ -100,7 +100,7 @@ void Clipboard::set_data(ReadonlyBytes data, const String& type, const HashMap<S
 {
     auto shared_buffer = SharedBuffer::create_with_size(data.size());
     if (!shared_buffer) {
-        dbgprintf("GUI::Clipboard::set_data() failed to create a shared buffer\n");
+        dbgln("GUI::Clipboard::set_data() failed to create a shared buffer");
         return;
     }
     if (!data.is_empty())

+ 1 - 1
Libraries/LibGUI/DragOperation.cpp

@@ -77,7 +77,7 @@ DragOperation::Outcome DragOperation::exec()
     m_event_loop = make<Core::EventLoop>();
     auto result = m_event_loop->exec();
     m_event_loop = nullptr;
-    dbgprintf("%s: event loop returned with result %d\n", class_name(), result);
+    dbgln("{}: event loop returned with result {}", class_name(), result);
     remove_from_parent();
     s_current_drag_operation = nullptr;
     return m_outcome;

+ 2 - 2
Libraries/LibGUI/InputBox.cpp

@@ -96,7 +96,7 @@ void InputBox::build()
     m_ok_button->set_fixed_height(20);
     m_ok_button->set_text("OK");
     m_ok_button->on_click = [this](auto) {
-        dbgprintf("GUI::InputBox: OK button clicked\n");
+        dbgln("GUI::InputBox: OK button clicked");
         m_text_value = m_text_editor->text();
         done(ExecOK);
     };
@@ -105,7 +105,7 @@ void InputBox::build()
     m_cancel_button->set_fixed_height(20);
     m_cancel_button->set_text("Cancel");
     m_cancel_button->on_click = [this](auto) {
-        dbgprintf("GUI::InputBox: Cancel button clicked\n");
+        dbgln("GUI::InputBox: Cancel button clicked");
         done(ExecCancel);
     };
 

+ 2 - 2
Libraries/LibGUI/Menu.cpp

@@ -72,7 +72,7 @@ void Menu::add_action(NonnullRefPtr<Action> action)
 {
     m_items.append(make<MenuItem>(m_menu_id, move(action)));
 #ifdef GMENU_DEBUG
-    dbgprintf("GUI::Menu::add_action(): MenuItem Menu ID: %d\n", m_menu_id);
+    dbgln("GUI::Menu::add_action(): MenuItem Menu ID: {}", m_menu_id);
 #endif
 }
 
@@ -134,7 +134,7 @@ int Menu::realize_menu(RefPtr<Action> default_action)
     m_menu_id = WindowServerConnection::the().send_sync<Messages::WindowServer::CreateMenu>(m_name)->menu_id();
 
 #ifdef MENU_DEBUG
-    dbgprintf("GUI::Menu::realize_menu(): New menu ID: %d\n", m_menu_id);
+    dbgln("GUI::Menu::realize_menu(): New menu ID: {}", m_menu_id);
 #endif
     ASSERT(m_menu_id > 0);
     for (size_t i = 0; i < m_items.size(); ++i) {

+ 1 - 1
Libraries/LibGUI/Window.cpp

@@ -534,7 +534,7 @@ void Window::update(const Gfx::IntRect& a_rect)
     for (auto& pending_rect : m_pending_paint_event_rects) {
         if (pending_rect.contains(a_rect)) {
 #ifdef UPDATE_COALESCING_DEBUG
-            dbgprintf("Ignoring %s since it's contained by pending rect %s\n", a_rect.to_string().characters(), pending_rect.to_string().characters());
+            dbgln("Ignoring {} since it's contained by pending rect {}", a_rect, pending_rect);
 #endif
             return;
         }

+ 3 - 3
Libraries/LibGfx/BitmapFont.cpp

@@ -129,16 +129,16 @@ RefPtr<BitmapFont> BitmapFont::load_from_memory(const u8* data)
 {
     auto& header = *reinterpret_cast<const FontFileHeader*>(data);
     if (memcmp(header.magic, "!Fnt", 4)) {
-        dbgprintf("header.magic != '!Fnt', instead it's '%c%c%c%c'\n", header.magic[0], header.magic[1], header.magic[2], header.magic[3]);
+        dbgln("header.magic != '!Fnt', instead it's '{:c}{:c}{:c}{:c}'", header.magic[0], header.magic[1], header.magic[2], header.magic[3]);
         return nullptr;
     }
     if (header.name[sizeof(header.name) - 1] != '\0') {
-        dbgprintf("Font name not fully null-terminated\n");
+        dbgln("Font name not fully null-terminated");
         return nullptr;
     }
 
     if (header.family[sizeof(header.family) - 1] != '\0') {
-        dbgprintf("Font family not fully null-terminated\n");
+        dbgln("Font family not fully null-terminated");
         return nullptr;
     }
 

+ 1 - 1
Libraries/LibGfx/PNGLoader.cpp

@@ -888,7 +888,7 @@ static bool process_IHDR(ReadonlyBytes data, PNGLoadingContext& context)
 
     if (context.interlace_method != PngInterlaceMethod::Null && context.interlace_method != PngInterlaceMethod::Adam7) {
 #ifdef PNG_DEBUG
-        dbgprintf("PNGLoader::process_IHDR: unknown interlace method: %d\n", context.interlace_method);
+        dbgln("PNGLoader::process_IHDR: unknown interlace method: {}", context.interlace_method);
 #endif
         return false;
     }

+ 3 - 3
Libraries/LibLine/Editor.cpp

@@ -736,7 +736,7 @@ void Editor::handle_read_event()
         case InputState::CSIExpectFinal: {
             m_state = InputState::Free;
             if (!(code_point >= 0x40 && code_point <= 0x7f)) {
-                dbgprintf("LibLine: Invalid CSI: %02x (%c)\r\n", code_point, code_point);
+                dbgln("LibLine: Invalid CSI: {:02x} ({:c})", code_point, code_point);
                 continue;
             }
             csi_final = code_point;
@@ -797,10 +797,10 @@ void Editor::handle_read_event()
                 }
                 // ^[[5~: page up
                 // ^[[6~: page down
-                dbgprintf("LibLine: Unhandled '~': %d\r\n", param1);
+                dbgln("LibLine: Unhandled '~': {}", param1);
                 continue;
             default:
-                dbgprintf("LibLine: Unhandled final: %02x (%c)\r\n", code_point, code_point);
+                dbgln("LibLine: Unhandled final: {:02x} ({:c})", code_point, code_point);
                 continue;
             }
             break;

+ 1 - 1
Services/AudioServer/Mixer.cpp

@@ -44,7 +44,7 @@ Mixer::Mixer()
           "AudioServer[mixer]"))
 {
     if (!m_device->open(Core::IODevice::WriteOnly)) {
-        dbgprintf("Can't open audio device: %s\n", m_device->error_string());
+        dbgln("Can't open audio device: {}", m_device->error_string());
         return;
     }
 

+ 1 - 1
Services/SystemServer/Service.cpp

@@ -211,7 +211,7 @@ void Service::spawn(int socket_fd)
         if (m_account.has_value()) {
             auto& account = m_account.value();
             if (setgid(account.gid()) < 0 || setgroups(account.extra_gids().size(), account.extra_gids().data()) < 0 || setuid(account.uid()) < 0) {
-                dbgprintf("Failed to drop privileges (GID=%u, UID=%u)\n", account.gid(), account.uid());
+                dbgln("Failed to drop privileges (GID={}, UID={})\n", account.gid(), account.uid());
                 exit(1);
             }
             setenv("HOME", account.home_directory().characters(), true);

+ 7 - 7
Services/Taskbar/TaskbarWindow.cpp

@@ -233,7 +233,7 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
     case GUI::Event::WM_WindowRemoved: {
 #ifdef EVENT_DEBUG
         auto& removed_event = static_cast<GUI::WMWindowRemovedEvent&>(event);
-        dbgprintf("WM_WindowRemoved: client_id=%d, window_id=%d\n",
+        dbgln("WM_WindowRemoved: client_id={}, window_id={}",
             removed_event.client_id(),
             removed_event.window_id());
 #endif
@@ -246,10 +246,10 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
     case GUI::Event::WM_WindowRectChanged: {
 #ifdef EVENT_DEBUG
         auto& changed_event = static_cast<GUI::WMWindowRectChangedEvent&>(event);
-        dbgprintf("WM_WindowRectChanged: client_id=%d, window_id=%d, rect=%s\n",
+        dbgln("WM_WindowRectChanged: client_id={}, window_id={}, rect={}",
             changed_event.client_id(),
             changed_event.window_id(),
-            changed_event.rect().to_string().characters());
+            changed_event.rect());
 #endif
         break;
     }
@@ -257,7 +257,7 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
     case GUI::Event::WM_WindowIconBitmapChanged: {
         auto& changed_event = static_cast<GUI::WMWindowIconBitmapChangedEvent&>(event);
 #ifdef EVENT_DEBUG
-        dbgprintf("WM_WindowIconBitmapChanged: client_id=%d, window_id=%d, icon_buffer_id=%d\n",
+        dbgln("WM_WindowIconBitmapChanged: client_id={}, window_id={}, icon_buffer_id={}",
             changed_event.client_id(),
             changed_event.window_id(),
             changed_event.icon_buffer_id());
@@ -274,11 +274,11 @@ void TaskbarWindow::wm_event(GUI::WMEvent& event)
     case GUI::Event::WM_WindowStateChanged: {
         auto& changed_event = static_cast<GUI::WMWindowStateChangedEvent&>(event);
 #ifdef EVENT_DEBUG
-        dbgprintf("WM_WindowStateChanged: client_id=%d, window_id=%d, title=%s, rect=%s, is_active=%u, is_minimized=%u\n",
+        dbgln("WM_WindowStateChanged: client_id={}, window_id={}, title={}, rect={}, is_active={}, is_minimized={}",
             changed_event.client_id(),
             changed_event.window_id(),
-            changed_event.title().characters(),
-            changed_event.rect().to_string().characters(),
+            changed_event.title(),
+            changed_event.rect(),
             changed_event.is_active(),
             changed_event.is_minimized());
 #endif

+ 2 - 2
Services/WindowServer/EventLoop.cpp

@@ -99,7 +99,7 @@ void EventLoop::drain_mouse()
     for (size_t i = 0; i < npackets; ++i) {
         auto& packet = packets[i];
 #ifdef WSMESSAGELOOP_DEBUG
-        dbgprintf("EventLoop: Mouse X %d, Y %d, Z %d, relative %d\n", packet.x, packet.y, packet.z, packet.is_relative);
+        dbgln("EventLoop: Mouse X {}, Y {}, Z {}, relative={}", packet.x, packet.y, packet.z, packet.is_relative);
 #endif
         buttons = packet.buttons;
 
@@ -117,7 +117,7 @@ void EventLoop::drain_mouse()
         if (buttons != state.buttons) {
             state.buttons = buttons;
 #ifdef WSMESSAGELOOP_DEBUG
-            dbgprintf("EventLoop: Mouse Button Event\n");
+            dbgln("EventLoop: Mouse Button Event");
 #endif
             screen.on_receive_mouse_data(state);
             if (state.is_relative) {

+ 2 - 2
Services/WindowServer/Screen.cpp

@@ -134,12 +134,12 @@ void Screen::on_receive_mouse_data(const MousePacket& packet)
     if (packet.is_relative) {
         m_cursor_location.move_by(packet.x * m_acceleration_factor, packet.y * m_acceleration_factor);
 #ifdef WSSCREEN_DEBUG
-        dbgprintf("Screen: New Relative mouse point @ X %d, Y %d\n", m_cursor_location.x(), m_cursor_location.y());
+        dbgln("Screen: New Relative mouse point @ {}", m_cursor_location);
 #endif
     } else {
         m_cursor_location = { packet.x * m_width / 0xffff, packet.y * m_height / 0xffff };
 #ifdef WSSCREEN_DEBUG
-        dbgprintf("Screen: New Absolute mouse point @ X %d, Y %d\n", m_cursor_location.x(), m_cursor_location.y());
+        dbgln("Screen: New Absolute mouse point @ {}", m_cursor_location);
 #endif
     }
 

+ 1 - 1
Userland/crash.cpp

@@ -256,7 +256,7 @@ int main(int argc, char** argv)
             u8* makeshift_esp = makeshift_stack + 2048;
             asm volatile("mov %%eax, %%esp" ::"a"(makeshift_esp));
             getuid();
-            dbgprintf("Survived syscall with MAP_STACK stack\n");
+            dbgln("Survived syscall with MAP_STACK stack");
 
             u8* bad_stack = (u8*)mmap(nullptr, PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_ANONYMOUS | MAP_PRIVATE, 0, 0);
             if (!bad_stack)

+ 1 - 1
Userland/pro.cpp

@@ -288,7 +288,7 @@ int main(int argc, char** argv)
     auto output_stream = ConditionalOutputFileStream { [&] { return save_at_provided_name ? received_actual_headers : true; }, stdout };
     download->stream_into(output_stream);
 
-    dbgprintf("started download with id %d\n", download->id());
+    dbgln("started download with id {}", download->id());
 
     auto rc = loop.exec();
     // FIXME: This shouldn't be needed.