Skip to content

Commit

Permalink
formatter: deprecate legacy formatter early for E-M
Browse files Browse the repository at this point in the history
Signed-off-by: Alyssa Wilk <[email protected]>
  • Loading branch information
alyssawilk committed Oct 14, 2024
1 parent 004401b commit 327d181
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions source/common/formatter/substitution_format_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,15 @@ class SubstitutionFormatStringUtils {
bool omit_empty_values, bool sort_properties,
const std::vector<CommandParserBasePtr<FormatterContext>>& commands = {}) {

// TODO(alyssawilk, wbpcode when deprecating logging_with_fast_json_formatter
// remove LegacyJsonFormatterBaseImpl and StructFormatterBase
#ifdef ENVOY_DISABLE_EXCEPTIONS
if (!Runtime::runtimeFeatureEnabled(
"envoy.reloadable_features.logging_with_fast_json_formatter")) {
return std::make_unique<LegacyJsonFormatterBaseImpl<FormatterContext>>(
struct_format, preserve_types, omit_empty_values, sort_properties, commands);
}
#endif

return std::make_unique<JsonFormatterImplBase<FormatterContext>>(struct_format,
omit_empty_values, commands);
Expand Down
8 changes: 5 additions & 3 deletions source/common/formatter/substitution_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ using JsonFormatterImpl = JsonFormatterImplBase<HttpFormatterContext>;
template <class... Ts> struct StructFormatMapVisitorHelper : Ts... { using Ts::operator()...; };
template <class... Ts> StructFormatMapVisitorHelper(Ts...) -> StructFormatMapVisitorHelper<Ts...>;

#ifdef ENVOY_DISABLE_EXCEPTIONS
/**
* An formatter for structured log formats, which returns a Struct proto that
* can be converted easily into multiple formats.
Expand Down Expand Up @@ -616,7 +617,7 @@ template <class FormatterContext> class StructFormatterBase {
output->emplace(pair.first, toFormatNumberValue(pair.second.number_value()));
break;
default:
throwEnvoyExceptionOrPanic(
throw EnvoyException(
"Only string values, nested structs, list values and number values are "
"supported in structured access log format.");
}
Expand Down Expand Up @@ -647,7 +648,7 @@ template <class FormatterContext> class StructFormatterBase {
break;

default:
throwEnvoyExceptionOrPanic(
throw EnvoyException(
"Only string values, nested structs, list values and number values are "
"supported in structured access log format.");
}
Expand Down Expand Up @@ -764,10 +765,11 @@ class LegacyJsonFormatterBaseImpl : public FormatterBase<FormatterContext> {

using StructFormatter = StructFormatterBase<HttpFormatterContext>;
using StructFormatterPtr = std::unique_ptr<StructFormatter>;
using LegacyJsonFormatterImpl = LegacyJsonFormatterBaseImpl<HttpFormatterContext>;
#endif // ENVOY_DISABLE_EXCEPTIONS

// Aliases for backwards compatibility.
using FormatterImpl = FormatterBaseImpl<HttpFormatterContext>;
using LegacyJsonFormatterImpl = LegacyJsonFormatterBaseImpl<HttpFormatterContext>;

} // namespace Formatter
} // namespace Envoy

0 comments on commit 327d181

Please sign in to comment.