diff --git a/src/core/handshaker/handshaker.cc b/src/core/handshaker/handshaker.cc index 5fee61ffed6..66824008fd7 100644 --- a/src/core/handshaker/handshaker.cc +++ b/src/core/handshaker/handshaker.cc @@ -82,11 +82,9 @@ HandshakeManager::HandshakeManager() void HandshakeManager::Add(RefCountedPtr handshaker) { MutexLock lock(&mu_); if (GRPC_TRACE_FLAG_ENABLED(handshaker)) { - gpr_log( - GPR_INFO, - "handshake_manager %p: adding handshaker %s [%p] at index %" PRIuPTR, - this, std::string(handshaker->name()).c_str(), handshaker.get(), - handshakers_.size()); + LOG(INFO) << "handshake_manager " << this << ": adding handshaker " + << std::string(handshaker->name()) << " [" << handshaker.get() + << "] at index " << handshakers_.size(); } handshakers_.push_back(std::move(handshaker)); } diff --git a/src/core/lib/event_engine/ares_resolver.h b/src/core/lib/event_engine/ares_resolver.h index 0182d0bef4e..68812e59a4c 100644 --- a/src/core/lib/event_engine/ares_resolver.h +++ b/src/core/lib/event_engine/ares_resolver.h @@ -47,11 +47,12 @@ namespace grpc_event_engine { namespace experimental { -#define GRPC_ARES_RESOLVER_TRACE_LOG(format, ...) \ - do { \ - if (GRPC_TRACE_FLAG_ENABLED(cares_resolver)) { \ - gpr_log(GPR_INFO, "(EventEngine c-ares resolver) " format, __VA_ARGS__); \ - } \ +#define GRPC_ARES_RESOLVER_TRACE_LOG(format, ...) \ + do { \ + if (GRPC_TRACE_FLAG_ENABLED(cares_resolver)) { \ + LOG(INFO) << "(EventEngine c-ares resolver) " \ + << absl::StrFormat(format, __VA_ARGS__); \ + } \ } while (0) class AresResolver : public RefCountedDNSResolverInterface { diff --git a/src/core/lib/experiments/experiments.yaml b/src/core/lib/experiments/experiments.yaml index ffed3b48294..5d69cf1bc13 100644 --- a/src/core/lib/experiments/experiments.yaml +++ b/src/core/lib/experiments/experiments.yaml @@ -175,7 +175,7 @@ - name: work_serializer_clears_time_cache description: Have the work serializer clear the time cache when it dispatches work. - expiry: 2024/07/01 + expiry: 2024/10/01 owner: ctiller@google.com test_tags: [] - name: work_serializer_dispatch diff --git a/src/core/lib/iomgr/call_combiner.h b/src/core/lib/iomgr/call_combiner.h index 0d969505775..d2c7c0c9851 100644 --- a/src/core/lib/iomgr/call_combiner.h +++ b/src/core/lib/iomgr/call_combiner.h @@ -22,6 +22,7 @@ #include #include "absl/container/inlined_vector.h" +#include "absl/log/log.h" #include #include @@ -166,11 +167,12 @@ class CallCombinerClosureList { closure.reason); } if (GRPC_TRACE_FLAG_ENABLED(call_combiner)) { - gpr_log(GPR_INFO, - "CallCombinerClosureList executing closure while already " - "holding call_combiner %p: closure=%s error=%s reason=%s", - call_combiner, closures_[0].closure->DebugString().c_str(), - StatusToString(closures_[0].error).c_str(), closures_[0].reason); + LOG(INFO) << "CallCombinerClosureList executing closure while already " + "holding call_combiner " + << call_combiner + << ": closure=" << closures_[0].closure->DebugString() + << " error=" << StatusToString(closures_[0].error) + << " reason=" << closures_[0].reason; } // This will release the call combiner. ExecCtx::Run(DEBUG_LOCATION, closures_[0].closure, closures_[0].error); diff --git a/src/core/lib/iomgr/cfstream_handle.cc b/src/core/lib/iomgr/cfstream_handle.cc index faee427f2bc..de9810ad2c8 100644 --- a/src/core/lib/iomgr/cfstream_handle.cc +++ b/src/core/lib/iomgr/cfstream_handle.cc @@ -24,6 +24,8 @@ #ifdef GRPC_CFSTREAM #import +#include "absl/log/log.h" + #include #include #include @@ -64,8 +66,8 @@ void CFStreamHandle::ReadCallback(CFReadStreamRef stream, CFErrorRef stream_error; CFStreamHandle* handle = static_cast(client_callback_info); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_DEBUG, "CFStream ReadCallback (%p, %p, %lu, %p)", handle, - stream, type, client_callback_info); + VLOG(2) << "CFStream ReadCallback (" << handle << ", " << stream << ", " + << type << ", " << client_callback_info << ")"; } switch (type) { case kCFStreamEventOpenCompleted: @@ -98,8 +100,8 @@ void CFStreamHandle::WriteCallback(CFWriteStreamRef stream, CFErrorRef stream_error; CFStreamHandle* handle = static_cast(clientCallBackInfo); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_DEBUG, "CFStream WriteCallback (%p, %p, %lu, %p)", handle, - stream, type, clientCallBackInfo); + VLOG(2) << "CFStream WriteCallback (" << handle << ", " << stream << ", " + << type << ", " << clientCallBackInfo << ")"; } switch (type) { case kCFStreamEventOpenCompleted: @@ -176,9 +178,8 @@ void CFStreamHandle::Shutdown(grpc_error_handle error) { void CFStreamHandle::Ref(const char* file, int line, const char* reason) { if (GRPC_TRACE_FLAG_ENABLED(tcp)) { gpr_atm val = gpr_atm_no_barrier_load(&refcount_.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "CFStream Handle ref %p : %s %" PRIdPTR " -> %" PRIdPTR, this, - reason, val, val + 1); + VLOG(2).AtLocation(file, line) << "CFStream Handle ref " << this << " : " + << reason << " " << val << " -> " << val + 1; } gpr_ref(&refcount_); } @@ -186,9 +187,8 @@ void CFStreamHandle::Ref(const char* file, int line, const char* reason) { void CFStreamHandle::Unref(const char* file, int line, const char* reason) { if (GRPC_TRACE_FLAG_ENABLED(tcp)) { gpr_atm val = gpr_atm_no_barrier_load(&refcount_.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "CFStream Handle unref %p : %s %" PRIdPTR " -> %" PRIdPTR, this, - reason, val, val - 1); + VLOG(2).AtLocation(file, line) << "CFStream Handle unref " << this << " : " + << reason << " " << val << " -> " << val - 1; } if (gpr_unref(&refcount_)) { delete this; diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h index efdb25f2fd3..bebdb41a0a4 100644 --- a/src/core/lib/iomgr/closure.h +++ b/src/core/lib/iomgr/closure.h @@ -23,9 +23,9 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include -#include #include #include "src/core/lib/gprpp/crash.h" @@ -293,16 +293,16 @@ class Closure { } #ifndef NDEBUG if (GRPC_TRACE_FLAG_ENABLED(closure)) { - gpr_log(GPR_DEBUG, "running closure %p: created [%s:%d]: run [%s:%d]", - closure, closure->file_created, closure->line_created, - location.file(), location.line()); + VLOG(2) << "running closure " << closure << ": created [" + << closure->file_created << ":" << closure->line_created + << "]: run [" << location.file() << ":" << location.line() << "]"; } CHECK_NE(closure->cb, nullptr); #endif closure->cb(closure->cb_arg, error); #ifndef NDEBUG if (GRPC_TRACE_FLAG_ENABLED(closure)) { - gpr_log(GPR_DEBUG, "closure %p finished", closure); + VLOG(2) << "closure " << closure << " finished"; } #endif } diff --git a/src/core/lib/iomgr/error.cc b/src/core/lib/iomgr/error.cc index d646b9a8a5f..d1303834559 100644 --- a/src/core/lib/iomgr/error.cc +++ b/src/core/lib/iomgr/error.cc @@ -21,12 +21,12 @@ #include #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_format.h" #include #include -#include #include #include @@ -221,7 +221,7 @@ grpc_error_handle grpc_error_add_child(grpc_error_handle src, bool grpc_log_error(const char* what, grpc_error_handle error, const char* file, int line) { DCHECK(!error.ok()); - gpr_log(file, line, GPR_LOG_SEVERITY_ERROR, "%s: %s", what, - grpc_core::StatusToString(error).c_str()); + LOG(ERROR).AtLocation(file, line) + << what << ": " << grpc_core::StatusToString(error); return false; } diff --git a/src/core/lib/iomgr/ev_poll_posix.cc b/src/core/lib/iomgr/ev_poll_posix.cc index 049787596df..b2a30686331 100644 --- a/src/core/lib/iomgr/ev_poll_posix.cc +++ b/src/core/lib/iomgr/ev_poll_posix.cc @@ -39,7 +39,6 @@ #include "absl/strings/str_format.h" #include -#include #include "src/core/lib/gprpp/crash.h" #include "src/core/lib/gprpp/thd.h" @@ -334,10 +333,10 @@ static void fork_fd_list_add_wakeup_fd(grpc_cached_wakeup_fd* fd) { static void ref_by(grpc_fd* fd, int n, const char* reason, const char* file, int line) { if (GRPC_TRACE_FLAG_ENABLED(fd_refcount)) { - gpr_log(GPR_DEBUG, - "FD %d %p ref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]", - fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst), - gpr_atm_no_barrier_load(&fd->refst) + n, reason, file, line); + VLOG(2) << "FD " << fd->fd << " " << fd << " ref " << n << " " + << gpr_atm_no_barrier_load(&fd->refst) << " -> " + << gpr_atm_no_barrier_load(&fd->refst) + n << " [" << reason << "; " + << file << ":" << line << "]"; } #else #define REF_BY(fd, n, reason) \ @@ -359,10 +358,10 @@ static void ref_by(grpc_fd* fd, int n) { static void unref_by(grpc_fd* fd, int n, const char* reason, const char* file, int line) { if (GRPC_TRACE_FLAG_ENABLED(fd_refcount)) { - gpr_log(GPR_DEBUG, - "FD %d %p unref %d %" PRIdPTR " -> %" PRIdPTR " [%s; %s:%d]", - fd->fd, fd, n, gpr_atm_no_barrier_load(&fd->refst), - gpr_atm_no_barrier_load(&fd->refst) - n, reason, file, line); + VLOG(2) << "FD " << fd->fd << " " << fd << " unref " << n << " " + << gpr_atm_no_barrier_load(&fd->refst) << " -> " + << gpr_atm_no_barrier_load(&fd->refst) - n << " [" << reason << "; " + << file << ":" << line << "]"; } #else static void unref_by(grpc_fd* fd, int n) { @@ -1030,7 +1029,7 @@ static grpc_error_handle pollset_work(grpc_pollset* pollset, GRPC_SCHEDULING_END_BLOCKING_REGION; if (GRPC_TRACE_FLAG_ENABLED(polling)) { - gpr_log(GPR_INFO, "%p poll=%d", pollset, r); + LOG(INFO) << pollset << " poll=" << r; } if (r < 0) { @@ -1054,7 +1053,7 @@ static grpc_error_handle pollset_work(grpc_pollset* pollset, } else { if (pfds[0].revents & POLLIN_CHECK) { if (GRPC_TRACE_FLAG_ENABLED(polling)) { - gpr_log(GPR_INFO, "%p: got_wakeup", pollset); + LOG(INFO) << pollset << ": got_wakeup"; } work_combine_error( &error, grpc_wakeup_fd_consume_wakeup(&worker.wakeup_fd->fd)); @@ -1068,9 +1067,10 @@ static grpc_error_handle pollset_work(grpc_pollset* pollset, fd_end_poll(&watchers[i], 0, 0); } else { if (GRPC_TRACE_FLAG_ENABLED(polling)) { - gpr_log(GPR_INFO, "%p got_event: %d r:%d w:%d [%d]", pollset, - pfds[i].fd, (pfds[i].revents & POLLIN_CHECK) != 0, - (pfds[i].revents & POLLOUT_CHECK) != 0, pfds[i].revents); + LOG(INFO) << pollset << " got_event: " << pfds[i].fd + << " r:" << ((pfds[i].revents & POLLIN_CHECK) != 0) + << " w:" << ((pfds[i].revents & POLLOUT_CHECK) != 0) + << " [" << pfds[i].revents << "]"; } // This is a mitigation to prevent poll() from spinning on a //* POLLHUP https://github.com/grpc/grpc/pull/13665 diff --git a/src/core/lib/iomgr/ev_posix.h b/src/core/lib/iomgr/ev_posix.h index bbacc4813ac..06d039faf34 100644 --- a/src/core/lib/iomgr/ev_posix.h +++ b/src/core/lib/iomgr/ev_posix.h @@ -33,9 +33,9 @@ #include "src/core/lib/iomgr/pollset_set.h" #include "src/core/lib/iomgr/wakeup_fd_posix.h" -#define GRPC_FD_TRACE(format, ...) \ - if (GRPC_TRACE_FLAG_ENABLED(fd_trace)) { \ - gpr_log(GPR_INFO, "(fd-trace) " format, __VA_ARGS__); \ +#define GRPC_FD_TRACE(format, ...) \ + if (GRPC_TRACE_FLAG_ENABLED(fd_trace)) { \ + LOG(INFO) << "(fd-trace) " << absl::StrFormat(format, __VA_ARGS__); \ } typedef struct grpc_fd grpc_fd; diff --git a/src/core/lib/iomgr/event_engine_shims/closure.cc b/src/core/lib/iomgr/event_engine_shims/closure.cc index 4e67097b462..e38b295bbaf 100644 --- a/src/core/lib/iomgr/event_engine_shims/closure.cc +++ b/src/core/lib/iomgr/event_engine_shims/closure.cc @@ -14,6 +14,7 @@ #include "src/core/lib/iomgr/event_engine_shims/closure.h" #include "absl/functional/any_invocable.h" +#include "absl/log/log.h" #include "absl/status/status.h" #include @@ -35,17 +36,16 @@ void RunEventEngineClosure(grpc_closure* closure, grpc_error_handle error) { #ifndef NDEBUG closure->scheduled = false; if (GRPC_TRACE_FLAG_ENABLED(closure)) { - gpr_log(GPR_DEBUG, - "EventEngine: running closure %p: created [%s:%d]: %s [%s:%d]", - closure, closure->file_created, closure->line_created, - closure->run ? "run" : "scheduled", closure->file_initiated, - closure->line_initiated); + VLOG(2) << "EventEngine: running closure " << closure << ": created [" + << closure->file_created << ":" << closure->line_created + << "]: " << (closure->run ? "run" : "scheduled") << " [" + << closure->file_initiated << ":" << closure->line_initiated << "]"; } #endif closure->cb(closure->cb_arg, error); #ifndef NDEBUG if (GRPC_TRACE_FLAG_ENABLED(closure)) { - gpr_log(GPR_DEBUG, "EventEngine: closure %p finished", closure); + VLOG(2) << "EventEngine: closure " << closure << " finished"; } #endif } diff --git a/src/core/lib/iomgr/event_engine_shims/endpoint.cc b/src/core/lib/iomgr/event_engine_shims/endpoint.cc index 0dfff51dd32..5b71ec378f8 100644 --- a/src/core/lib/iomgr/event_engine_shims/endpoint.cc +++ b/src/core/lib/iomgr/event_engine_shims/endpoint.cc @@ -28,7 +28,6 @@ #include #include #include -#include #include #include @@ -120,8 +119,7 @@ class EventEngineEndpointWrapper { read_buffer->~SliceBuffer(); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { size_t i; - gpr_log(GPR_INFO, "TCP: %p READ error=%s", eeep_->wrapper, - status.ToString().c_str()); + LOG(INFO) << "TCP: " << eeep_->wrapper << " READ error=" << status; if (ABSL_VLOG_IS_ON(2)) { for (i = 0; i < pending_read_buffer_->count; i++) { char* dump = grpc_dump_slice(pending_read_buffer_->slices[i], @@ -151,8 +149,7 @@ class EventEngineEndpointWrapper { Ref(); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { size_t i; - gpr_log(GPR_INFO, "TCP: %p WRITE (peer=%s)", this, - std::string(PeerAddress()).c_str()); + LOG(INFO) << "TCP: " << this << " WRITE (peer=" << PeerAddress() << ")"; if (ABSL_VLOG_IS_ON(2)) { for (i = 0; i < slices->count; i++) { char* dump = @@ -177,8 +174,8 @@ class EventEngineEndpointWrapper { auto* write_buffer = reinterpret_cast(&eeep_->write_buffer); write_buffer->~SliceBuffer(); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "TCP: %p WRITE (peer=%s) error=%s", this, - std::string(PeerAddress()).c_str(), status.ToString().c_str()); + LOG(INFO) << "TCP: " << this << " WRITE (peer=" << PeerAddress() + << ") error=" << status; } grpc_closure* cb = pending_write_cb_; pending_write_cb_ = nullptr; diff --git a/src/core/lib/iomgr/exec_ctx.cc b/src/core/lib/iomgr/exec_ctx.cc index aa7350b4540..0a3ae056eb8 100644 --- a/src/core/lib/iomgr/exec_ctx.cc +++ b/src/core/lib/iomgr/exec_ctx.cc @@ -19,9 +19,9 @@ #include "src/core/lib/iomgr/exec_ctx.h" #include "absl/log/check.h" +#include "absl/log/log.h" #include "absl/strings/str_format.h" -#include #include #include @@ -33,10 +33,10 @@ static void exec_ctx_run(grpc_closure* closure) { #ifndef NDEBUG closure->scheduled = false; if (GRPC_TRACE_FLAG_ENABLED(closure)) { - gpr_log(GPR_DEBUG, "running closure %p: created [%s:%d]: %s [%s:%d]", - closure, closure->file_created, closure->line_created, - closure->run ? "run" : "scheduled", closure->file_initiated, - closure->line_initiated); + VLOG(2) << "running closure " << closure << ": created [" + << closure->file_created << ":" << closure->line_created + << "]: " << (closure->run ? "run" : "scheduled") << " [" + << closure->file_initiated << ":" << closure->line_initiated << "]"; } #endif grpc_error_handle error = @@ -45,7 +45,7 @@ static void exec_ctx_run(grpc_closure* closure) { closure->cb(closure->cb_arg, std::move(error)); #ifndef NDEBUG if (GRPC_TRACE_FLAG_ENABLED(closure)) { - gpr_log(GPR_DEBUG, "closure %p finished", closure); + VLOG(2) << "closure " << closure << " finished"; } #endif } diff --git a/src/core/lib/iomgr/lockfree_event.cc b/src/core/lib/iomgr/lockfree_event.cc index 7b20767870f..ab4f5639796 100644 --- a/src/core/lib/iomgr/lockfree_event.cc +++ b/src/core/lib/iomgr/lockfree_event.cc @@ -19,8 +19,8 @@ #include "src/core/lib/iomgr/lockfree_event.h" #include "absl/log/check.h" +#include "absl/log/log.h" -#include #include #include "src/core/lib/debug/trace.h" @@ -96,9 +96,8 @@ void LockfreeEvent::NotifyOn(grpc_closure* closure) { // referencing it. gpr_atm curr = gpr_atm_acq_load(&state_); if (GRPC_TRACE_FLAG_ENABLED(polling)) { - gpr_log(GPR_DEBUG, - "LockfreeEvent::NotifyOn: %p curr=%" PRIxPTR " closure=%p", this, - curr, closure); + VLOG(2) << "LockfreeEvent::NotifyOn: " << this << " curr=" << curr + << " closure=" << closure; } switch (curr) { case kClosureNotReady: { @@ -165,9 +164,8 @@ bool LockfreeEvent::SetShutdown(grpc_error_handle shutdown_error) { while (true) { gpr_atm curr = gpr_atm_no_barrier_load(&state_); if (GRPC_TRACE_FLAG_ENABLED(polling)) { - gpr_log(GPR_DEBUG, - "LockfreeEvent::SetShutdown: %p curr=%" PRIxPTR " err=%s", - &state_, curr, StatusToString(shutdown_error).c_str()); + VLOG(2) << "LockfreeEvent::SetShutdown: " << &state_ << " curr=" << curr + << " err=" << StatusToString(shutdown_error); } switch (curr) { case kClosureReady: @@ -215,8 +213,7 @@ void LockfreeEvent::SetReady() { gpr_atm curr = gpr_atm_no_barrier_load(&state_); if (GRPC_TRACE_FLAG_ENABLED(polling)) { - gpr_log(GPR_DEBUG, "LockfreeEvent::SetReady: %p curr=%" PRIxPTR, &state_, - curr); + VLOG(2) << "LockfreeEvent::SetReady: " << &state_ << " curr=" << curr; } switch (curr) { diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc index 017fc316f5a..4ef737e2c70 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -49,7 +49,6 @@ #include #include -#include #include #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -374,38 +373,35 @@ grpc_error_handle grpc_set_socket_tcp_user_timeout( // if it is available. if (g_socket_supports_tcp_user_timeout.load() == 0) { if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) { - gpr_log(GPR_INFO, - "TCP_USER_TIMEOUT is not available. TCP_USER_TIMEOUT won't " - "be used thereafter"); + LOG(INFO) << "TCP_USER_TIMEOUT is not available. TCP_USER_TIMEOUT " + "won't be used thereafter"; g_socket_supports_tcp_user_timeout.store(-1); } else { - gpr_log(GPR_INFO, - "TCP_USER_TIMEOUT is available. TCP_USER_TIMEOUT will be " - "used thereafter"); + LOG(INFO) << "TCP_USER_TIMEOUT is available. TCP_USER_TIMEOUT will " + "be used thereafter"; g_socket_supports_tcp_user_timeout.store(1); } } if (g_socket_supports_tcp_user_timeout.load() > 0) { if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "Enabling TCP_USER_TIMEOUT with a timeout of %d ms", - timeout); + LOG(INFO) << "Enabling TCP_USER_TIMEOUT with a timeout of " << timeout + << " ms"; } if (0 != setsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &timeout, sizeof(timeout))) { - gpr_log(GPR_ERROR, "setsockopt(TCP_USER_TIMEOUT) %s", - grpc_core::StrError(errno).c_str()); + LOG(ERROR) << "setsockopt(TCP_USER_TIMEOUT) " + << grpc_core::StrError(errno); return absl::OkStatus(); } if (0 != getsockopt(fd, IPPROTO_TCP, TCP_USER_TIMEOUT, &newval, &len)) { - gpr_log(GPR_ERROR, "getsockopt(TCP_USER_TIMEOUT) %s", - grpc_core::StrError(errno).c_str()); + LOG(ERROR) << "getsockopt(TCP_USER_TIMEOUT) " + << grpc_core::StrError(errno); return absl::OkStatus(); } if (newval != timeout) { - gpr_log(GPR_INFO, - "Setting TCP_USER_TIMEOUT to value %d ms. Actual " - "TCP_USER_TIMEOUT value is %d ms", - timeout, newval); + LOG(INFO) << "Setting TCP_USER_TIMEOUT to value " << timeout + << " ms. Actual TCP_USER_TIMEOUT value is " << newval + << " ms"; return absl::OkStatus(); } } @@ -451,8 +447,7 @@ static void probe_ipv6_once(void) { if (bind(fd, reinterpret_cast(&addr), sizeof(addr)) == 0) { g_ipv6_loopback_available = 1; } else { - gpr_log(GPR_INFO, - "Disabling AF_INET6 sockets because ::1 is not available."); + LOG(INFO) << "Disabling AF_INET6 sockets because ::1 is not available."; } close(fd); } diff --git a/src/core/lib/iomgr/tcp_client_cfstream.cc b/src/core/lib/iomgr/tcp_client_cfstream.cc index f350703e4c9..06c6a6fb486 100644 --- a/src/core/lib/iomgr/tcp_client_cfstream.cc +++ b/src/core/lib/iomgr/tcp_client_cfstream.cc @@ -27,9 +27,10 @@ #include #include +#include "absl/log/log.h" + #include #include -#include #include #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -78,8 +79,8 @@ static void CFStreamConnectCleanup(CFStreamConnect* connect) { static void OnAlarm(void* arg, grpc_error_handle error) { CFStreamConnect* connect = static_cast(arg); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_DEBUG, "CLIENT_CONNECT :%p OnAlarm, error:%s", connect, - grpc_core::StatusToString(error).c_str()); + VLOG(2) << "CLIENT_CONNECT :" << connect + << " OnAlarm, error:" << grpc_core::StatusToString(error); } gpr_mu_lock(&connect->mu); grpc_closure* closure = connect->closure; @@ -99,8 +100,8 @@ static void OnAlarm(void* arg, grpc_error_handle error) { static void OnOpen(void* arg, grpc_error_handle error) { CFStreamConnect* connect = static_cast(arg); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_DEBUG, "CLIENT_CONNECT :%p OnOpen, error:%s", connect, - grpc_core::StatusToString(error).c_str()); + VLOG(2) << "CLIENT_CONNECT :" << connect + << " OnOpen, error:" << grpc_core::StatusToString(error); } gpr_mu_lock(&connect->mu); grpc_timer_cancel(&connect->alarm); @@ -173,8 +174,8 @@ static int64_t CFStreamClientConnect( gpr_mu_init(&connect->mu); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_DEBUG, "CLIENT_CONNECT: %p, %s: asynchronously connecting", - connect, connect->addr_name.c_str()); + VLOG(2) << "CLIENT_CONNECT: " << connect << ", " << connect->addr_name + << ": asynchronously connecting"; } CFReadStreamRef read_stream; diff --git a/src/core/lib/iomgr/tcp_client_posix.cc b/src/core/lib/iomgr/tcp_client_posix.cc index eed6762c443..eed4b78e362 100644 --- a/src/core/lib/iomgr/tcp_client_posix.cc +++ b/src/core/lib/iomgr/tcp_client_posix.cc @@ -34,7 +34,6 @@ #include "absl/strings/str_cat.h" #include -#include #include #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -143,8 +142,8 @@ static void tc_on_alarm(void* acp, grpc_error_handle error) { int done; async_connect* ac = static_cast(acp); if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_alarm: error=%s", - ac->addr_str.c_str(), grpc_core::StatusToString(error).c_str()); + LOG(INFO) << "CLIENT_CONNECT: " << ac->addr_str + << ": on_alarm: error=" << grpc_core::StatusToString(error); } gpr_mu_lock(&ac->mu); if (ac->fd != nullptr) { @@ -182,8 +181,8 @@ static void on_writable(void* acp, grpc_error_handle error) { grpc_fd* fd; if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: on_writable: error=%s", - ac->addr_str.c_str(), grpc_core::StatusToString(error).c_str()); + LOG(INFO) << "CLIENT_CONNECT: " << ac->addr_str + << ": on_writable: error=" << grpc_core::StatusToString(error); } gpr_mu_lock(&ac->mu); @@ -383,8 +382,8 @@ int64_t grpc_tcp_client_create_from_prepared_fd( ac->options = options; if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "CLIENT_CONNECT: %s: asynchronously connecting fd %p", - ac->addr_str.c_str(), fdobj); + LOG(INFO) << "CLIENT_CONNECT: " << ac->addr_str + << ": asynchronously connecting fd " << fdobj; } int shard_number = connection_id % (*g_connection_shards).size(); diff --git a/src/core/lib/iomgr/tcp_windows.cc b/src/core/lib/iomgr/tcp_windows.cc index 7e4a2e2d60d..0888f92ff19 100644 --- a/src/core/lib/iomgr/tcp_windows.cc +++ b/src/core/lib/iomgr/tcp_windows.cc @@ -29,8 +29,6 @@ #include #include -#include -#include #include #include "src/core/lib/address_utils/sockaddr_utils.h" @@ -142,9 +140,8 @@ static void tcp_unref(grpc_tcp* tcp, const char* reason, const char* file, int line) { if (GRPC_TRACE_FLAG_ENABLED(tcp)) { gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "TCP unref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val, - val - 1); + VLOG(2).AtLocation(file, line) << "TCP unref " << tcp << " : " << reason + << " " << val << " -> " << val - 1; } if (gpr_unref(&tcp->refcount)) { tcp_free(tcp); @@ -155,9 +152,8 @@ static void tcp_ref(grpc_tcp* tcp, const char* reason, const char* file, int line) { if (GRPC_TRACE_FLAG_ENABLED(tcp)) { gpr_atm val = gpr_atm_no_barrier_load(&tcp->refcount.count); - gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, - "TCP ref %p : %s %" PRIdPTR " -> %" PRIdPTR, tcp, reason, val, - val + 1); + VLOG(2).AtLocation(file, line) << "TCP ref " << tcp << " : " << reason + << " " << val << " -> " << val + 1; } gpr_ref(&tcp->refcount); } @@ -181,7 +177,7 @@ static void on_read(void* tcpp, grpc_error_handle error) { grpc_winsocket_callback_info* info = &socket->read_info; if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "TCP:%p on_read", tcp); + LOG(INFO) << "TCP:" << tcp << " on_read"; } if (error.ok()) { @@ -213,7 +209,7 @@ static void on_read(void* tcpp, grpc_error_handle error) { } } else { if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "TCP:%p unref read_slice", tcp); + LOG(INFO) << "TCP:" << tcp << " unref read_slice"; } grpc_slice_buffer_reset_and_unref(tcp->read_slices); error = grpc_error_set_int( @@ -244,7 +240,7 @@ static void win_read(grpc_endpoint* ep, grpc_slice_buffer* read_slices, size_t i; if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "TCP:%p win_read", tcp); + LOG(INFO) << "TCP:" << tcp << " win_read"; } if (tcp->shutting_down) { @@ -315,7 +311,7 @@ static void on_write(void* tcpp, grpc_error_handle error) { grpc_closure* cb; if (GRPC_TRACE_FLAG_ENABLED(tcp)) { - gpr_log(GPR_INFO, "TCP:%p on_write", tcp); + LOG(INFO) << "TCP:" << tcp << " on_write"; } gpr_mu_lock(&tcp->mu); diff --git a/src/core/lib/iomgr/timer_manager.cc b/src/core/lib/iomgr/timer_manager.cc index 3e865b6ae0e..5136ad35d1a 100644 --- a/src/core/lib/iomgr/timer_manager.cc +++ b/src/core/lib/iomgr/timer_manager.cc @@ -24,7 +24,6 @@ #include "absl/log/log.h" #include -#include #include #include "src/core/lib/debug/trace.h" @@ -182,8 +181,7 @@ static bool wait_until(grpc_core::Timestamp next) { if (GRPC_TRACE_FLAG_ENABLED(timer_check)) { grpc_core::Duration wait_time = next - grpc_core::Timestamp::Now(); - gpr_log(GPR_INFO, "sleep for a %" PRId64 " milliseconds", - wait_time.millis()); + LOG(INFO) << "sleep for a " << wait_time.millis() << " milliseconds"; } } else { // g_timed_waiter == true && next >= g_timed_waiter_deadline next = grpc_core::Timestamp::InfFuture(); @@ -198,9 +196,9 @@ static bool wait_until(grpc_core::Timestamp next) { gpr_cv_wait(&g_cv_wait, &g_mu, next.as_timespec(GPR_CLOCK_MONOTONIC)); if (GRPC_TRACE_FLAG_ENABLED(timer_check)) { - gpr_log(GPR_INFO, "wait ended: was_timed:%d kicked:%d", - my_timed_waiter_generation == g_timed_waiter_generation, - g_kicked); + LOG(INFO) << "wait ended: was_timed:" + << (my_timed_waiter_generation == g_timed_waiter_generation) + << " kicked:" << g_kicked; } // if this was the timed waiter, then we need to check timers, and flag // that there's now no timed waiter... we'll look for a replacement if diff --git a/tools/run_tests/sanity/banned_functions.py b/tools/run_tests/sanity/banned_functions.py index 5828854ecd3..56baf9802fd 100755 --- a/tools/run_tests/sanity/banned_functions.py +++ b/tools/run_tests/sanity/banned_functions.py @@ -51,15 +51,6 @@ DEPRECATED_FUNCTION_TEMP_ALLOW_LIST = { "gpr_log_severity_string": [], "gpr_log(": [ "./include/grpc/support/log.h", - "./src/core/ext/filters/backend_metrics/backend_metric_filter.cc", - "./src/core/ext/filters/channel_idle/legacy_channel_idle_filter.cc", - "./src/core/ext/filters/fault_injection/fault_injection_filter.cc", - "./src/core/ext/filters/http/message_compress/compression_filter.cc", - "./src/core/ext/filters/http/server/http_server_filter.cc", - "./src/core/ext/filters/load_reporting/server_load_reporting_filter.cc", - "./src/core/ext/filters/logging/logging_filter.cc", - "./src/core/ext/filters/message_size/message_size_filter.cc", - "./src/core/ext/transport/binder/wire_format/wire_reader_impl.cc", "./src/core/ext/transport/chttp2/client/chttp2_connector.cc", "./src/core/ext/transport/chttp2/transport/bin_decoder.cc", "./src/core/ext/transport/chttp2/transport/flow_control.cc", @@ -78,15 +69,11 @@ DEPRECATED_FUNCTION_TEMP_ALLOW_LIST = { "./src/core/handshaker/http_connect/http_proxy_mapper.cc", "./src/core/lib/event_engine/ares_resolver.h", "./src/core/lib/gprpp/time.h", - "./src/core/lib/iomgr/call_combiner.cc", "./src/core/lib/iomgr/call_combiner.h", "./src/core/lib/iomgr/cfstream_handle.cc", "./src/core/lib/iomgr/closure.h", - "./src/core/lib/iomgr/combiner.cc", - "./src/core/lib/iomgr/endpoint_cfstream.cc", "./src/core/lib/iomgr/error.cc", "./src/core/lib/iomgr/ev_apple.cc", - "./src/core/lib/iomgr/ev_epoll1_linux.cc", "./src/core/lib/iomgr/ev_poll_posix.cc", "./src/core/lib/iomgr/ev_posix.cc", "./src/core/lib/iomgr/ev_posix.h", @@ -99,7 +86,6 @@ DEPRECATED_FUNCTION_TEMP_ALLOW_LIST = { "./src/core/lib/iomgr/tcp_client_cfstream.cc", "./src/core/lib/iomgr/tcp_client_posix.cc", "./src/core/lib/iomgr/tcp_windows.cc", - "./src/core/lib/iomgr/timer_generic.cc", "./src/core/lib/iomgr/timer_manager.cc", "./src/core/lib/promise/for_each.h", "./src/core/lib/promise/inter_activity_latch.h", @@ -109,23 +95,6 @@ DEPRECATED_FUNCTION_TEMP_ALLOW_LIST = { "./src/core/lib/promise/party.h", "./src/core/lib/promise/pipe.h", "./src/core/lib/surface/api_trace.h", - "./src/core/lib/surface/call.cc", - "./src/core/lib/surface/call_utils.cc", - "./src/core/lib/surface/channel_init.cc", - "./src/core/lib/surface/completion_queue.cc", - "./src/core/lib/surface/legacy_channel.cc", - "./src/core/lib/transport/bdp_estimator.cc", - "./src/core/lib/transport/bdp_estimator.h", - "./src/core/lib/transport/call_filters.cc", - "./src/core/lib/transport/connectivity_state.cc", - "./src/core/lib/transport/transport.h", - "./src/core/resolver/dns/c_ares/grpc_ares_wrapper.cc", - "./src/core/resolver/dns/c_ares/grpc_ares_wrapper.h", - "./src/core/resolver/dns/event_engine/event_engine_client_channel_resolver.cc", - "./src/core/resolver/dns/native/dns_resolver.cc", - "./src/core/resolver/xds/xds_resolver.cc", - "./src/core/server/server.cc", - "./src/core/server/xds_server_config_fetcher.cc", "./src/core/util/android/log.cc", "./src/core/util/linux/log.cc", "./src/core/util/posix/log.cc",