Google Cloud C++ Client 2.10.1
C++ Client Library for Google Cloud Platform
|
An overview of logging in the Google Cloud C++ client libraries.
The client libraries never use logging to report errors, but logging can be enabled to help troubleshoot problems when the last error message does not provide a good enough indication of the root cause.
In general, we abide by the following principles:
std::clog
immediately before a GCP_LOG(FATAL)
terminates the process.#ifdef
/#endif
directives around them.if()
statement. At the very least it should not incur additional memory allocations or locks.The application needs to do two things to enable logging:
*Connection
object with a TracingComponentsOption. Consult the documentation for each *Client
class to find what tracing components are available.At run-time, setting the GOOGLE_CLOUD_CPP_ENABLE_CLOG
to a non-empty value configures a LogBackend that uses std::clog
. Likewise, setting the GOOGLE_CLOUD_CPP_ENABLE_TRACING=a,b
will enable tracing for components a
and b
across all client objects. The most common components are auth
, rpc
, and rpc-streams
.
Note that while std::clog
is buffered, the framework will flush any log message at severity WARNING
or higher.
Use the GCP_LOG()
macro to log from a Google Cloud Platform C++ library:
To enable logs to std::clog
the application can call:
As previously noted, this can be switched at run-time using the GOOGLE_CLOUD_CPP_ENABLE_CLOG
environment variable.