Skip to content

Commit

Permalink
fix incorrect trace log (#287)
Browse files Browse the repository at this point in the history
* fix incorrect trace log
* normalize log output
  • Loading branch information
ekoby authored Jun 15, 2021
1 parent ca84fd8 commit 2a3dc3c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions library/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ static void close_handle_cb(uv_handle_t *h) {
int ziti_channel_close(ziti_channel_t *ch) {
int r = 0;
if (ch->state != Closed) {
CH_LOG(INFO, "closing", ch->id, ch->name);
CH_LOG(INFO, "closing(%s)", ch->name);
r = uv_mbed_close(&ch->connection, close_handle_cb);
uv_timer_stop(&ch->timer);
uv_close((uv_handle_t *) &ch->timer, NULL);
Expand Down Expand Up @@ -361,7 +361,7 @@ ziti_channel_send_for_reply(ziti_channel_t *ch, uint32_t content, const hdr_t *h
header_t header;
header_init(&header, ch->msg_seq++);

CH_LOG(TRACE, "=> ct[%04X] seq[%d] len[%d]", ch->id, content, header.seq, body_len);
CH_LOG(TRACE, "=> ct[%04X] seq[%d] len[%d]", content, header.seq, body_len);
header.content = content;
header.body_len = body_len;

Expand Down Expand Up @@ -456,7 +456,7 @@ static void dispatch_message(ziti_channel_t *ch, message *m) {
return;
}

CH_LOG(ERROR, "could not find waiter for reply_to = %d", ch->id, reply_to);
CH_LOG(ERROR, "could not find waiter for reply_to = %d", reply_to);
}

if (ch->state == Connecting) {
Expand Down Expand Up @@ -542,7 +542,7 @@ static void process_inbound(ziti_channel_t *ch) {
ch->in_body_offset += len;

if (ch->in_body_offset == total) {
CH_LOG(TRACE, "message is complete seq[%d] ct[%X]", ch->in_next->header.seq,
CH_LOG(TRACE, "message is complete seq[%d] ct[%04X]", ch->in_next->header.seq,
ch->in_next->header.content);

dispatch_message(ch, ch->in_next);
Expand Down Expand Up @@ -667,7 +667,7 @@ static void send_hello(ziti_channel_t *ch, ziti_session *session) {

static void connect_timeout(uv_timer_t *t) {
ziti_channel_t *ch = t->data;
CH_LOG(ERROR, "connect timeout", ch->id);
CH_LOG(ERROR, "connect timeout");
ch->state = Disconnected;
if (ch->connection.conn_req == NULL) {
// diagnostics
Expand Down
7 changes: 4 additions & 3 deletions library/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ int establish_crypto(ziti_connection conn, message *msg) {
return ZITI_CRYPTO_FAIL;
}
else {
CONN_LOG(VERBOSE, "encryption not set up: peer_key_sent[%d] conn->encrypted[%d]", (int)peer_key_sent, (int)conn->encrypted);
// service is not required to be encrypted and hosting side did not send the key
return ZITI_OK;
}
Expand Down Expand Up @@ -1096,7 +1097,7 @@ static void rebind_cb(ziti_connection conn, int status) {
int backoff_count = 1 << MIN(conn->conn_req->retry_count, 5);
uint32_t random;
uv_random(conn->ziti_ctx->loop, NULL, &random, sizeof(random), 0, NULL);
long backoff_time = random % (backoff_count * 5000);
long backoff_time = (long)(random % (backoff_count * 5000));
CONN_LOG(DEBUG, "failed to re-bind[%d/%s], retrying in %ldms", status, ziti_errorstr(status), backoff_time);
if (conn->conn_req->conn_timeout == NULL) {
conn->conn_req->conn_timeout = calloc(1, sizeof(uv_timer_t));
Expand Down Expand Up @@ -1266,7 +1267,7 @@ static void process_edge_message(struct ziti_conn *conn, message *msg, int code)
conn->data_cb(conn, NULL, code);
break;
default:
CONN_LOG(WARN, "disconnecting from state[%d]", conn->conn_id, st);
CONN_LOG(WARN, "disconnecting from state[%d]", st);
}
ziti_channel_rem_receiver(conn->channel, conn->conn_id);
conn->channel = NULL;
Expand All @@ -1278,7 +1279,7 @@ static void process_edge_message(struct ziti_conn *conn, message *msg, int code)
bool has_seq = message_get_int32_header(msg, SeqHeader, &seq);
bool has_conn_id = message_get_int32_header(msg, ConnIdHeader, &conn_id);

CONN_LOG(TRACE, "<= ct[%X] edge_seq[%d] body[%d]", msg->header.content, seq, msg->header.body_len);
CONN_LOG(TRACE, "<= ct[%04X] edge_seq[%d] body[%d]", msg->header.content, seq, msg->header.body_len);

switch (msg->header.content) {
case ContentTypeStateClosed:
Expand Down

0 comments on commit 2a3dc3c

Please sign in to comment.