[#absl-LogAsLiteral] = xref:absl.adoc[absl]::LogAsLiteral :relfileprefix: ../ :mrdocs: Annotates its argument as a string literal so that structured logging captures it as a `literal` field instead of a `str` field (the default). This does not affect the text representation, only the structure. == Synopsis Declared in `<absl/log/structured.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- /* implementation-defined */::AsLiteralImpl LogAsLiteral(std::string_view s); ---- == Description Streaming `LogAsLiteral(s)` into a `std::ostream` behaves just like streaming `s` directly. Using `LogAsLiteral()` is occasionally appropriate and useful when proxying data logged from another system or another language. For example: void Logger::LogString(absl::string_view str, absl::LogSeverity severity, const char *file, int line) { LOG(LEVEL(severity)).AtLocation(file, line) << str; } void Logger::LogStringLiteral(absl::string_view str, absl::LogSeverity severity, const char *file, int line) { LOG(LEVEL(severity)).AtLocation(file, line) << absl::LogAsLiteral(str); } `LogAsLiteral` should only be used as a streaming operand and not, for example, as a local variable initializer. == Return Value An object that streams `s` as a literal field. == Parameters [cols="1,4"] |=== | Name| Description | *s* | The string to annotate as a literal. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#