Skip to content

Commit 3f23a58

Browse files
asyntsawesomekling
authored andcommitted
Everywhere: Replace a bundle of dbg with dbgln.
These changes are arbitrarily divided into multiple commits to make it easier to find potentially introduced bugs with git bisect.
1 parent 7d783d8 commit 3f23a58

File tree

9 files changed

+97
-70
lines changed

9 files changed

+97
-70
lines changed

AK/Debug.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,3 +442,32 @@ constexpr bool debug_trace_tokenizer = true;
442442
constexpr bool debug_trace_tokenizer = false;
443443
#endif
444444

445+
#ifdef IMAGE_LOADER_DEBUG
446+
constexpr bool debug_image_loader = true;
447+
#else
448+
constexpr bool debug_image_loader = false;
449+
#endif
450+
451+
#ifdef RESOURCE_DEBUG
452+
constexpr bool debug_resource = true;
453+
#else
454+
constexpr bool debug_resource = false;
455+
#endif
456+
457+
#ifdef CACHE_DEBUG
458+
constexpr bool debug_cache = true;
459+
#else
460+
constexpr bool debug_cache = false;
461+
#endif
462+
463+
#ifdef DHCPV4_DEBUG
464+
constexpr bool debug_dhcpv4 = true;
465+
#else
466+
constexpr bool debug_dhcpv4 = false;
467+
#endif
468+
469+
#ifdef DHCPV4CLIENT_DEBUG
470+
constexpr bool debug_dhcpv4_client = true;
471+
#else
472+
constexpr bool debug_dhcpv4_client = false;
473+
#endif

Userland/Libraries/LibWeb/Loader/FrameLoader.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27+
#include <AK/Debug.h>
2728
#include <AK/LexicalPath.h>
2829
#include <LibGemini/Document.h>
2930
#include <LibGfx/ImageDecoder.h>
@@ -39,8 +40,6 @@
3940
#include <LibWeb/Page/Frame.h>
4041
#include <LibWeb/Page/Page.h>
4142

42-
//#define GEMINI_DEBUG 1
43-
4443
namespace Web {
4544

4645
FrameLoader::FrameLoader(Frame& frame)
@@ -180,14 +179,14 @@ bool FrameLoader::load(const LoadRequest& request, Type type)
180179
ResourceLoader::the().load(
181180
favicon_url,
182181
[this, favicon_url](auto data, auto&) {
183-
dbg() << "Favicon downloaded, " << data.size() << " bytes from " << favicon_url;
182+
dbgln("Favicon downloaded, {} bytes from {}", data.size(), favicon_url);
184183
auto decoder = Gfx::ImageDecoder::create(data.data(), data.size());
185184
auto bitmap = decoder->bitmap();
186185
if (!bitmap) {
187-
dbg() << "Could not decode favicon " << favicon_url;
186+
dbgln("Could not decode favicon {}", favicon_url);
188187
return;
189188
}
190-
dbg() << "Decoded favicon, " << bitmap->size();
189+
dbgln("Decoded favicon, {}", bitmap->size());
191190
if (auto* page = frame().page())
192191
page->client().page_did_change_favicon(*bitmap);
193192
});
@@ -198,7 +197,7 @@ bool FrameLoader::load(const LoadRequest& request, Type type)
198197

199198
bool FrameLoader::load(const URL& url, Type type)
200199
{
201-
dbg() << "FrameLoader::load: " << url;
200+
dbgln("FrameLoader::load: {}", url);
202201

203202
if (!url.is_valid()) {
204203
load_error_page(url, "Invalid URL");
@@ -240,7 +239,7 @@ void FrameLoader::load_error_page(const URL& failed_url, const String& error)
240239
frame().set_document(document);
241240
},
242241
[](auto error) {
243-
dbg() << "Failed to load error page: " << error;
242+
dbgln("Failed to load error page: {}", error);
244243
ASSERT_NOT_REACHED();
245244
});
246245
}

Userland/Libraries/LibWeb/Loader/ImageLoader.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27+
#include <AK/Debug.h>
2728
#include <LibCore/Timer.h>
2829
#include <LibGfx/Bitmap.h>
2930
#include <LibGfx/ImageDecoder.h>
@@ -71,13 +72,13 @@ void ImageLoader::resource_did_load()
7172

7273
m_loading_state = LoadingState::Loaded;
7374

74-
#ifdef IMAGE_LOADER_DEBUG
75-
if (!resource()->has_encoded_data()) {
76-
dbg() << "ImageLoader: Resource did load, no encoded data. URL: " << resource()->url();
77-
} else {
78-
dbg() << "ImageLoader: Resource did load, has encoded data. URL: " << resource()->url();
75+
if constexpr (debug_image_loader) {
76+
if (!resource()->has_encoded_data()) {
77+
dbgln("ImageLoader: Resource did load, no encoded data. URL: {}", resource()->url());
78+
} else {
79+
dbgln("ImageLoader: Resource did load, has encoded data. URL: {}", resource()->url());
80+
}
7981
}
80-
#endif
8182

8283
if (resource()->should_decode_in_process()) {
8384
auto& decoder = resource()->ensure_decoder();
@@ -121,7 +122,7 @@ void ImageLoader::animate()
121122

122123
void ImageLoader::resource_did_fail()
123124
{
124-
dbg() << "ImageLoader: Resource did fail. URL: " << resource()->url();
125+
dbgln("ImageLoader: Resource did fail. URL: {}", resource()->url());
125126
m_loading_state = LoadingState::Failed;
126127
if (on_fail)
127128
on_fail();

Userland/Libraries/LibWeb/Loader/Resource.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27+
#include <AK/Debug.h>
2728
#include <AK/Function.h>
2829
#include <LibCore/MimeData.h>
2930
#include <LibWeb/HTML/HTMLImageElement.h>
@@ -99,9 +100,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap
99100
m_encoding = encoding_from_content_type(content_type.value());
100101
m_mime_type = mime_type_from_content_type(content_type.value());
101102
} else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
102-
#ifdef RESOURCE_DEBUG
103-
dbg() << "This is a data URL with mime-type _" << url().data_mime_type() << "_";
104-
#endif
103+
dbgln<debug_resource>("This is a data URL with mime-type _{}_", url().data_mime_type());
105104
m_encoding = "utf-8"; // FIXME: This doesn't seem nice.
106105
m_mime_type = url().data_mime_type();
107106
} else {

Userland/Libraries/LibWeb/Loader/ResourceLoader.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
*/
2626

2727
#include <AK/Base64.h>
28+
#include <AK/Debug.h>
2829
#include <AK/JsonObject.h>
2930
#include <LibCore/EventLoop.h>
3031
#include <LibCore/File.h>
@@ -35,8 +36,6 @@
3536
#include <LibWeb/Loader/Resource.h>
3637
#include <LibWeb/Loader/ResourceLoader.h>
3738

38-
//#define CACHE_DEBUG
39-
4039
namespace Web {
4140

4241
ResourceLoader& ResourceLoader::the()
@@ -82,11 +81,9 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, const LoadRe
8281
auto it = s_resource_cache.find(request);
8382
if (it != s_resource_cache.end()) {
8483
if (it->value->type() != type) {
85-
dbg() << "FIXME: Not using cached resource for " << request.url() << " since there's a type mismatch.";
84+
dbgln("FIXME: Not using cached resource for {} since there's a type mismatch.", request.url());
8685
} else {
87-
#ifdef CACHE_DEBUG
88-
dbg() << "Reusing cached resource for: " << request.url();
89-
#endif
86+
dbgln<debug_cache>("Reusing cached resource for: {}", request.url());
9087
return it->value;
9188
}
9289
}
@@ -112,7 +109,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
112109
auto& url = request.url();
113110

114111
if (is_port_blocked(url.port())) {
115-
dbg() << "ResourceLoader::load: Error: blocked port " << url.port() << " for URL: " << url;
112+
dbgln("ResourceLoader::load: Error: blocked port {} from URL {}", url.port(), url);
116113
return;
117114
}
118115

@@ -123,15 +120,18 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
123120
}
124121

125122
if (url.protocol() == "about") {
126-
dbg() << "Loading about: URL " << url;
123+
dbgln("Loading about: URL {}", url);
127124
deferred_invoke([success_callback = move(success_callback)](auto&) {
128125
success_callback(String::empty().to_byte_buffer(), {});
129126
});
130127
return;
131128
}
132129

133130
if (url.protocol() == "data") {
134-
dbg() << "ResourceLoader loading a data URL with mime-type: '" << url.data_mime_type() << "', base64=" << url.data_payload_is_base64() << ", payload='" << url.data_payload() << "'";
131+
dbgln("ResourceLoader loading a data URL with mime-type: '{}', base64={}, payload='{}'",
132+
url.data_mime_type(),
133+
url.data_payload_is_base64(),
134+
url.data_payload());
135135

136136
ByteBuffer data;
137137
if (url.data_payload_is_base64())
@@ -149,7 +149,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
149149
auto f = Core::File::construct();
150150
f->set_filename(url.path());
151151
if (!f->open(Core::IODevice::OpenMode::ReadOnly)) {
152-
dbg() << "ResourceLoader::load: Error: " << f->error_string();
152+
dbgln("ResourceLoader::load: Error: {}", f->error_string());
153153
if (error_callback)
154154
error_callback(f->error_string());
155155
return;

Userland/Libraries/LibWeb/SVG/SVGPathElement.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2525
*/
2626

27+
#include <AK/Debug.h>
2728
#include <AK/StringBuilder.h>
2829
#include <LibGfx/Painter.h>
2930
#include <LibGfx/Path.h>
@@ -33,8 +34,6 @@
3334
#include <LibWeb/SVG/SVGPathElement.h>
3435
#include <ctype.h>
3536

36-
//#define PATH_DEBUG
37-
3837
namespace Web::SVG {
3938

4039
#ifdef PATH_DEBUG
@@ -136,7 +135,7 @@ void PathDataParser::parse_drawto()
136135
} else if (match('A') || match('a')) {
137136
parse_elliptical_arc();
138137
} else {
139-
dbg() << "PathDataParser::parse_drawto failed to match: '" << ch() << "'";
138+
dbgln("PathDataParser::parse_drawto failed to match: '{}'", ch());
140139
TODO();
141140
}
142141
}

Userland/Services/ChessEngine/ChessEngine.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
#include "ChessEngine.h"
2828
#include "MCTSTree.h"
29+
#include <AK/Debug.h>
2930
#include <LibCore/ElapsedTimer.h>
3031

3132
using namespace Chess::UCI;
@@ -68,9 +69,9 @@ void ChessEngine::handle_go(const GoCommand& command)
6869
mcts.do_round();
6970
++rounds;
7071
}
71-
dbg() << "MCTS finished " << rounds << " rounds.";
72-
dbg() << "MCTS evaluation " << mcts.expected_value();
72+
dbgln("MCTS finished {} rounds.", rounds);
73+
dbgln("MCTS evaluation {}", mcts.expected_value());
7374
auto best_move = mcts.best_move();
74-
dbg() << "MCTS best move " << best_move.to_long_algebraic();
75+
dbgln("MCTS best move {}", best_move.to_long_algebraic());
7576
send_command(BestMoveCommand(best_move));
7677
}

Userland/Services/DHCPClient/DHCPv4.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@
2525
*/
2626

2727
#include "DHCPv4.h"
28-
29-
//#define DHCPV4_DEBUG
28+
#include <AK/Debug.h>
3029

3130
ParsedDHCPv4Options DHCPv4Packet::parse_options() const
3231
{
@@ -42,12 +41,10 @@ ParsedDHCPv4Options DHCPv4Packet::parse_options() const
4241
++index;
4342
auto length = m_options[index];
4443
if ((size_t)length > DHCPV4_OPTION_FIELD_MAX_LENGTH - index) {
45-
dbg() << "Bogus option length " << length << " assuming forgotten END";
44+
dbgln("Bogus option length {} assuming forgotten END", length);
4645
break;
4746
}
48-
#ifdef DHCPV4_DEBUG
49-
dbg() << "DHCP Option " << (u8)opt_name << " with length " << length;
50-
#endif
47+
dbgln<debug_dhcpv4>("DHCP Option {} with length {}", (u8)opt_name, length);
5148
++index;
5249
options.options.set(opt_name, { length, &m_options[index] });
5350
index += length - 1;

0 commit comments

Comments
 (0)