@@ -99,7 +99,7 @@ std::string JsonFormatterImpl::format(const Http::HeaderMap& request_headers,
99
99
const auto output_struct =
100
100
toStruct (request_headers, response_headers, response_trailers, stream_info);
101
101
102
- std::string log_line = MessageUtil::getJsonStringFromMessage (output_struct, false , true );
102
+ const std::string log_line = MessageUtil::getJsonStringFromMessage (output_struct, false , true );
103
103
return absl::StrCat (log_line, " \n " );
104
104
}
105
105
@@ -115,11 +115,11 @@ ProtobufWkt::Struct JsonFormatterImpl::toStruct(const Http::HeaderMap& request_h
115
115
116
116
if (providers.size () == 1 ) {
117
117
const auto & provider = providers.front ();
118
- auto val = preserve_types_
119
- ? provider->formatValue (request_headers, response_headers, response_trailers ,
120
- stream_info)
121
- : ValueUtil::stringValue (provider->format (request_headers, response_headers,
122
- response_trailers, stream_info));
118
+ const auto val =
119
+ preserve_types_ ? provider->formatValue (request_headers, response_headers,
120
+ response_trailers, stream_info)
121
+ : ValueUtil::stringValue (provider->format (
122
+ request_headers, response_headers, response_trailers, stream_info));
123
123
124
124
(*fields)[pair.first ] = val;
125
125
} else {
@@ -144,7 +144,7 @@ void AccessLogFormatParser::parseCommandHeader(const std::string& token, const s
144
144
throw EnvoyException (
145
145
// Header format rules support only one alternative header.
146
146
// docs/root/configuration/access_log.rst#format-rules
147
- fmt::format (" More than 1 alternative header specified in token: {} " , token));
147
+ absl::StrCat (" More than 1 alternative header specified in token: " , token));
148
148
}
149
149
if (subs.size () == 1 ) {
150
150
alternative_header = subs.front ();
@@ -163,24 +163,24 @@ void AccessLogFormatParser::parseCommand(const std::string& token, const size_t
163
163
std::vector<std::string>& sub_items,
164
164
absl::optional<size_t >& max_length) {
165
165
// TODO(dnoe): Convert this to use string_view throughout.
166
- size_t end_request = token.find (' )' , start);
166
+ const size_t end_request = token.find (' )' , start);
167
167
sub_items.clear ();
168
168
if (end_request != token.length () - 1 ) {
169
169
// Closing bracket is not found.
170
170
if (end_request == std::string::npos) {
171
- throw EnvoyException (fmt::format (" Closing bracket is missing in token: {} " , token));
171
+ throw EnvoyException (absl::StrCat (" Closing bracket is missing in token: " , token));
172
172
}
173
173
174
174
// Closing bracket should be either last one or followed by ':' to denote limitation.
175
175
if (token[end_request + 1 ] != ' :' ) {
176
- throw EnvoyException (fmt::format (" Incorrect position of ')' in token: {} " , token));
176
+ throw EnvoyException (absl::StrCat (" Incorrect position of ')' in token: " , token));
177
177
}
178
178
179
179
const auto length_str = absl::string_view (token).substr (end_request + 2 );
180
180
uint64_t length_value;
181
181
182
182
if (!absl::SimpleAtoi (length_str, &length_value)) {
183
- throw EnvoyException (fmt::format (" Length must be an integer, given: {} " , length_str));
183
+ throw EnvoyException (absl::StrCat (" Length must be an integer, given: " , length_str));
184
184
}
185
185
186
186
max_length = length_value;
@@ -218,7 +218,7 @@ std::vector<FormatterProviderPtr> AccessLogFormatParser::parse(const std::string
218
218
}
219
219
220
220
std::smatch m;
221
- std::string search_space = format.substr (pos);
221
+ const std::string search_space = format.substr (pos);
222
222
if (!(std::regex_search (search_space, m, command_w_args_regex) || m.position () == 0 )) {
223
223
throw EnvoyException (
224
224
fmt::format (" Incorrect configuration: {}. Couldn't find valid command at position {}" ,
@@ -228,7 +228,7 @@ std::vector<FormatterProviderPtr> AccessLogFormatParser::parse(const std::string
228
228
const std::string match = m.str (0 );
229
229
const std::string token = match.substr (1 , match.length () - 2 );
230
230
pos += 1 ;
231
- int command_end_position = pos + token.length ();
231
+ const int command_end_position = pos + token.length ();
232
232
233
233
if (absl::StartsWith (token, " REQ(" )) {
234
234
std::string main_header, alternative_header;
@@ -332,15 +332,15 @@ class StreamInfoOptionalStringFieldExtractor : public StreamInfoFormatter::Field
332
332
333
333
// StreamInfoFormatter::FieldExtractor
334
334
std::string extract (const StreamInfo::StreamInfo& stream_info) const override {
335
- auto str = field_extractor_ (stream_info);
335
+ const auto str = field_extractor_ (stream_info);
336
336
if (!str) {
337
337
return UnspecifiedValueString;
338
338
}
339
339
340
340
return str.value ();
341
341
}
342
342
ProtobufWkt::Value extractValue (const StreamInfo::StreamInfo& stream_info) const override {
343
- auto str = field_extractor_ (stream_info);
343
+ const auto str = field_extractor_ (stream_info);
344
344
if (!str) {
345
345
return unspecifiedValue ();
346
346
}
@@ -362,15 +362,15 @@ class StreamInfoDurationFieldExtractor : public StreamInfoFormatter::FieldExtrac
362
362
363
363
// StreamInfoFormatter::FieldExtractor
364
364
std::string extract (const StreamInfo::StreamInfo& stream_info) const override {
365
- auto millis = extractMillis (stream_info);
365
+ const auto millis = extractMillis (stream_info);
366
366
if (!millis) {
367
367
return UnspecifiedValueString;
368
368
}
369
369
370
370
return fmt::format_int (millis.value ()).str ();
371
371
}
372
372
ProtobufWkt::Value extractValue (const StreamInfo::StreamInfo& stream_info) const override {
373
- auto millis = extractMillis (stream_info);
373
+ const auto millis = extractMillis (stream_info);
374
374
if (!millis) {
375
375
return unspecifiedValue ();
376
376
}
@@ -380,7 +380,7 @@ class StreamInfoDurationFieldExtractor : public StreamInfoFormatter::FieldExtrac
380
380
381
381
private:
382
382
absl::optional<uint32_t > extractMillis (const StreamInfo::StreamInfo& stream_info) const {
383
- auto time = field_extractor_ (stream_info);
383
+ const auto time = field_extractor_ (stream_info);
384
384
if (time ) {
385
385
return std::chrono::duration_cast<std::chrono::milliseconds>(time .value ()).count ();
386
386
}
0 commit comments