avoid per-message logging overhead when not tracing
This closes
@@ -407,7 +407,13 @@ static qd_iterator_t *router_annotate_message(qd_router_t *router,
static void log_link_message(qd_connection_t *conn, pn_link_t *pn_link, qd_message_t *msg)
{
- if (!conn || !pn_link || !msg) return;
+ assert(conn && pn_link && msg);
+ qd_log_source_t *logger = qd_message_log_source();
+
+ // the message processing is expensive as this is done for every message received.
+ // Do not bother if not tracing.
+
+ if (qd_log_enabled(logger, QD_LOG_TRACE)) {
const qd_server_config_t *cf = qd_connection_config(conn);
if (!cf) return;
size_t repr_len = qd_message_repr_len();
@@ -418,7 +424,7 @@ static void log_link_message(qd_connection_t *conn, pn_link_t *pn_link, qd_messa
if (msg_str) {
const char *src = pn_terminus_get_address(pn_link_source(pn_link));
const char *tgt = pn_terminus_get_address(pn_link_target(pn_link));
- qd_log(qd_message_log_source(), QD_LOG_TRACE,
+ qd_log(logger, QD_LOG_TRACE,
"[C%"PRIu64"]: %s %s on link '%s' (%s -> %s)",
qd_connection_connection_id(conn),
pn_link_is_sender(pn_link) ? "Sent" : "Received",
@@ -429,6 +435,7 @@ static void log_link_message(qd_connection_t *conn, pn_link_t *pn_link, qd_messa
}
free(buf);
}
+}
/**
* Inbound Delivery Handler
