mirror of
https://github.com/obgm/libcoap.git
synced 2026-12-05 20:02:19 +03:00
Replace debug(), info() & warn() macros with appropriate coap_log()
This then removes the need for name polution/confict of debug(), info() and warn() when building other projects that use libcoap and need to #include the libcoap header files Updated: examples/client.c examples/contiki/coap-observer.c examples/etsi_iot_01.c include/coap2/debug.h src/async.c src/block.c src/coap_io.c src/coap_openssl.c src/coap_session.c src/coap_tinydtls.c src/debug.c src/mem.c src/net.c src/option.c src/pdu.c src/resource.c src/uri.c If the debug() etc. macros are still required, then the change to include/coap2/debug.h just needs to be reverted. There are also a couple of space changes - to cause log output to be columnar e.g "ERR" was padded to "ERR ", so that "EMRG" or "ERR " log output output was aligned in the same way. This is a replacement for PR#51, and partially deals with name polution issues raised in Issue #50. Parameter re-aligned some long strings, splitting strings across multiple lines
This commit is contained in:
1 parent
3c75958f33
commit
04ced3e5e5
17 files changed
+357
-240
No files matched your search
+2
-2
@@ -329,7 +329,7 @@ message_handler(struct coap_context_t *ctx,
|
||||
}
|
||||
|
||||
if (received->type == COAP_MESSAGE_RST) {
|
||||
info("got RST\n");
|
||||
coap_log(LOG_INFO, "got RST\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1406,7 +1406,7 @@ main(int argc, char **argv) {
|
||||
if ( result >= 0 ) {
|
||||
if ( wait_ms > 0 && !wait_ms_reset ) {
|
||||
if ( (unsigned)result >= wait_ms ) {
|
||||
info( "timeout\n" );
|
||||
coap_log(LOG_INFO, "timeout\n");
|
||||
break;
|
||||
} else {
|
||||
wait_ms -= result;
|
||||
|
||||
@@ -101,7 +101,7 @@ message_handler(struct coap_context_t *ctx,
|
||||
/* send ACK if received message is confirmable (i.e. a separate response) */
|
||||
coap_send_ack(ctx, remote, received);
|
||||
|
||||
debug("** process incoming %d.%02d response:\n",
|
||||
coap_log(LOG_DEBUG, "** process incoming %d.%02d response:\n",
|
||||
(received->hdr->code >> 5), received->hdr->code & 0x1F);
|
||||
coap_show_pdu(LOG_WARNING, received);
|
||||
|
||||
|
||||
@@ -352,7 +352,7 @@ hnd_put_test(coap_context_t *ctx, struct coap_resource_t *resource,
|
||||
|
||||
return;
|
||||
error:
|
||||
warn("cannot modify resource\n");
|
||||
coap_log(LOG_WARNING, "cannot modify resource\n");
|
||||
response->code = COAP_RESPONSE_CODE(500);
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ hnd_get_separate(coap_context_t *ctx, struct coap_resource_t *resource,
|
||||
delay = d < COAP_RESOURCE_CHECK_TIME_SEC
|
||||
? COAP_RESOURCE_CHECK_TIME_SEC
|
||||
: d;
|
||||
debug("set delay to %lu\n", delay);
|
||||
coap_log(LOG_DEBUG, "set delay to %lu\n", delay);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -474,7 +474,7 @@ check_async(coap_context_t *ctx, coap_tick_t now) {
|
||||
: COAP_MESSAGE_NON,
|
||||
COAP_RESPONSE_CODE(205), 0, size);
|
||||
if (!response) {
|
||||
debug("check_async: insufficient memory, we'll try later\n");
|
||||
coap_log(LOG_DEBUG, "check_async: insufficient memory, we'll try later\n");
|
||||
async->appdata =
|
||||
(void *)((unsigned long)async->appdata + 15 * COAP_TICKS_PER_SECOND);
|
||||
return;
|
||||
@@ -493,7 +493,7 @@ check_async(coap_context_t *ctx, coap_tick_t now) {
|
||||
coap_add_data(response, 4, (unsigned char *)"done");
|
||||
|
||||
if (coap_send(ctx, &async->peer, response) == COAP_INVALID_TID) {
|
||||
debug("check_async: cannot send response for message %d\n",
|
||||
coap_log(LOG_DEBUG, "check_async: cannot send response for message %d\n",
|
||||
response->tid);
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ make_large(char *filename) {
|
||||
|
||||
/* read from specified input file */
|
||||
if (stat(filename, &statbuf) < 0) {
|
||||
warn("cannot stat file %s\n", filename);
|
||||
coap_log(LOG_WARNING, "cannot stat file %s\n", filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -523,7 +523,7 @@ make_large(char *filename) {
|
||||
|
||||
inputfile = fopen(filename, "r");
|
||||
if ( !inputfile ) {
|
||||
warn("cannot read file %s\n", filename);
|
||||
coap_log(LOG_WARNING, "cannot read file %s\n", filename);
|
||||
coap_free(payload);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user