bneradt commented on code in PR #13018:
URL: https://github.com/apache/trafficserver/pull/13018#discussion_r3011432263
##########
src/proxy/logging/LogFormat.cc:
##########
@@ -55,6 +58,94 @@ DbgCtl dbg_ctl_log_format{"log-format"};
DbgCtl dbg_ctl_log_agg{"log-agg"};
DbgCtl dbg_ctl_log_slice{"log-slice"};
+char *
+trim_log_field_token(char *token)
+{
+ while (*token != '\0' && std::isspace(static_cast<unsigned char>(*token))) {
+ ++token;
+ }
+
+ size_t len = std::strlen(token);
+ while (len > 0 && std::isspace(static_cast<unsigned char>(token[len - 1]))) {
+ token[--len] = '\0';
+ }
+
+ return token;
+}
+
+bool
+parse_header_fallback_candidate(char *candidate, LogField::HeaderField &field,
const std::string &original_symbol)
+{
+ candidate = trim_log_field_token(candidate);
+ if (*candidate == '\0') {
+ Note("Invalid header fallback field specification: empty candidate in %s",
original_symbol.c_str());
+ return false;
+ }
+
+ if (*candidate != '{') {
+ Note("Invalid header fallback field specification: %s is not a header
field candidate in %s", candidate,
+ original_symbol.c_str());
+ return false;
+ }
+
+ char *name_end = std::strchr(candidate, '}');
+ if (name_end == nullptr) {
+ Note("Invalid header fallback field specification: no trailing '}' in %s",
original_symbol.c_str());
+ return false;
+ }
+
+ *name_end = '\0';
+ char *name = candidate + 1;
+ char *symbol = trim_log_field_token(name_end + 1);
+ LogSlice slice(symbol);
+
+ if (*name == '\0') {
+ Note("Invalid header fallback field specification: empty header name in
%s", original_symbol.c_str());
+ return false;
+ }
+
+ auto container = LogField::valid_container_name(symbol);
+ if (!LogField::isHeaderContainer(container)) {
+ Note("Invalid header fallback field specification: %s is not a supported
header container in %s", symbol,
+ original_symbol.c_str());
+ return false;
+ }
+
+ field.name = name;
+ field.container = container;
+ field.slice = slice;
+ return true;
+}
+
+LogField *
+parse_header_fallback_field(char *symbol)
+{
+ std::string original_symbol(symbol);
+ std::vector<LogField::HeaderField> header_fields;
+ char *candidate = symbol;
+
+ while (candidate != nullptr) {
Review Comment:
Yes! They can be chained n times:
```
%<{x-primary-id}cqh?:{x-secondary-id}cqh?:{x-tertiary-id}cqh>
```
There is, btw, a dev mailing list email about this if you want to chime in
there.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]