diff options
author | Linus Groh <mail@linusgroh.de> | 2020-10-25 14:46:04 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-25 18:52:20 +0100 |
commit | 75864b5a8569f1fdeabcc94c9a9f9c7091cf264d (patch) | |
tree | f1de8d91b8c03951d087e1d20f06108d0733c2b6 | |
parent | 956e9aa73671575a44076791e797679cb09f5028 (diff) | |
download | serenity-75864b5a8569f1fdeabcc94c9a9f9c7091cf264d.zip |
LookupServer: Replace dbg()/dbgprintf() with dbgln()
-rw-r--r-- | Services/LookupServer/DNSResponse.cpp | 18 | ||||
-rw-r--r-- | Services/LookupServer/LookupServer.cpp | 23 |
2 files changed, 20 insertions, 21 deletions
diff --git a/Services/LookupServer/DNSResponse.cpp b/Services/LookupServer/DNSResponse.cpp index 8889a68b60..cf8599ab2d 100644 --- a/Services/LookupServer/DNSResponse.cpp +++ b/Services/LookupServer/DNSResponse.cpp @@ -57,16 +57,16 @@ static_assert(sizeof(DNSRecordWithoutName) == 10); Optional<DNSResponse> DNSResponse::from_raw_response(const u8* raw_data, size_t raw_size) { if (raw_size < sizeof(DNSPacket)) { - dbg() << "DNS response not large enough (" << raw_size << " out of " << sizeof(DNSPacket) << ") to be a DNS packet."; + dbgln("DNS response not large enough ({} out of {}) to be a DNS packet.", raw_size, sizeof(DNSPacket)); return {}; } auto& response_header = *(const DNSPacket*)(raw_data); - dbgprintf("Got response (ID: %u)\n", response_header.id()); - dbgprintf(" Question count: %u\n", response_header.question_count()); - dbgprintf(" Answer count: %u\n", response_header.answer_count()); - dbgprintf(" Authority count: %u\n", response_header.authority_count()); - dbgprintf("Additional count: %u\n", response_header.additional_count()); + dbgln("Got response (ID: {})", response_header.id()); + dbgln(" Question count: {}", response_header.question_count()); + dbgln(" Answer count: {}", response_header.answer_count()); + dbgln(" Authority count: {}", response_header.authority_count()); + dbgln("Additional count: {}", response_header.additional_count()); DNSResponse response; response.m_id = response_header.id(); @@ -87,7 +87,7 @@ Optional<DNSResponse> DNSResponse::from_raw_response(const u8* raw_data, size_t response.m_questions.empend(name, record_and_class.record_type, record_and_class.class_code); auto& question = response.m_questions.last(); offset += 4; - dbg() << "Question #" << i << ": _" << question.name() << "_ type: " << question.record_type() << ", class: " << question.class_code(); + dbgln("Question #{}: name=_{}_, type={}, class={}", i, question.name(), question.record_type(), question.class_code()); } for (u16 i = 0; i < response_header.answer_count(); ++i) { @@ -106,9 +106,9 @@ Optional<DNSResponse> DNSResponse::from_raw_response(const u8* raw_data, size_t data = ipv4_address.to_string(); } else { // FIXME: Parse some other record types perhaps? - dbg() << " data=(unimplemented record type " << record.type() << ")"; + dbgln("data=(unimplemented record type {})", record.type()); } - dbg() << "Answer #" << i << ": name=_" << name << "_, type=" << record.type() << ", ttl=" << record.ttl() << ", length=" << record.data_length() << ", data=_" << data << "_"; + dbgln("Answer #{}: name=_{}_, type={}, ttl={}, length={}, data=_{}_", i, name, record.type(), record.ttl(), record.data_length(), data); response.m_answers.empend(name, record.type(), record.record_class(), record.ttl(), data); offset += record.data_length(); } diff --git a/Services/LookupServer/LookupServer.cpp b/Services/LookupServer/LookupServer.cpp index 53900ebd02..855a2c1dce 100644 --- a/Services/LookupServer/LookupServer.cpp +++ b/Services/LookupServer/LookupServer.cpp @@ -42,7 +42,7 @@ LookupServer::LookupServer() { auto config = Core::ConfigFile::get_for_system("LookupServer"); - dbg() << "Using network config file at " << config->file_name(); + dbgln("Using network config file at {}", config->file_name()); m_nameserver = config->read_entry("DNS", "Nameserver", "1.1.1.1"); load_etc_hosts(); @@ -109,11 +109,11 @@ void LookupServer::service_client(RefPtr<Core::LocalSocket> socket) char lookup_type = client_buffer[0]; if (lookup_type != 'L' && lookup_type != 'R') { - dbg() << "Invalid lookup_type " << lookup_type; + dbgln("Invalid lookup_type '{}'", lookup_type); return; } auto hostname = String((const char*)client_buffer + 1, nrecv - 1, Chomp); - dbg() << "Got request for '" << hostname << "' (using IP " << m_nameserver << ")"; + dbgln("Got request for '{}' (using IP {})", hostname, m_nameserver); Vector<String> responses; @@ -160,10 +160,9 @@ Vector<String> LookupServer::lookup(const String& hostname, bool& did_timeout, u if (cached_lookup.question.record_type() == record_type) { Vector<String> responses; for (auto& cached_answer : cached_lookup.answers) { - dbg() << "Cache hit: " << hostname << " -> " << cached_answer.record_data() << ", expired: " << cached_answer.has_expired(); - if (!cached_answer.has_expired()) { + dbgln("Cache hit: {} -> {}, expired: {}", hostname, cached_answer.record_data(), cached_answer.has_expired()); + if (!cached_answer.has_expired()) responses.append(cached_answer.record_data()); - } } if (!responses.is_empty()) return responses; @@ -207,7 +206,7 @@ Vector<String> LookupServer::lookup(const String& hostname, bool& did_timeout, u auto& response = o_response.value(); if (response.id() != request.id()) { - dbgprintf("LookupServer: ID mismatch (%u vs %u) :(\n", response.id(), request.id()); + dbgln("LookupServer: ID mismatch ({} vs {}) :(", response.id(), request.id()); return {}; } @@ -220,7 +219,7 @@ Vector<String> LookupServer::lookup(const String& hostname, bool& did_timeout, u } if (response.question_count() != request.question_count()) { - dbgprintf("LookupServer: Question count (%u vs %u) :(\n", response.question_count(), request.question_count()); + dbgln("LookupServer: Question count ({} vs {}) :(", response.question_count(), request.question_count()); return {}; } @@ -228,15 +227,15 @@ Vector<String> LookupServer::lookup(const String& hostname, bool& did_timeout, u auto& request_question = request.questions()[i]; auto& response_question = response.questions()[i]; if (request_question != response_question) { - dbg() << "Request and response questions do not match"; - dbg() << " Request: {_" << request_question.name() << "_, " << request_question.record_type() << ", " << request_question.class_code() << "}"; - dbg() << " Response: {_" << response_question.name() << "_, " << response_question.record_type() << ", " << response_question.class_code() << "}"; + dbgln("Request and response questions do not match"); + dbgln(" Request: name=_{}_, type={}, class={}", request_question.name(), response_question.record_type(), response_question.class_code()); + dbgln(" Response: name=_{}_, type={}, class={}", response_question.name(), response_question.record_type(), response_question.class_code()); return {}; } } if (response.answer_count() < 1) { - dbgprintf("LookupServer: Not enough answers (%u) :(\n", response.answer_count()); + dbgln("LookupServer: Not enough answers ({}) :(", response.answer_count()); return {}; } |