[#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)&period; This does not affect the text representation, only the structure&period;

== Synopsis

Declared in `&lt;absl&sol;log&sol;structured&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&sol;&ast; implementation-defined &ast;&sol;::AsLiteralImpl
LogAsLiteral(std::string&lowbar;view s);
----

== Description

Streaming `LogAsLiteral(s)` into a `std&colon;&colon;ostream` behaves just like streaming `s` directly&period;

Using `LogAsLiteral()` is occasionally appropriate and useful when proxying data logged from another system or another language&period; For example&colon;

void Logger&colon;&colon;LogString(absl&colon;&colon;string&lowbar;view str, absl&colon;&colon;LogSeverity severity, const char &ast;file, int line) &lcub; LOG(LEVEL(severity))&period;AtLocation(file, line) &lt;&lt; str&semi; &rcub; void Logger&colon;&colon;LogStringLiteral(absl&colon;&colon;string&lowbar;view str, absl&colon;&colon;LogSeverity severity, const char &ast;file, int line) &lcub; LOG(LEVEL(severity))&period;AtLocation(file, line) &lt;&lt; absl&colon;&colon;LogAsLiteral(str)&semi; &rcub;

`LogAsLiteral` should only be used as a streaming operand and not, for example, as a local variable initializer&period;

== Return Value

An object that streams `s` as a literal field&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *s*
| The string to annotate as a literal&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
