abseil-cpp/absl/status/status_payload_printer.h
Go to the documentation of this file.
1 // Copyright 2019 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 #ifndef ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_
15 #define ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_
16 
17 #include <string>
18 
19 #include "absl/strings/cord.h"
20 #include "absl/strings/string_view.h"
21 #include "absl/types/optional.h"
22 
23 namespace absl {
25 namespace status_internal {
26 
27 // By default, `Status::ToString` and `operator<<(Status)` print a payload by
28 // dumping the type URL and the raw bytes. To help debugging, we provide an
29 // extension point, which is a global printer function that can be set by users
30 // to specify how to print payloads. The function takes the type URL and the
31 // payload as input, and should return a valid human-readable string on success
32 // or `absl::nullopt` on failure (in which case it falls back to the default
33 // approach of printing the raw bytes).
34 // NOTE: This is an internal API and the design is subject to change in the
35 // future in a non-backward-compatible way. Since it's only meant for debugging
36 // purpose, you should not rely on it in any critical logic.
38  const absl::Cord&);
39 
40 // Sets the global payload printer. Only one printer should be set per process.
41 // If multiple printers are set, it's undefined which one will be used.
43 
44 // Returns the global payload printer if previously set, otherwise `nullptr`.
46 
47 } // namespace status_internal
49 } // namespace absl
50 
51 #endif // ABSL_STATUS_STATUS_PAYLOAD_PRINTER_H_
absl::Cord
Definition: abseil-cpp/absl/strings/cord.h:150
absl::status_internal::GetStatusPayloadPrinter
StatusPayloadPrinter GetStatusPayloadPrinter()
Definition: abseil-cpp/absl/status/status_payload_printer.cc:32
ABSL_NAMESPACE_END
#define ABSL_NAMESPACE_END
Definition: third_party/abseil-cpp/absl/base/config.h:171
ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
Definition: third_party/abseil-cpp/absl/base/config.h:170
absl::optional< std::string >
absl::status_internal::StatusPayloadPrinter
absl::optional< std::string >(*)(absl::string_view, const absl::Cord &) StatusPayloadPrinter
Definition: abseil-cpp/absl/status/status_payload_printer.h:38
string_view
absl::string_view string_view
Definition: attr.cc:22
absl
Definition: abseil-cpp/absl/algorithm/algorithm.h:31
absl::status_internal::SetStatusPayloadPrinter
void SetStatusPayloadPrinter(StatusPayloadPrinter printer)
Definition: abseil-cpp/absl/status/status_payload_printer.cc:28


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:17