}
if (curproxy->logformat_string)
- parse_logformat_string(curproxy->logformat_string, curproxy, &curproxy->logformat, LOG_OPT_MANDATORY);
+ parse_logformat_string(curproxy->logformat_string, curproxy, &curproxy->logformat, LOG_OPT_MANDATORY,
+ SMP_VAL_FE_LOG_END);
if (curproxy->uniqueid_format_string)
- parse_logformat_string(curproxy->uniqueid_format_string, curproxy, &curproxy->format_unique_id, 0);
+ parse_logformat_string(curproxy->uniqueid_format_string, curproxy, &curproxy->format_unique_id, 0,
+ (proxy->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR);
/* first, we will invert the servers list order */
newsrv = NULL;
* success. At the moment, sample converters are not yet supported but fetch arguments
* should work.
*/
-void add_sample_to_logformat_list(char *text, char *arg, int arg_len, struct proxy *curpx, struct list *list_format, int options)
+void add_sample_to_logformat_list(char *text, char *arg, int arg_len, struct proxy *curpx, struct list *list_format, int options, int cap)
{
char *cmd[2];
struct sample_expr *expr;
node->arg = my_strndup(arg, arg_len);
parse_logformat_var_args(node->arg, node);
}
- if (expr->fetch->val & SMP_VAL_REQUEST)
+ if (expr->fetch->val & cap & SMP_VAL_REQUEST)
node->options |= LOG_OPT_REQ_CAP; /* fetch method is request-compatible */
- if (expr->fetch->val & SMP_VAL_RESPONSE)
+ if (expr->fetch->val & cap & SMP_VAL_RESPONSE)
node->options |= LOG_OPT_RES_CAP; /* fetch method is response-compatible */
+ if (!(expr->fetch->val & cap))
+ Warning("log-format: sample fetch <%s> may not be reliably used %s because it needs '%s' which is not available here.\n",
+ text, cap == SMP_VAL_FE_LOG_END ? "with 'log-format'" : "here", sample_src_names(expr->fetch->use));
+
/* check if we need to allocate an hdr_idx struct for HTTP parsing */
/* Note, we may also need to set curpx->to_log with certain fetches */
if (expr->fetch->use & SMP_USE_HTTP_ANY)
* curproxy: the proxy affected
* list_format: the destination list
* options: LOG_OPT_* to force on every node
+ * cap: all SMP_VAL_* flags supported by the consumer
*/
-void parse_logformat_string(const char *fmt, struct proxy *curproxy, struct list *list_format, int options)
+void parse_logformat_string(const char *fmt, struct proxy *curproxy, struct list *list_format, int options, int cap)
{
char *sp, *str, *backfmt; /* start pointer for text parts */
char *arg = NULL; /* start pointer for args */
parse_logformat_var(arg, arg_len, var, var_len, curproxy, list_format, &options);
break;
case LF_STEXPR:
- add_sample_to_logformat_list(var, arg, arg_len, curproxy, list_format, options);
+ add_sample_to_logformat_list(var, arg, arg_len, curproxy, list_format, options, cap);
break;
case LF_TEXT:
case LF_SEPARATOR:
rule->arg.hdr_add.name = strdup(args[cur_arg]);
rule->arg.hdr_add.name_len = strlen(rule->arg.hdr_add.name);
LIST_INIT(&rule->arg.hdr_add.fmt);
- parse_logformat_string(args[cur_arg + 1], proxy, &rule->arg.hdr_add.fmt, 0);
+ parse_logformat_string(args[cur_arg + 1], proxy, &rule->arg.hdr_add.fmt, 0,
+ (proxy->cap & PR_CAP_FE) ? SMP_VAL_FE_HRQ_HDR : SMP_VAL_BE_HRQ_HDR);
cur_arg += 2;
} else if (strcmp(args[0], "redirect") == 0) {
struct redirect_rule *redir;