Skip to content

Commit cb2c8fe

Browse files
committed
Fix: remove filepath from library code
remove full path name from error and debug messages. Signed-off-by: Ajay Bhargav <[email protected]>
1 parent c6fb606 commit cb2c8fe

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

mqttclient/mqttclient.c

+23-23
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("%s:%d %s()...\ntopic: %s, qos: %d, \nmessage:%s", __FILE__, __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("%s:%d %s()... resend %d package, packet_id is %d ", __FILE__, __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,8 +460,8 @@ 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("%s:%d %s()...msg_handler->topic_filter: %s, handler->topic_filter: %s",
464-
__FILE__, __LINE__, __FUNCTION__, msg_handler->topic_filter, handler->topic_filter);
463+
MQTT_LOG_W("mqtt-client:%d %s()...msg_handler->topic_filter: %s, handler->topic_filter: %s",
464+
__LINE__, __FUNCTION__, msg_handler->topic_filter, handler->topic_filter);
465465
return 1;
466466
}
467467
}
@@ -517,7 +517,7 @@ static void mqtt_clean_session(mqtt_client_t* c)
517517
msg_handler->topic_filter = NULL;
518518
platform_memory_free(msg_handler);
519519
}
520-
// MQTT_LOG_D("%s:%d %s() mqtt_msg_handler_list delete", __FILE__, __LINE__, __FUNCTION__);
520+
// MQTT_LOG_D("mqtt-client:%d %s() mqtt_msg_handler_list delete", __LINE__, __FUNCTION__);
521521
mqtt_list_del_init(&c->mqtt_msg_handler_list);
522522
}
523523

@@ -569,10 +569,10 @@ 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("%s:%d %s()... mqtt try resubscribe ...", __FILE__, __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)) {
575-
// MQTT_LOG_D("%s:%d %s() mqtt_msg_handler_list is empty", __FILE__, __LINE__, __FUNCTION__);
575+
// MQTT_LOG_D("mqtt-client:%d %s() mqtt_msg_handler_list is empty", __LINE__, __FUNCTION__);
576576
RETURN_ERROR(MQTT_SUCCESS_ERROR);
577577
}
578578

@@ -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("%s:%d %s()... mqtt ack handler num too much ...", __FILE__, __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("%s:%d %s()... mqtt try connect result is -0x%04x", __FILE__, __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
}
@@ -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("%s:%d %s()... mqtt not connect", __FILE__, __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("%s:%d %s()..., mqtt is not connected to the server...", __FILE__, __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("%s:%d %s()..., mqtt clean session....", __FILE__, __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("%s:%d %s()..., mqtt reconnect timeout....", __FILE__, __LINE__, __FUNCTION__);
952+
MQTT_LOG_W("mqtt-client:%d %s()..., mqtt reconnect timeout....", __LINE__, __FUNCTION__);
953953
}
954954
}
955955

@@ -991,7 +991,7 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
991991
}
992992
}
993993

994-
MQTT_LOG_I("%s:%d %s()... mqtt connect success...", __FILE__, __LINE__, __FUNCTION__);
994+
MQTT_LOG_I("mqtt-client:%d %s()... mqtt connect success...", __LINE__, __FUNCTION__);
995995

996996
connect_data.keepAliveInterval = c->mqtt_keep_alive_interval;
997997
connect_data.cleansession = c->mqtt_clean_session;
@@ -1045,7 +1045,7 @@ static int mqtt_connect_with_results(mqtt_client_t* c)
10451045
/*creat the thread fail and disconnect the mqtt socket connect*/
10461046
network_release(c->mqtt_network);
10471047
rc = MQTT_CONNECT_FAILED_ERROR;
1048-
MQTT_LOG_W("%s:%d %s()... mqtt yield thread creat failed...", __FILE__, __LINE__, __FUNCTION__);
1048+
MQTT_LOG_W("mqtt-client:%d %s()... mqtt yield thread creat failed...", __LINE__, __FUNCTION__);
10491049
}
10501050
} else {
10511051
mqtt_set_client_state(c, CLIENT_STATE_CONNECTED); /* reconnect, mqtt thread is already exists */
@@ -1079,7 +1079,7 @@ static uint32_t mqtt_read_buf_malloc(mqtt_client_t* c, uint32_t size)
10791079
c->mqtt_read_buf = (uint8_t*) platform_memory_alloc(c->mqtt_read_buf_size);
10801080

10811081
if (NULL == c->mqtt_read_buf) {
1082-
MQTT_LOG_E("%s:%d %s()... malloc read buf failed...", __FILE__, __LINE__, __FUNCTION__);
1082+
MQTT_LOG_E("mqtt-client:%d %s()... malloc read buf failed...", __LINE__, __FUNCTION__);
10831083
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
10841084
}
10851085
return c->mqtt_read_buf_size;
@@ -1101,7 +1101,7 @@ static uint32_t mqtt_write_buf_malloc(mqtt_client_t* c, uint32_t size)
11011101
c->mqtt_write_buf = (uint8_t*) platform_memory_alloc(c->mqtt_write_buf_size);
11021102

11031103
if (NULL == c->mqtt_write_buf) {
1104-
MQTT_LOG_E("%s:%d %s()... malloc write buf failed...", __FILE__, __LINE__, __FUNCTION__);
1104+
MQTT_LOG_E("mqtt-client:%d %s()... malloc write buf failed...", __LINE__, __FUNCTION__);
11051105
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
11061106
}
11071107
return c->mqtt_write_buf_size;
@@ -1113,7 +1113,7 @@ static int mqtt_init(mqtt_client_t* c)
11131113
c->mqtt_network = (network_t*) platform_memory_alloc(sizeof(network_t));
11141114

11151115
if (NULL == c->mqtt_network) {
1116-
MQTT_LOG_E("%s:%d %s()... malloc memory failed...", __FILE__, __LINE__, __FUNCTION__);
1116+
MQTT_LOG_E("mqtt-client:%d %s()... malloc memory failed...", __LINE__, __FUNCTION__);
11171117
RETURN_ERROR(MQTT_MEM_NOT_ENOUGH_ERROR);
11181118
}
11191119
memset(c->mqtt_network, 0, sizeof(network_t));
@@ -1196,7 +1196,7 @@ int mqtt_keep_alive(mqtt_client_t* c)
11961196

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

@@ -1246,7 +1246,7 @@ int mqtt_release(mqtt_client_t* c)
12461246
while ((CLIENT_STATE_INVALID != mqtt_get_client_state(c))) {
12471247
// platform_timer_usleep(1000); // 1ms avoid compiler optimization.
12481248
if (platform_timer_is_expired(&timer)) {
1249-
MQTT_LOG_E("%s:%d %s()... mqtt release failed...", __FILE__, __LINE__, __FUNCTION__);
1249+
MQTT_LOG_E("mqtt-client:%d %s()... mqtt release failed...", __LINE__, __FUNCTION__);
12501250
RETURN_ERROR(MQTT_FAILED_ERROR)
12511251
}
12521252
}
@@ -1448,7 +1448,7 @@ int mqtt_publish(mqtt_client_t* c, const char* topic_filter, mqtt_message_t* msg
14481448
platform_mutex_unlock(&c->mqtt_write_lock);
14491449

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

14531453
/*must realse the socket file descriptor zhaoshimin 20200629*/
14541454
network_release(c->mqtt_network);
@@ -1473,13 +1473,13 @@ int mqtt_list_subscribe_topic(mqtt_client_t* c)
14731473
RETURN_ERROR(MQTT_NULL_VALUE_ERROR);
14741474

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

14781478
LIST_FOR_EACH_SAFE(curr, next, &c->mqtt_msg_handler_list) {
14791479
msg_handler = LIST_ENTRY(curr, message_handlers_t, list);
14801480
/* determine whether a node already exists by mqtt topic, but wildcards are not supported */
14811481
if (NULL != msg_handler->topic_filter) {
1482-
MQTT_LOG_I("%s:%d %s()...[%d] subscribe topic: %s", __FILE__, __LINE__, __FUNCTION__, ++i ,msg_handler->topic_filter);
1482+
MQTT_LOG_I("mqtt-client:%d %s()...[%d] subscribe topic: %s", __LINE__, __FUNCTION__, ++i ,msg_handler->topic_filter);
14831483
}
14841484
}
14851485

0 commit comments

Comments
 (0)