File tree Expand file tree Collapse file tree 5 files changed +15
-3
lines changed Expand file tree Collapse file tree 5 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -234,6 +234,7 @@ cc_library(
234234 linkopts = ABSL_DEFAULT_LINKOPTS ,
235235 deps = [
236236 "//absl/base:config" ,
237+ "//absl/base:core_headers" ,
237238 "//absl/log/internal:structured" ,
238239 "//absl/strings" ,
239240 ],
Original file line number Diff line number Diff line change @@ -665,6 +665,7 @@ absl_cc_library(
665665 ${ABSL_DEFAULT_LINKOPTS}
666666 DEPS
667667 absl::config
668+ absl::core_headers
668669 absl::log_internal_message
669670 absl::strings
670671)
@@ -680,6 +681,7 @@ absl_cc_library(
680681 ${ABSL_DEFAULT_LINKOPTS}
681682 DEPS
682683 absl::config
684+ absl::core_headers
683685 absl::log_internal_structured
684686 absl::strings
685687 PUBLIC
Original file line number Diff line number Diff line change @@ -281,6 +281,7 @@ cc_library(
281281 deps = [
282282 ":log_message" ,
283283 "//absl/base:config" ,
284+ "//absl/base:core_headers" ,
284285 "//absl/strings" ,
285286 ],
286287)
Original file line number Diff line number Diff line change 2222#include < ostream>
2323
2424#include " absl/base/config.h"
25+ #include " absl/base/attributes.h"
2526#include " absl/log/internal/log_message.h"
2627#include " absl/strings/string_view.h"
2728
@@ -31,14 +32,16 @@ namespace log_internal {
3132
3233class ABSL_MUST_USE_RESULT AsLiteralImpl final {
3334 public:
34- explicit AsLiteralImpl (absl::string_view str) : str_(str) {}
35+ explicit AsLiteralImpl (absl::string_view str ABSL_ATTRIBUTE_LIFETIME_BOUND)
36+ : str_(str) {}
3537 AsLiteralImpl (const AsLiteralImpl&) = default ;
3638 AsLiteralImpl& operator =(const AsLiteralImpl&) = default ;
3739
3840 private:
3941 absl::string_view str_;
4042
41- friend std::ostream& operator <<(std::ostream& os, AsLiteralImpl as_literal) {
43+ friend std::ostream& operator <<(std::ostream& os,
44+ AsLiteralImpl&& as_literal) {
4245 return os << as_literal.str_ ;
4346 }
4447 void AddToMessage (log_internal::LogMessage& m) {
Original file line number Diff line number Diff line change 3232
3333#include < ostream>
3434
35+ #include " absl/base/attributes.h"
3536#include " absl/base/config.h"
3637#include " absl/log/internal/structured.h"
3738#include " absl/strings/string_view.h"
@@ -60,7 +61,11 @@ ABSL_NAMESPACE_BEGIN
6061// int line) {
6162// LOG(LEVEL(severity)).AtLocation(file, line) << absl::LogAsLiteral(str);
6263// }
63- inline log_internal::AsLiteralImpl LogAsLiteral (absl::string_view s) {
64+ //
65+ // `LogAsLiteral` should only be used as a streaming operand and not, for
66+ // example, as a local variable initializer.
67+ inline log_internal::AsLiteralImpl LogAsLiteral (
68+ absl::string_view s ABSL_ATTRIBUTE_LIFETIME_BOUND) {
6469 return log_internal::AsLiteralImpl (s);
6570}
6671
You can’t perform that action at this time.
0 commit comments