Do not throw an `ApiException` when grpc logging does not work
When debugging grpc-related issues in a PHP client library, some common steps include adding the below lines to the php.ini file:
grpc.grpc_verbosity=debug
grpc.grpc_trace=all,-timer_check
grpc.log_filename=/var/log/grpc.log
However, if one accidentally forgets to initialize and make the grpc.log file writeable (e.g. running sudo chmod 666 /var/log/grpc.log), then when running any sample PHP code that uses grpc, you get this error:
PHP Fatal error: Uncaught Google\ApiCore\ApiException: {
"message": "failed to connect to all addresses",
"code": 14,
"status": "UNAVAILABLE",
"details": []
}
This is misleading as it suggests that the service one is trying to access in unavailable, when in actuality the only issue is that the grpc.log file is missing/unwriteable.
This error immediately goes away when the grpc.log file is initialized and writeable, or if grpc.log_filename is removed/commented out and the logs are written directly to stderr.
Ideally in this scenario, grpc emits a more descriptive message along the lines of Make sure the grpc.log file is initialized and writeable, and google-cloud-php does not throw an ApiException that could throw off users.
Related issue in grpc here: https://github.com/grpc/grpc/issues/27987
@alicejli looks like this one is blocked on getting changes into gRPC (grpc/grpc#27987). Can I assign to you to track through?