diff options
Diffstat (limited to 'src/zenserver/sessions/logtemplate.h')
| -rw-r--r-- | src/zenserver/sessions/logtemplate.h | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/zenserver/sessions/logtemplate.h b/src/zenserver/sessions/logtemplate.h new file mode 100644 index 000000000..e8b07e63d --- /dev/null +++ b/src/zenserver/sessions/logtemplate.h @@ -0,0 +1,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 |