Skip to content

Commit d205659

Browse files
committed
Improve debug message display
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 25e8374 commit d205659

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

mqttclient/mqttclient.c

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
static void default_msg_handler(void* client, message_data_t* msg)
1414
{
15-
MQTT_LOG_I("mqtt-client:%d %s()...\ntopic: %s, qos: %d, \nmessage:%s", __LINE__, __FUNCTION__,
15+
MQTT_LOG_I("mqtt-client:%d %s() -\ntopic: %s, qos: %d, \nmessage:%s", __LINE__, __FUNCTION__,
1616
msg->topic_name, msg->message->qos, (char*)msg->message->payload);
1717
}
1818

@@ -352,7 +352,7 @@ static void mqtt_ack_handler_resend(mqtt_client_t* c, ack_handlers_t* ack_handle
352352

353353
mqtt_send_packet(c, ack_handler->payload_len, &timer); /* resend data */
354354
platform_mutex_unlock(&c->mqtt_write_lock);
355-
MQTT_LOG_W("mqtt-client:%d %s()... resend %d package, packet_id is %d ", __LINE__, __FUNCTION__, ack_handler->type, ack_handler->packet_id);
355+
MQTT_LOG_W("mqtt-client:%d %s() - resend %d package, packet_id is %d ", __LINE__, __FUNCTION__, ack_handler->type, ack_handler->packet_id);
356356
}
357357

358358
static int mqtt_ack_list_node_is_exist(mqtt_client_t* c, int type, uint16_t packet_id)
@@ -460,7 +460,7 @@ static int mqtt_msg_handler_is_exist(mqtt_client_t* c, message_handlers_t *handl
460460

461461
/* determine whether a node already exists by mqtt topic, but wildcards are not supported */
462462
if ((NULL != msg_handler->topic_filter) && (mqtt_is_topic_equals(msg_handler->topic_filter, handler->topic_filter))) {
463-
MQTT_LOG_W("mqtt-client:%d %s()...msg_handler->topic_filter: %s, handler->topic_filter: %s",
463+
MQTT_LOG_W("mqtt-client:%d %s() -msg_handler->topic_filter: %s, handler->topic_filter: %s",
464464
__LINE__, __FUNCTION__, msg_handler->topic_filter, handler->topic_filter);
465465
return 1;
466466
}
@@ -569,7 +569,7 @@ static int mqtt_try_resubscribe(mqtt_client_t* c)
569569
mqtt_list_t *curr, *next;
570570
message_handlers_t *msg_handler;
571571

572-
MQTT_LOG_W("mqtt-client:%d %s()... mqtt try resubscribe ...", __LINE__, __FUNCTION__);
572+
MQTT_LOG_W("mqtt-client:%d %s() - mqtt try resubscribe ", __LINE__, __FUNCTION__);
573573

574574
if (mqtt_list_is_empty(&c->mqtt_msg_handler_list)) {
575575
// MQTT_LOG_D("mqtt-client:%d %s() mqtt_msg_handler_list is empty", __LINE__, __FUNCTION__);
@@ -581,7 +581,7 @@ static int mqtt_try_resubscribe(mqtt_client_t* c)
581581

582582
/* resubscribe topic */
583583
if ((rc = mqtt_subscribe(c, msg_handler->topic_filter, msg_handler->qos, msg_handler->handler)) == MQTT_ACK_HANDLER_NUM_TOO_MUCH_ERROR)
584-
MQTT_LOG_W("mqtt-client:%d %s()... mqtt ack handler num too much ...", __LINE__, __FUNCTION__);
584+
MQTT_LOG_W("mqtt-client:%d %s() - mqtt ack handler num too much ", __LINE__, __FUNCTION__);
585585

586586
}
587587

@@ -601,7 +601,7 @@ static int mqtt_try_do_reconnect(mqtt_client_t* c)
601601
mqtt_ack_list_scan(c, 0);
602602
}
603603

604-
MQTT_LOG_D("mqtt-client:%d %s()... mqtt try connect result is -0x%04x", __LINE__, __FUNCTION__, -rc);
604+
MQTT_LOG_D("mqtt-client:%d %s() - mqtt try connect result is -0x%04x", __LINE__, __FUNCTION__, -rc);
605605

606606
RETURN_ERROR(rc);
607607
}
@@ -711,7 +711,7 @@ static int mqtt_suback_packet_handle(mqtt_client_t *c, platform_timer_t *timer)
711711

712712
if (is_nack) {
713713
mqtt_msg_handler_destory(msg_handler); /* subscribe topic failed, destory message handler */
714-
MQTT_LOG_D("subscribe topic failed...");
714+
MQTT_LOG_D("subscribe topic failed");
715715
RETURN_ERROR(MQTT_SUBSCRIBE_NOT_ACK_ERROR);
716716
}
717717

@@ -919,7 +919,7 @@ static int mqtt_yield(mqtt_client_t* c, int timeout_ms)
919919
mqtt_ack_list_scan(c, 1);
920920

921921
} else if (MQTT_NOT_CONNECT_ERROR == rc) {
922-
MQTT_LOG_E("mqtt-client:%d %s()... mqtt not connect", __LINE__, __FUNCTION__);
922+
MQTT_LOG_E("mqtt-client:%d %s() - mqtt not connect", __LINE__, __FUNCTION__);
923923
} else {
924924
break;
925925
}
@@ -937,19 +937,19 @@ static void mqtt_yield_thread(void *arg)
937937

938938
state = mqtt_get_client_state(c);
939939
if (CLIENT_STATE_CONNECTED != state) {
940-
MQTT_LOG_W("mqtt-client:%d %s()..., mqtt is not connected to the server...", __LINE__, __FUNCTION__);
940+
MQTT_LOG_W("mqtt-client:%d %s() -, mqtt is not connected to the server", __LINE__, __FUNCTION__);
941941
platform_thread_stop(c->mqtt_thread); /* mqtt is not connected to the server, stop thread */
942942
}
943943

944944
while (1) {
945945
rc = mqtt_yield(c, c->mqtt_cmd_timeout);
946946
if (MQTT_CLEAN_SESSION_ERROR == rc) {
947-
MQTT_LOG_W("mqtt-client:%d %s()..., mqtt clean session....", __LINE__, __FUNCTION__);
947+
MQTT_LOG_W("mqtt-client:%d %s() -, mqtt clean session.", __LINE__, __FUNCTION__);
948948
network_disconnect(c->mqtt_network);
949949
mqtt_clean_session(c);
950950
goto exit;
951951
} else if (MQTT_RECONNECT_TIMEOUT_ERROR == rc) {
952-
MQTT_LOG_W("mqtt-client:%d %s()..., mqtt reconnect timeout....", __LINE__, __FUNCTION__);
952+
MQTT_LOG_W("mqtt-client:%d %s() -, mqtt reconnect timeout.", __LINE__, __FUNCTION__);
953953
}
954954
}
955955

@@ -993,7 +993,7 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
993993
RETURN_ERROR(rc);
994994
}
995995

996-
MQTT_LOG_I("mqtt-client:%d %s()... mqtt connect success...", __LINE__, __FUNCTION__);
996+
MQTT_LOG_I("mqtt-client:%d %s() - mqtt connect success", __LINE__, __FUNCTION__);
997997

998998
connect_data.keepAliveInterval = c->mqtt_keep_alive_interval;
999999
connect_data.cleansession = c->mqtt_clean_session;
@@ -1047,7 +1047,7 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
10471047
/*creat the thread fail and disconnect the mqtt socket connect*/
10481048
network_release(c->mqtt_network);
10491049
rc = MQTT_CONNECT_FAILED_ERROR;
1050-
MQTT_LOG_W("mqtt-client:%d %s()... mqtt yield thread creat failed...", __LINE__, __FUNCTION__);
1050+
MQTT_LOG_W("mqtt-client:%d %s() - mqtt yield thread creat failed", __LINE__, __FUNCTION__);
10511051
}
10521052
} else {
10531053
mqtt_set_client_state(c, CLIENT_STATE_CONNECTED); /* reconnect, mqtt thread is already exists */
@@ -1081,7 +1081,7 @@ static uint32_t mqtt_read_buf_malloc(mqtt_client_t* c, uint32_t size)
10811081
c->mqtt_read_buf = (uint8_t*) platform_memory_alloc(c->mqtt_read_buf_size);
10821082

10831083
if (NULL == c->mqtt_read_buf) {
1084-
MQTT_LOG_E("mqtt-client:%d %s()... malloc read buf failed...", __LINE__, __FUNCTION__);
1084+
MQTT_LOG_E("mqtt-client:%d %s() - malloc read buf failed", __LINE__, __FUNCTION__);
10851085
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
10861086
}
10871087
return c->mqtt_read_buf_size;
@@ -1103,7 +1103,7 @@ static uint32_t mqtt_write_buf_malloc(mqtt_client_t* c, uint32_t size)
11031103
c->mqtt_write_buf = (uint8_t*) platform_memory_alloc(c->mqtt_write_buf_size);
11041104

11051105
if (NULL == c->mqtt_write_buf) {
1106-
MQTT_LOG_E("mqtt-client:%d %s()... malloc write buf failed...", __LINE__, __FUNCTION__);
1106+
MQTT_LOG_E("mqtt-client:%d %s() - malloc write buf failed", __LINE__, __FUNCTION__);
11071107
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
11081108
}
11091109
return c->mqtt_write_buf_size;
@@ -1115,7 +1115,7 @@ static int mqtt_init(mqtt_client_t* c)
11151115
c->mqtt_network = (network_t*) platform_memory_alloc(sizeof(network_t));
11161116

11171117
if (NULL == c->mqtt_network) {
1118-
MQTT_LOG_E("mqtt-client:%d %s()... malloc memory failed...", __LINE__, __FUNCTION__);
1118+
MQTT_LOG_E("mqtt-client:%d %s() - malloc memory failed", __LINE__, __FUNCTION__);
11191119
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
11201120
}
11211121
memset(c->mqtt_network, 0, sizeof(network_t));
@@ -1198,7 +1198,7 @@ int mqtt_keep_alive(mqtt_client_t* c)
11981198

11991199
if (platform_timer_is_expired(&c->mqtt_last_sent) || platform_timer_is_expired(&c->mqtt_last_received)) {
12001200
if (c->mqtt_ping_outstanding) {
1201-
MQTT_LOG_W("mqtt-client:%d %s()... ping outstanding", __LINE__, __FUNCTION__);
1201+
MQTT_LOG_W("mqtt-client:%d %s() - ping outstanding", __LINE__, __FUNCTION__);
12021202
/*must realse the socket file descriptor zhaoshimin 20200629*/
12031203
network_release(c->mqtt_network);
12041204

@@ -1250,7 +1250,7 @@ int mqtt_release(mqtt_client_t* c)
12501250
while ((CLIENT_STATE_INVALID != mqtt_get_client_state(c))) {
12511251
// platform_timer_usleep(1000); // 1ms avoid compiler optimization.
12521252
if (platform_timer_is_expired(&timer)) {
1253-
MQTT_LOG_E("mqtt-client:%d %s()... mqtt release failed...", __LINE__, __FUNCTION__);
1253+
MQTT_LOG_E("mqtt-client:%d %s() - mqtt release failed", __LINE__, __FUNCTION__);
12541254
RETURN_ERROR(MQTT_FAILED_ERROR)
12551255
}
12561256
}
@@ -1415,7 +1415,7 @@ int mqtt_publish(mqtt_client_t* c, const char* topic_filter, mqtt_message_t* msg
14151415
msg->payloadlen = strlen((char*)msg->payload);
14161416

14171417
if (msg->payloadlen > c->mqtt_write_buf_size) {
1418-
MQTT_LOG_E("publish payload len is is greater than client write buffer...");
1418+
MQTT_LOG_E("publish payload len is is greater than client write buffer");
14191419
RETURN_ERROR(MQTT_BUFFER_TOO_SHORT_ERROR);
14201420
}
14211421

@@ -1457,7 +1457,7 @@ int mqtt_publish(mqtt_client_t* c, const char* topic_filter, mqtt_message_t* msg
14571457
platform_mutex_unlock(&c->mqtt_write_lock);
14581458

14591459
if ((MQTT_ACK_HANDLER_NUM_TOO_MUCH_ERROR == rc) || (MQTT_MEM_NOT_ENOUGH_ERROR == rc)) {
1460-
MQTT_LOG_W("mqtt-client:%d %s()... there is not enough memory space to record...", __LINE__, __FUNCTION__);
1460+
MQTT_LOG_W("mqtt-client:%d %s() - there is not enough memory space to record", __LINE__, __FUNCTION__);
14611461

14621462
/*must realse the socket file descriptor zhaoshimin 20200629*/
14631463
network_release(c->mqtt_network);
@@ -1482,13 +1482,13 @@ int mqtt_list_subscribe_topic(mqtt_client_t* c)
14821482
RETURN_ERROR(MQTT_NULL_VALUE_ERROR);
14831483

14841484
if (mqtt_list_is_empty(&c->mqtt_msg_handler_list))
1485-
MQTT_LOG_I("mqtt-client:%d %s()... there are no subscribed topics...", __LINE__, __FUNCTION__);
1485+
MQTT_LOG_I("mqtt-client:%d %s() - there are no subscribed topics", __LINE__, __FUNCTION__);
14861486

14871487
LIST_FOR_EACH_SAFE(curr, next, &c->mqtt_msg_handler_list) {
14881488
msg_handler = LIST_ENTRY(curr, message_handlers_t, list);
14891489
/* determine whether a node already exists by mqtt topic, but wildcards are not supported */
14901490
if (NULL != msg_handler->topic_filter) {
1491-
MQTT_LOG_I("mqtt-client:%d %s()...[%d] subscribe topic: %s", __LINE__, __FUNCTION__, ++i ,msg_handler->topic_filter);
1491+
MQTT_LOG_I("mqtt-client:%d %s() -[%d] subscribe topic: %s", __LINE__, __FUNCTION__, ++i ,msg_handler->topic_filter);
14921492
}
14931493
}
14941494

0 commit comments

Comments
 (0)