A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/cpp/docs/reference/common/2.28.0/logging below:

C++ Client Libraries | Google Cloud

Stay organized with collections Save and categorize content based on your preferences.

Logging Components

An overview of logging in the Google Cloud C++ client libraries.

Introduction

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:

Enabling logs

The application needs to do two things to enable logging:

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.

Example: Logging From Library

Use the GCP_LOG() macro to log from a Google Cloud Platform C++ library:

void LibraryCode(ComplexThing const& thing) {
  GCP_LOG(INFO) << "I am here";
  if (thing.is_bad()) {
    GCP_LOG(ERROR) << "Poor thing is bad: " << thing;
  }
}
Example: Enable Logs to std::clog

To enable logs to std::clog the application can call:

void AppCode() {
  google::cloud::LogSink::EnableStdClog();
}

As previously noted, this can be switched at run-time using the GOOGLE_CLOUD_CPP_ENABLE_CLOG environment variable.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["This page provides documentation for logging in the Google Cloud C++ client libraries, emphasizing that logging is controlled by the application developer and does not occur by default."],["Logging can be enabled by adding a backend to the default `LogSink` and configuring which components to log, typically done using a `LoggingComponentsOption` when initializing the connection object."],["The `GOOGLE_CLOUD_CPP_ENABLE_CLOG` environment variable can be used to enable logging to `std::clog` at runtime, and the `GOOGLE_CLOUD_CPP_ENABLE_TRACING` variable enables tracing for specified components across all client objects."],["The `GCP_LOG()` macro is used within the Google Cloud Platform C++ libraries to emit log messages, and the logging framework is designed to be efficient, minimizing overhead when logs are disabled."],["The page shows the reference documentation for the logging component for each different versions of the Google Cloud C++ client libraries, ranging from version `2.10.1` to the latest release candidate `2.37.0-rc`."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4