diff --git a/src/core/check.hpp b/src/core/check.hpp index 2e7fe5f5b..6f01ece53 100644 --- a/src/core/check.hpp +++ b/src/core/check.hpp @@ -94,7 +94,7 @@ class CheckError { LogMessage* log_message_; }; -#if defined(OFFICIAL_BUILD) && defined(NDEBUG) +#if defined(OFFICIAL_BUILD) && !DCHECK_IS_ON() // Discard log strings to reduce code bloat. // diff --git a/src/core/logging.cpp b/src/core/logging.cpp index e50573b31..1da89fc7e 100644 --- a/src/core/logging.cpp +++ b/src/core/logging.cpp @@ -209,16 +209,6 @@ typedef FILE* FileHandle; #include #include -#if !defined(NDEBUG) || defined(_DEBUG) -#define DEFAULT_LOGBUFLEVEL -1 -#define DEFAULT_VERBOSE_LEVEL 1 -#define DEFAULT_LOGSTDERRTHRESHOLD LOGGING_WARNING -#else -#define DEFAULT_LOGBUFLEVEL 0 -#define DEFAULT_VERBOSE_LEVEL 0 -#define DEFAULT_LOGSTDERRTHRESHOLD LOGGING_ERROR -#endif - namespace { // simple init once flag std::atomic g_log_init; @@ -302,7 +292,7 @@ ABSL_FLAG(bool, // when they run a program without having to look in another file. ABSL_FLAG(int32_t, stderrthreshold, - DEFAULT_LOGSTDERRTHRESHOLD, + LOGGING_ERROR, "log messages at or above this level are copied to stderr in " "addition to logfiles. This flag obsoletes --alsologtostderr."); ABSL_FLAG(int32_t, @@ -312,7 +302,7 @@ ABSL_FLAG(int32_t, "actually get logged anywhere"); ABSL_FLAG(int32_t, logbuflevel, - DEFAULT_LOGBUFLEVEL, + 0, "Buffer log messages logged at this level or lower" " (-1 means don't buffer; 0 means buffer INFO only;" " ...)"); @@ -355,7 +345,7 @@ ABSL_FLAG(bool, stop_logging_if_full_disk, false, "Stop attempting to log to dis ABSL_FLAG(std::string, log_backtrace_at, "", "Emit a backtrace when logging at file:linenum."); -ABSL_FLAG(int32_t, v, DEFAULT_VERBOSE_LEVEL, "verboselevel"); +ABSL_FLAG(int32_t, v, 0, "verboselevel"); ABSL_FLAG(std::string, vmodule, diff --git a/src/crypto/aead_evp_decrypter.cpp b/src/crypto/aead_evp_decrypter.cpp index a7b3e8308..8e9c1c2f5 100644 --- a/src/crypto/aead_evp_decrypter.cpp +++ b/src/crypto/aead_evp_decrypter.cpp @@ -11,7 +11,7 @@ // In debug builds only, log OpenSSL error stack. Then clear OpenSSL error // stack. static void DLogOpenSslErrors() { -#ifdef NDEBUG +#if !DCHECK_IS_ON() ERR_clear_error(); #else while (uint32_t error = ERR_get_error()) { diff --git a/src/crypto/aead_evp_encrypter.cpp b/src/crypto/aead_evp_encrypter.cpp index 04ea5870f..492572aed 100644 --- a/src/crypto/aead_evp_encrypter.cpp +++ b/src/crypto/aead_evp_encrypter.cpp @@ -11,7 +11,7 @@ // In debug builds only, log OpenSSL error stack. Then clear OpenSSL error // stack. static void DLogOpenSslErrors() { -#ifdef NDEBUG +#if !DCHECK_IS_ON() ERR_clear_error(); #else while (uint32_t error = ERR_get_error()) { diff --git a/src/crypto/aead_sodium_decrypter.cpp b/src/crypto/aead_sodium_decrypter.cpp index 83ff40b24..c4483360d 100644 --- a/src/crypto/aead_sodium_decrypter.cpp +++ b/src/crypto/aead_sodium_decrypter.cpp @@ -11,7 +11,7 @@ // In debug builds only, log OpenSSL error stack. Then clear OpenSSL error // stack. static void DLogOpenSslErrors() { -#ifdef NDEBUG +#if !DCHECK_IS_ON() ERR_clear_error(); #else while (uint32_t error = ERR_get_error()) { diff --git a/src/crypto/aead_sodium_encrypter.cpp b/src/crypto/aead_sodium_encrypter.cpp index bd45ab956..0f8fc4583 100644 --- a/src/crypto/aead_sodium_encrypter.cpp +++ b/src/crypto/aead_sodium_encrypter.cpp @@ -11,7 +11,7 @@ // In debug builds only, log OpenSSL error stack. Then clear OpenSSL error // stack. static void DLogOpenSslErrors() { -#ifdef NDEBUG +#if !DCHECK_IS_ON() ERR_clear_error(); #else while (uint32_t error = ERR_get_error()) { diff --git a/src/net/cipher.cpp b/src/net/cipher.cpp index 718cafb14..740904639 100644 --- a/src/net/cipher.cpp +++ b/src/net/cipher.cpp @@ -193,9 +193,7 @@ cipher::cipher(const std::string& key, key_len_ = !key.empty() ? cipher_impl::parse_key(key, key_, key_bitlen_ / 8) : cipher_impl::derive_key(password, key_, key_bitlen_ / 8); -#ifndef NDEBUG DumpHex("cipher: KEY", key_, key_len_); -#endif tag_len_ = impl_->GetTagSize(); } @@ -283,9 +281,7 @@ void cipher::decrypt_salt(IOBuf* chunk) { chunk->trimStart(nonce_len); chunk->retreat(nonce_len); set_key_stream(nonce, nonce_len); -#ifndef NDEBUG DumpHex("DE-NONCE", nonce, nonce_len); -#endif return; } #endif @@ -298,9 +294,7 @@ void cipher::decrypt_salt(IOBuf* chunk) { chunk->retreat(salt_len); set_key_aead(salt_, salt_len); -#ifndef NDEBUG DumpHex("DE-SALT", salt_, salt_len); -#endif } void cipher::encrypt_salt(IOBuf* chunk) { @@ -316,9 +310,7 @@ void cipher::encrypt_salt(IOBuf* chunk) { chunk->prepend(nonce_len); memcpy(chunk->mutable_data(), nonce, nonce_len); set_key_stream(nonce, nonce_len); -#ifndef NDEBUG DumpHex("EN-NONCE", nonce, nonce_len); -#endif return; } #endif @@ -331,9 +323,7 @@ void cipher::encrypt_salt(IOBuf* chunk) { memcpy(chunk->mutable_data(), salt_, salt_len); set_key_aead(salt_, salt_len); -#ifndef NDEBUG DumpHex("EN-SALT", salt_, salt_len); -#endif } int cipher::chunk_decrypt_frame(uint64_t* counter, IOBuf* plaintext, IOBuf* ciphertext) const { @@ -539,10 +529,8 @@ void cipher::set_key_stream(const uint8_t* nonce, size_t nonce_len) { LOG(WARNING) << "SetKey Failed"; } -#ifndef NDEBUG DumpHex("KEY", impl_->GetKey(), impl_->GetKeySize()); DumpHex("IV", impl_->GetIV(), impl_->GetIVSize()); -#endif } void cipher::set_key_aead(const uint8_t* salt, size_t salt_len) { @@ -565,10 +553,8 @@ void cipher::set_key_aead(const uint8_t* salt, size_t salt_len) { LOG(WARNING) << "SetNoncePrefix Failed"; } -#ifndef NDEBUG DumpHex("SKEY", impl_->GetKey(), impl_->GetKeySize()); DumpHex("NONCE_PREFIX", impl_->GetNoncePrefix(), impl_->GetNoncePrefixSize()); -#endif } } // namespace net diff --git a/src/net/protocol.hpp b/src/net/protocol.hpp index 1ee6f0777..ad7954b15 100644 --- a/src/net/protocol.hpp +++ b/src/net/protocol.hpp @@ -34,7 +34,7 @@ NextProto NextProtoFromString(std::string_view proto_string); std::string_view NextProtoToString(NextProto next_proto); -#ifndef NDEBUG +#if DCHECK_IS_ON() inline void DumpHex_Impl(const char* file, int line, const char* prefix, const uint8_t* data, uint32_t length) { if (!VLOG_IS_ON(4)) { return; @@ -90,11 +90,11 @@ inline void DumpHex_Impl(const char* file, int line, const char* prefix, const n uint32_t length = buf->length(); DumpHex_Impl(file, line, prefix, data, length); } -#endif // NDEBUG +#endif // DCHECK_IS_ON() } // namespace net -#ifndef NDEBUG +#if DCHECK_IS_ON() #define DumpHex(...) ::net::DumpHex_Impl(__FILE__, __LINE__, __VA_ARGS__) #else #define DumpHex(...) diff --git a/src/net/stream.hpp b/src/net/stream.hpp index 4426171a8..c8e9d4395 100644 --- a/src/net/stream.hpp +++ b/src/net/stream.hpp @@ -503,7 +503,7 @@ class stream : public RefCountedThreadSafe { if (ec) { VLOG(2) << "data transfer failed with " << endpoint_ << " due to " << ec << " stats: readed " << rbytes_transferred_ << " written: " << wbytes_transferred_; -#ifndef NDEBUG +#if DCHECK_IS_ON() const char* file; int line; while (uint32_t error = ERR_get_error_line(&file, &line)) {