MINOR: flt_trace: Rename macros to print trace messages

Names of these macros may enter in conflict with the macros of the runtime
tracing mechanism. So the prefix "FLT_" has been added to avoid any ambiguities.
This commit is contained in:
Christopher Faulet 2019-11-04 11:35:42 +01:00
parent 276c1e0533
commit a3ed271ed4

View File

@ -43,12 +43,12 @@ struct trace_config {
int hexdump;
};
#define TRACE(conf, fmt, ...) \
#define FLT_TRACE(conf, fmt, ...) \
fprintf(stderr, "%d.%06d [%-20s] " fmt "\n", \
(int)now.tv_sec, (int)now.tv_usec, (conf)->name, \
##__VA_ARGS__)
#define STRM_TRACE(conf, strm, fmt, ...) \
#define FLT_STRM_TRACE(conf, strm, fmt, ...) \
fprintf(stderr, "%d.%06d [%-20s] [strm %p(%x) 0x%08x 0x%08x] " fmt "\n", \
(int)now.tv_sec, (int)now.tv_usec, (conf)->name, \
strm, (strm ? ((struct stream *)strm)->uniq_id : ~0U), \
@ -170,7 +170,7 @@ trace_init(struct proxy *px, struct flt_conf *fconf)
fconf->flags |= FLT_CFG_FL_HTX;
fconf->conf = conf;
TRACE(conf, "filter initialized [read random=%s - fwd random=%s - hexdump=%s]",
FLT_TRACE(conf, "filter initialized [read random=%s - fwd random=%s - hexdump=%s]",
(conf->rand_parsing ? "true" : "false"),
(conf->rand_forwarding ? "true" : "false"),
(conf->hexdump ? "true" : "false"));
@ -184,7 +184,7 @@ trace_deinit(struct proxy *px, struct flt_conf *fconf)
struct trace_config *conf = fconf->conf;
if (conf) {
TRACE(conf, "filter deinitialized");
FLT_TRACE(conf, "filter deinitialized");
free(conf->name);
free(conf);
}
@ -205,7 +205,7 @@ trace_init_per_thread(struct proxy *px, struct flt_conf *fconf)
{
struct trace_config *conf = fconf->conf;
TRACE(conf, "filter initialized for thread tid %u", tid);
FLT_TRACE(conf, "filter initialized for thread tid %u", tid);
return 0;
}
@ -216,7 +216,7 @@ trace_deinit_per_thread(struct proxy *px, struct flt_conf *fconf)
struct trace_config *conf = fconf->conf;
if (conf)
TRACE(conf, "filter deinitialized for thread tid %u", tid);
FLT_TRACE(conf, "filter deinitialized for thread tid %u", tid);
}
/**************************************************************************
@ -228,7 +228,7 @@ trace_attach(struct stream *s, struct filter *filter)
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s: filter-type=%s",
FLT_STRM_TRACE(conf, s, "%-25s: filter-type=%s",
__FUNCTION__, filter_type(filter));
return 1;
@ -241,7 +241,7 @@ trace_detach(struct stream *s, struct filter *filter)
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s: filter-type=%s",
FLT_STRM_TRACE(conf, s, "%-25s: filter-type=%s",
__FUNCTION__, filter_type(filter));
}
@ -251,7 +251,7 @@ trace_stream_start(struct stream *s, struct filter *filter)
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s",
FLT_STRM_TRACE(conf, s, "%-25s",
__FUNCTION__);
return 0;
}
@ -264,7 +264,7 @@ trace_stream_set_backend(struct stream *s, struct filter *filter,
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s: backend=%s",
FLT_STRM_TRACE(conf, s, "%-25s: backend=%s",
__FUNCTION__, be->id);
return 0;
}
@ -275,7 +275,7 @@ trace_stream_stop(struct stream *s, struct filter *filter)
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s",
FLT_STRM_TRACE(conf, s, "%-25s",
__FUNCTION__);
}
@ -285,7 +285,7 @@ trace_check_timeouts(struct stream *s, struct filter *filter)
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s",
FLT_STRM_TRACE(conf, s, "%-25s",
__FUNCTION__);
}
@ -299,7 +299,7 @@ trace_chn_start_analyze(struct stream *s, struct filter *filter,
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
__FUNCTION__,
channel_label(chn), proxy_mode(s), stream_pos(s));
filter->pre_analyzers |= (AN_REQ_ALL | AN_RES_ALL);
@ -375,7 +375,7 @@ trace_chn_analyze(struct stream *s, struct filter *filter,
ana = "unknown";
}
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
"analyzer=%s - step=%s",
__FUNCTION__,
channel_label(chn), proxy_mode(s), stream_pos(s),
@ -390,7 +390,7 @@ trace_chn_end_analyze(struct stream *s, struct filter *filter,
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
__FUNCTION__,
channel_label(chn), proxy_mode(s), stream_pos(s));
return 1;
@ -408,7 +408,7 @@ trace_http_headers(struct stream *s, struct filter *filter,
struct htx_sl *sl = http_get_stline(htx);
int32_t pos;
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)\t%.*s %.*s %.*s",
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)\t%.*s %.*s %.*s",
__FUNCTION__,
channel_label(msg->chn), proxy_mode(s), stream_pos(s),
HTX_SL_P1_LEN(sl), HTX_SL_P1_PTR(sl),
@ -427,7 +427,7 @@ trace_http_headers(struct stream *s, struct filter *filter,
n = htx_get_blk_name(htx, blk);
v = htx_get_blk_value(htx, blk);
STRM_TRACE(conf, s, "\t%.*s: %.*s",
FLT_STRM_TRACE(conf, s, "\t%.*s: %.*s",
(int)n.len, n.ptr, (int)v.len, v.ptr);
}
return 1;
@ -469,7 +469,7 @@ trace_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg
}
}
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
"offset=%u - len=%u - forward=%d",
__FUNCTION__,
channel_label(msg->chn), proxy_mode(s), stream_pos(s),
@ -489,7 +489,7 @@ trace_http_end(struct stream *s, struct filter *filter,
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
__FUNCTION__,
channel_label(msg->chn), proxy_mode(s), stream_pos(s));
return 1;
@ -501,7 +501,7 @@ trace_http_reset(struct stream *s, struct filter *filter,
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
__FUNCTION__,
channel_label(msg->chn), proxy_mode(s), stream_pos(s));
}
@ -512,7 +512,7 @@ trace_http_reply(struct stream *s, struct filter *filter, short status,
{
struct trace_config *conf = FLT_CONF(filter);
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
__FUNCTION__, "-", proxy_mode(s), stream_pos(s));
}
@ -529,7 +529,7 @@ trace_tcp_data(struct stream *s, struct filter *filter, struct channel *chn)
if (ret && conf->rand_parsing)
ret = random() % (ret+1);
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - next=%u - avail=%u - consume=%d",
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - next=%u - avail=%u - consume=%d",
__FUNCTION__,
channel_label(chn), proxy_mode(s), stream_pos(s),
FLT_NXT(filter, chn), avail, ret);
@ -549,7 +549,7 @@ trace_tcp_forward_data(struct stream *s, struct filter *filter, struct channel *
if (ret && conf->rand_forwarding)
ret = random() % (ret+1);
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - len=%u - fwd=%u - forward=%d",
FLT_STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - len=%u - fwd=%u - forward=%d",
__FUNCTION__,
channel_label(chn), proxy_mode(s), stream_pos(s), len,
FLT_FWD(filter, chn), ret);