1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

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.
This commit is contained in:
asynts 2021-01-17 18:17:00 +01:00 committed by Andreas Kling
parent 7d783d8b84
commit 3f23a58fa1
9 changed files with 97 additions and 70 deletions

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <AK/LexicalPath.h>
#include <LibGemini/Document.h>
#include <LibGfx/ImageDecoder.h>
@ -39,8 +40,6 @@
#include <LibWeb/Page/Frame.h>
#include <LibWeb/Page/Page.h>
//#define GEMINI_DEBUG 1
namespace Web {
FrameLoader::FrameLoader(Frame& frame)
@ -180,14 +179,14 @@ bool FrameLoader::load(const LoadRequest& request, Type type)
ResourceLoader::the().load(
favicon_url,
[this, favicon_url](auto data, auto&) {
dbg() << "Favicon downloaded, " << data.size() << " bytes from " << favicon_url;
dbgln("Favicon downloaded, {} bytes from {}", data.size(), favicon_url);
auto decoder = Gfx::ImageDecoder::create(data.data(), data.size());
auto bitmap = decoder->bitmap();
if (!bitmap) {
dbg() << "Could not decode favicon " << favicon_url;
dbgln("Could not decode favicon {}", favicon_url);
return;
}
dbg() << "Decoded favicon, " << bitmap->size();
dbgln("Decoded favicon, {}", bitmap->size());
if (auto* page = frame().page())
page->client().page_did_change_favicon(*bitmap);
});
@ -198,7 +197,7 @@ bool FrameLoader::load(const LoadRequest& request, Type type)
bool FrameLoader::load(const URL& url, Type type)
{
dbg() << "FrameLoader::load: " << url;
dbgln("FrameLoader::load: {}", url);
if (!url.is_valid()) {
load_error_page(url, "Invalid URL");
@ -240,7 +239,7 @@ void FrameLoader::load_error_page(const URL& failed_url, const String& error)
frame().set_document(document);
},
[](auto error) {
dbg() << "Failed to load error page: " << error;
dbgln("Failed to load error page: {}", error);
ASSERT_NOT_REACHED();
});
}

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <LibCore/Timer.h>
#include <LibGfx/Bitmap.h>
#include <LibGfx/ImageDecoder.h>
@ -71,13 +72,13 @@ void ImageLoader::resource_did_load()
m_loading_state = LoadingState::Loaded;
#ifdef IMAGE_LOADER_DEBUG
if (!resource()->has_encoded_data()) {
dbg() << "ImageLoader: Resource did load, no encoded data. URL: " << resource()->url();
} else {
dbg() << "ImageLoader: Resource did load, has encoded data. URL: " << resource()->url();
if constexpr (debug_image_loader) {
if (!resource()->has_encoded_data()) {
dbgln("ImageLoader: Resource did load, no encoded data. URL: {}", resource()->url());
} else {
dbgln("ImageLoader: Resource did load, has encoded data. URL: {}", resource()->url());
}
}
#endif
if (resource()->should_decode_in_process()) {
auto& decoder = resource()->ensure_decoder();
@ -121,7 +122,7 @@ void ImageLoader::animate()
void ImageLoader::resource_did_fail()
{
dbg() << "ImageLoader: Resource did fail. URL: " << resource()->url();
dbgln("ImageLoader: Resource did fail. URL: {}", resource()->url());
m_loading_state = LoadingState::Failed;
if (on_fail)
on_fail();

View file

@ -24,6 +24,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <AK/Function.h>
#include <LibCore/MimeData.h>
#include <LibWeb/HTML/HTMLImageElement.h>
@ -99,9 +100,7 @@ void Resource::did_load(Badge<ResourceLoader>, ReadonlyBytes data, const HashMap
m_encoding = encoding_from_content_type(content_type.value());
m_mime_type = mime_type_from_content_type(content_type.value());
} else if (url().protocol() == "data" && !url().data_mime_type().is_empty()) {
#ifdef RESOURCE_DEBUG
dbg() << "This is a data URL with mime-type _" << url().data_mime_type() << "_";
#endif
dbgln<debug_resource>("This is a data URL with mime-type _{}_", url().data_mime_type());
m_encoding = "utf-8"; // FIXME: This doesn't seem nice.
m_mime_type = url().data_mime_type();
} else {

View file

@ -25,6 +25,7 @@
*/
#include <AK/Base64.h>
#include <AK/Debug.h>
#include <AK/JsonObject.h>
#include <LibCore/EventLoop.h>
#include <LibCore/File.h>
@ -35,8 +36,6 @@
#include <LibWeb/Loader/Resource.h>
#include <LibWeb/Loader/ResourceLoader.h>
//#define CACHE_DEBUG
namespace Web {
ResourceLoader& ResourceLoader::the()
@ -82,11 +81,9 @@ RefPtr<Resource> ResourceLoader::load_resource(Resource::Type type, const LoadRe
auto it = s_resource_cache.find(request);
if (it != s_resource_cache.end()) {
if (it->value->type() != type) {
dbg() << "FIXME: Not using cached resource for " << request.url() << " since there's a type mismatch.";
dbgln("FIXME: Not using cached resource for {} since there's a type mismatch.", request.url());
} else {
#ifdef CACHE_DEBUG
dbg() << "Reusing cached resource for: " << request.url();
#endif
dbgln<debug_cache>("Reusing cached resource for: {}", request.url());
return it->value;
}
}
@ -112,7 +109,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
auto& url = request.url();
if (is_port_blocked(url.port())) {
dbg() << "ResourceLoader::load: Error: blocked port " << url.port() << " for URL: " << url;
dbgln("ResourceLoader::load: Error: blocked port {} from URL {}", url.port(), url);
return;
}
@ -123,7 +120,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
}
if (url.protocol() == "about") {
dbg() << "Loading about: URL " << url;
dbgln("Loading about: URL {}", url);
deferred_invoke([success_callback = move(success_callback)](auto&) {
success_callback(String::empty().to_byte_buffer(), {});
});
@ -131,7 +128,10 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
}
if (url.protocol() == "data") {
dbg() << "ResourceLoader loading a data URL with mime-type: '" << url.data_mime_type() << "', base64=" << url.data_payload_is_base64() << ", payload='" << url.data_payload() << "'";
dbgln("ResourceLoader loading a data URL with mime-type: '{}', base64={}, payload='{}'",
url.data_mime_type(),
url.data_payload_is_base64(),
url.data_payload());
ByteBuffer data;
if (url.data_payload_is_base64())
@ -149,7 +149,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
auto f = Core::File::construct();
f->set_filename(url.path());
if (!f->open(Core::IODevice::OpenMode::ReadOnly)) {
dbg() << "ResourceLoader::load: Error: " << f->error_string();
dbgln("ResourceLoader::load: Error: {}", f->error_string());
if (error_callback)
error_callback(f->error_string());
return;