blob: e8b07e63dda9b33da45c225362d78134d9372a14 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include <zencore/compactbinary.h>
#include <zencore/string.h>
#include <string_view>
namespace zen {
/// Render a UE structured-log template (as produced by UE_LOGFMT) against a
/// fields bag, writing the result into a caller-provided builder. Grammar:
///
/// format := (text | escape | placeholder)*
/// escape := '{{' | '}}' (non-localized, default)
/// | '`{' | '`}' | '``' (localized, $locformat)
/// placeholder := '{' field_path '}'
/// field_path := name ('.' name | '[' digits ']')*
/// name := [A-Za-z0-9] [A-Za-z0-9_]* (leading '_' reserved)
///
/// There are NO inline format specs — `{Name:spec}` is not part of the
/// grammar. Formatting control lives on the value side via nested
/// objects carrying `$text` / `$format` / `$locformat` (see the value-
/// rendering rules in logtemplate.cpp).
///
/// Missing paths render as empty (UE asserts these at emit time, so in
/// practice they don't occur; the empty-render is defensive). Unknown
/// primitive CbField types render as empty.
///
/// Typical use: pass an `ExtendableStringBuilder<256>` so typical messages
/// render on the stack with no heap allocation. The builder is appended to,
/// not cleared, so callers can compose multiple writes if they want.
///
/// @param Template The format string.
/// @param Fields The top-level fields bag referenced by placeholders.
/// @param Out Builder to append the rendered text to.
/// @param Localized True for $locformat templates (backtick escapes);
/// false (default) for the top-level `format` field.
void RenderLogTemplate(std::string_view Template, CbObjectView Fields, StringBuilderBase& Out, bool Localized = false);
} // namespace zen
|