From 9dfcb2ebb6d22e12f7585fc66255017c4fdaf9c1 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Thu, 5 Apr 2018 05:34:50 -0700 Subject: [PATCH] Various logging improvements --- examples/slip-radio/slip-radio.c | 2 +- os/net/app-layer/coap/coap-engine.c | 2 +- os/net/app-layer/coap/coap-uip.c | 8 ++++---- os/net/ipv6/sicslowpan.c | 12 ++++++------ os/net/ipv6/tcpip.c | 4 +++- os/net/mac/csma/csma-output.c | 3 ++- os/net/mac/csma/csma.c | 6 +++--- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/examples/slip-radio/slip-radio.c b/examples/slip-radio/slip-radio.c index 30a9387df..21779a3dc 100644 --- a/examples/slip-radio/slip-radio.c +++ b/examples/slip-radio/slip-radio.c @@ -254,7 +254,7 @@ PROCESS_THREAD(slip_radio_process, ev, data) #ifdef SLIP_RADIO_CONF_SENSORS SLIP_RADIO_CONF_SENSORS.init(); #endif - printf("Slip Radio started...\n"); + LOG_INFO("Slip Radio started\n"); etimer_set(&et, CLOCK_SECOND * 3); diff --git a/os/net/app-layer/coap/coap-engine.c b/os/net/app-layer/coap/coap-engine.c index 0db9c2a39..fb85b5b15 100644 --- a/os/net/app-layer/coap/coap-engine.c +++ b/os/net/app-layer/coap/coap-engine.c @@ -51,7 +51,7 @@ /* Log configuration */ #include "coap-log.h" -#define LOG_MODULE "coap-engine" +#define LOG_MODULE "coap-eng" #define LOG_LEVEL LOG_LEVEL_COAP static void process_callback(coap_timer_t *t); diff --git a/os/net/app-layer/coap/coap-uip.c b/os/net/app-layer/coap/coap-uip.c index ed881ca8b..8db2bbbbf 100644 --- a/os/net/app-layer/coap/coap-uip.c +++ b/os/net/app-layer/coap/coap-uip.c @@ -359,8 +359,8 @@ process_secure_data(void) { LOG_INFO("receiving secure UDP datagram from ["); LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr); - LOG_INFO_("]:%u\n Length: %u\n", uip_ntohs(UIP_UDP_BUF->srcport), - uip_datalen()); + LOG_INFO_("]:%u\n", uip_ntohs(UIP_UDP_BUF->srcport)); + LOG_INFO(" Length: %u\n", uip_datalen()); if(dtls_context) { dtls_handle_message(dtls_context, (coap_endpoint_t *)get_src_endpoint(1), @@ -374,8 +374,8 @@ process_data(void) { LOG_INFO("receiving UDP datagram from ["); LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr); - LOG_INFO_("]:%u\n Length: %u\n", uip_ntohs(UIP_UDP_BUF->srcport), - uip_datalen()); + LOG_INFO_("]:%u\n", uip_ntohs(UIP_UDP_BUF->srcport)); + LOG_INFO(" Length: %u\n", uip_datalen()); coap_receive(get_src_endpoint(0), uip_appdata, uip_datalen()); } diff --git a/os/net/ipv6/sicslowpan.c b/os/net/ipv6/sicslowpan.c index 3bc7a935e..4708acca7 100644 --- a/os/net/ipv6/sicslowpan.c +++ b/os/net/ipv6/sicslowpan.c @@ -1571,7 +1571,7 @@ output(const linkaddr_t *localdest) LOG_INFO("Fragmentation sending packet len %d\n", uip_len); /* Create 1st Fragment */ - LOG_INFO("output: 1rst fragment "); + LOG_INFO("output: 1st fragment "); /* Reset last tx status to ok in case the fragment transmissions are deferred */ last_tx_status = MAC_TX_OK; @@ -1591,7 +1591,7 @@ output(const linkaddr_t *localdest) /* Copy payload and send */ packetbuf_hdr_len += SICSLOWPAN_FRAG1_HDR_LEN; packetbuf_payload_len = (max_payload - packetbuf_hdr_len) & 0xfffffff8; - LOG_INFO("(len %d, tag %d)\n", packetbuf_payload_len, frag_tag); + LOG_INFO_("(len %d, tag %d)\n", packetbuf_payload_len, frag_tag); memcpy(packetbuf_ptr + packetbuf_hdr_len, (uint8_t *)UIP_IP_BUF + uncomp_hdr_len, packetbuf_payload_len); packetbuf_set_datalen(packetbuf_payload_len + packetbuf_hdr_len); @@ -1636,7 +1636,7 @@ output(const linkaddr_t *localdest) /* last fragment */ packetbuf_payload_len = uip_len - processed_ip_out_len; } - LOG_INFO("(offset %d, len %d, tag %d)\n", + LOG_INFO_("(offset %d, len %d, tag %d)\n", processed_ip_out_len >> 3, packetbuf_payload_len, frag_tag); memcpy(packetbuf_ptr + packetbuf_hdr_len, (uint8_t *)UIP_IP_BUF + processed_ip_out_len, packetbuf_payload_len); @@ -1742,7 +1742,7 @@ input(void) frag_offset = 0; frag_size = GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_DISPATCH_SIZE) & 0x07ff; frag_tag = GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_TAG); - LOG_INFO("size %d, tag %d, offset %d)\n", + LOG_INFO_ ("size %d, tag %d, offset %d)\n", frag_size, frag_tag, frag_offset); packetbuf_hdr_len += SICSLOWPAN_FRAG1_HDR_LEN; first_fragment = 1; @@ -1767,13 +1767,13 @@ input(void) frag_offset = PACKETBUF_FRAG_PTR[PACKETBUF_FRAG_OFFSET]; frag_tag = GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_TAG); frag_size = GET16(PACKETBUF_FRAG_PTR, PACKETBUF_FRAG_DISPATCH_SIZE) & 0x07ff; - LOG_INFO("size %d, tag %d, offset %d)\n", + LOG_INFO_("size %d, tag %d, offset %d)\n", frag_size, frag_tag, frag_offset); packetbuf_hdr_len += SICSLOWPAN_FRAGN_HDR_LEN; /* If this is the last fragment, we may shave off any extrenous bytes at the end. We must be liberal in what we accept. */ - LOG_INFO("last_fragment?: packetbuf_payload_len %d frag_size %d\n", + LOG_INFO_("last_fragment?: packetbuf_payload_len %d frag_size %d\n", packetbuf_datalen() - packetbuf_hdr_len, frag_size); /* Add the fragment to the fragmentation context (this will also diff --git a/os/net/ipv6/tcpip.c b/os/net/ipv6/tcpip.c index 41d317d17..5db4b9a21 100644 --- a/os/net/ipv6/tcpip.c +++ b/os/net/ipv6/tcpip.c @@ -168,6 +168,8 @@ static void packet_input(void) { if(uip_len > 0) { + LOG_INFO("input: received %u bytes\n", uip_len); + check_for_tcp_syn(); #if UIP_TAG_TC_WITH_VARIABLE_RETRANSMISSIONS @@ -499,7 +501,7 @@ get_nexthop(uip_ipaddr_t *addr) uip_ipaddr_t *nexthop; uip_ds6_route_t *route; - LOG_INFO("output: processing packet from "); + LOG_INFO("output: processing %u bytes packet from ", uip_len); LOG_INFO_6ADDR(&UIP_IP_BUF->srcipaddr); LOG_INFO_(" to "); LOG_INFO_6ADDR(&UIP_IP_BUF->destipaddr); diff --git a/os/net/mac/csma/csma-output.c b/os/net/mac/csma/csma-output.c index 74803ecf1..87a46aa18 100644 --- a/os/net/mac/csma/csma-output.c +++ b/os/net/mac/csma/csma-output.c @@ -523,7 +523,8 @@ csma_output_packet(mac_callback_t sent, void *ptr) LOG_INFO("sending to "); LOG_INFO_LLADDR(addr); - LOG_INFO_(", seqno %u, queue length %d, free packets %d\n", + LOG_INFO_(", len %u, seqno %u, queue length %d, free packets %d\n", + packetbuf_datalen(), packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO), list_length(n->packet_queue), memb_numfree(&packet_memb)); /* If q is the first packet in the neighbor's queue, send asap */ diff --git a/os/net/mac/csma/csma.c b/os/net/mac/csma/csma.c index aa7a98a3d..7259e35c8 100644 --- a/os/net/mac/csma/csma.c +++ b/os/net/mac/csma/csma.c @@ -108,9 +108,9 @@ input_packet(void) } #endif /* CSMA_SEND_SOFT_ACK */ if(!duplicate) { - LOG_WARN("received packet from "); - LOG_WARN_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER)); - LOG_WARN_(", seqno %u, len %u\n", packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO), packetbuf_datalen()); + LOG_INFO("received packet from "); + LOG_INFO_LLADDR(packetbuf_addr(PACKETBUF_ADDR_SENDER)); + LOG_INFO_(", seqno %u, len %u\n", packetbuf_attr(PACKETBUF_ATTR_MAC_SEQNO), packetbuf_datalen()); NETSTACK_NETWORK.input(); } }