mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-12-08 11:11:01 +01:00
MINOR: log: add do_log_parse_act() helper func
Function may be used from places where per-context actions are usually registered (tcp_act.c, http_act.c, quic_rules.c.. to name a few) in order to expose the do_log() action.
This commit is contained in:
parent
e63c7da508
commit
0e271f1d2a
@ -105,6 +105,13 @@ static inline int sess_build_logline(struct session *sess, struct stream *s, cha
|
|||||||
log_orig(LOG_ORIG_UNSPEC, LOG_ORIG_FL_NONE));
|
log_orig(LOG_ORIG_UNSPEC, LOG_ORIG_FL_NONE));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Parse a "do_log" action. It doesn't take any argument
|
||||||
|
* May be used from places where per-context actions are usually registered
|
||||||
|
*/
|
||||||
|
enum act_parse_ret do_log_parse_act(enum log_orig_id id,
|
||||||
|
const char **args, int *orig_arg, struct proxy *px,
|
||||||
|
struct act_rule *rule, char **err);
|
||||||
|
|
||||||
/* opportunistic log when session already exists (<s> may be null) */
|
/* opportunistic log when session already exists (<s> may be null) */
|
||||||
void do_log(struct session *sess, struct stream *s, struct log_orig origin);
|
void do_log(struct session *sess, struct stream *s, struct log_orig origin);
|
||||||
|
|
||||||
|
|||||||
30
src/log.c
30
src/log.c
@ -6781,6 +6781,36 @@ static int px_parse_log_steps(char **args, int section_type, struct proxy *curpx
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* needed by do_log_parse_act() */
|
||||||
|
static enum act_return do_log_action(struct act_rule *rule, struct proxy *px,
|
||||||
|
struct session *sess, struct stream *s, int flags)
|
||||||
|
{
|
||||||
|
/* do_log() expects valid session pointer */
|
||||||
|
BUG_ON(sess == NULL);
|
||||||
|
|
||||||
|
do_log(sess, s, log_orig(rule->arg.expr_int.value, LOG_ORIG_FL_NONE));
|
||||||
|
return ACT_RET_CONT;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Parse a "do_log" action. It doesn't take any argument
|
||||||
|
* May be used from places where per-context actions are usually registered
|
||||||
|
*/
|
||||||
|
enum act_parse_ret do_log_parse_act(enum log_orig_id id,
|
||||||
|
const char **args, int *orig_arg, struct proxy *px,
|
||||||
|
struct act_rule *rule, char **err)
|
||||||
|
{
|
||||||
|
if (*args[*orig_arg]) {
|
||||||
|
memprintf(err, "doesn't expects any argument");
|
||||||
|
return ACT_RET_PRS_ERR;
|
||||||
|
}
|
||||||
|
|
||||||
|
rule->action_ptr = do_log_action;
|
||||||
|
rule->action = ACT_CUSTOM;
|
||||||
|
rule->release_ptr = NULL;
|
||||||
|
rule->arg.expr_int.value = id;
|
||||||
|
return ACT_RET_PRS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
static struct cfg_kw_list cfg_kws_li = {ILH, {
|
static struct cfg_kw_list cfg_kws_li = {ILH, {
|
||||||
{ CFG_LISTEN, "log-steps", px_parse_log_steps },
|
{ CFG_LISTEN, "log-steps", px_parse_log_steps },
|
||||||
{ 0, NULL, NULL },
|
{ 0, NULL, NULL },
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user