1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:37: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-15 21:46:23 +01:00 committed by Andreas Kling
parent 27bc48e06c
commit 9229ba0fe9
14 changed files with 130 additions and 80 deletions

View file

@ -24,12 +24,11 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <AK/Debug.h>
#include <LibCore/NetworkJob.h>
#include <LibCore/NetworkResponse.h>
#include <stdio.h>
//#define CNETWORKJOB_DEBUG
namespace Core {
NetworkJob::NetworkJob(OutputStream& output_stream)
@ -56,9 +55,7 @@ void NetworkJob::did_finish(NonnullRefPtr<NetworkResponse>&& response)
NonnullRefPtr<NetworkJob> protector(*this);
m_response = move(response);
#ifdef CNETWORKJOB_DEBUG
dbg() << *this << " job did_finish!";
#endif
dbgln<debug_cnetworkjob>("{} job did_finish", *this);
ASSERT(on_finish);
on_finish(true);
shutdown();

View file

@ -81,3 +81,7 @@ private:
const char* to_string(NetworkJob::Error);
}
template<>
struct AK::Formatter<Core::NetworkJob> : Formatter<Core::Object> {
};

View file

@ -25,6 +25,7 @@
*/
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <LibCore/Notifier.h>
#include <LibCore/Socket.h>
#include <arpa/inet.h>
@ -37,8 +38,6 @@
#include <sys/socket.h>
#include <unistd.h>
//#define CSOCKET_DEBUG
namespace Core {
Socket::Socket(Type type, Object* parent)
@ -80,9 +79,7 @@ bool Socket::connect(const String& hostname, int port)
}
IPv4Address host_address((const u8*)hostent->h_addr_list[0]);
#ifdef CSOCKET_DEBUG
dbg() << "Socket::connect: Resolved '" << hostname << "' to " << host_address;
#endif
dbgln<debug_csocket>("Socket::connect: Resolved '{}' to {}", hostname, host_address);
return connect(host_address, port);
}
@ -101,9 +98,7 @@ bool Socket::connect(const SocketAddress& address, int port)
{
ASSERT(!is_connected());
ASSERT(address.type() == SocketAddress::Type::IPv4);
#ifdef CSOCKET_DEBUG
dbg() << *this << " connecting to " << address << "...";
#endif
dbgln<debug_csocket>("{} connecting to {}...", *this, address);
ASSERT(port > 0 && port <= 65535);
@ -124,9 +119,7 @@ bool Socket::connect(const SocketAddress& address)
{
ASSERT(!is_connected());
ASSERT(address.type() == SocketAddress::Type::Local);
#ifdef CSOCKET_DEBUG
dbg() << *this << " connecting to " << address << "...";
#endif
dbgln<debug_csocket>("{} connecting to {}...", *this, address);
sockaddr_un saddr;
saddr.sun_family = AF_LOCAL;
@ -145,9 +138,7 @@ bool Socket::connect(const SocketAddress& address)
bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
{
auto connected = [this] {
#ifdef CSOCKET_DEBUG
dbg() << *this << " connected!";
#endif
dbgln<debug_csocket>("{} connected!", *this);
if (!m_connected) {
m_connected = true;
ensure_read_notifier();
@ -162,9 +153,7 @@ bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
int rc = ::connect(fd(), addr, addrlen);
if (rc < 0) {
if (errno == EINPROGRESS) {
#ifdef CSOCKET_DEBUG
dbg() << *this << " connection in progress (EINPROGRESS)";
#endif
dbgln<debug_csocket>("{} connection in progress (EINPROGRESS)", *this);
m_notifier = Notifier::construct(fd(), Notifier::Event::Write, this);
m_notifier->on_ready_to_write = move(connected);
return true;
@ -174,9 +163,7 @@ bool Socket::common_connect(const struct sockaddr* addr, socklen_t addrlen)
errno = saved_errno;
return false;
}
#ifdef CSOCKET_DEBUG
dbg() << *this << " connected ok!";
#endif
dbgln<debug_csocket>("{} connected ok!", *this);
connected();
return true;
}

View file

@ -87,3 +87,7 @@ private:
};
}
template<>
struct AK::Formatter<Core::Socket> : Formatter<Core::Object> {
};

View file

@ -113,3 +113,11 @@ private:
const LogStream& operator<<(const LogStream&, const SocketAddress&);
}
template<>
struct AK::Formatter<Core::SocketAddress> : Formatter<String> {
void format(FormatBuilder& builder, const Core::SocketAddress& value)
{
return Formatter<String>::format(builder, value.to_string());
}
};

View file

@ -26,6 +26,7 @@
#pragma once
#include <AK/Debug.h>
#include <AK/LogStream.h>
#include <AK/StdLibExtras.h>
#include <errno.h>
@ -41,10 +42,11 @@ inline int safe_syscall(Syscall syscall, Args&&... args)
for (;;) {
int sysret = syscall(forward<Args>(args)...);
if (sysret == -1) {
#ifdef SAFE_SYSCALL_DEBUG
int saved_errno = errno;
dbg() << "Core::safe_syscall: " << sysret << " (" << saved_errno << ": " << strerror(saved_errno) << ")";
#endif
if constexpr (debug_safe_syscall) {
int saved_errno = errno;
dbgln<debug_safe_syscall>("Core::safe_syscall: {} ({}: {})", sysret, saved_errno, strerror(saved_errno));
}
if (errno == EINTR)
continue;
ASSERT_NOT_REACHED();