Added logging example for regression testing with all logs enabled
This commit is contained in:
parent
4c68f68b07
commit
1dcba2a700
@ -493,12 +493,12 @@ uip_ds6_route_rm(uip_ds6_route_t *route)
|
||||
if(list_head(route->neighbor_routes->route_list) == NULL) {
|
||||
/* If this was the only route using this neighbor, remove the
|
||||
neighbor from the table - this implicitly unlocks nexthop */
|
||||
#if LOG_ANNOTATE_ENABLED
|
||||
#if LOG_WITH_ANNOTATE
|
||||
uip_ipaddr_t *nexthop = uip_ds6_route_nexthop(route);
|
||||
if(nexthop != NULL) {
|
||||
LOG_ANNOTATE("#L %u 0\n", nexthop->u8[sizeof(uip_ipaddr_t) - 1]);
|
||||
}
|
||||
#endif /* LOG_ANNOTATE_ENABLED */
|
||||
#endif /* LOG_WITH_ANNOTATE */
|
||||
LOG_INFO("Rm: removing neighbor too\n");
|
||||
nbr_table_remove(nbr_routes, route->neighbor_routes->route_list);
|
||||
#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_REMOVED_CALLBACK
|
||||
|
@ -67,7 +67,6 @@ void uip_debug_ipaddr_print(const uip_ipaddr_t *addr);
|
||||
#define LOG_LEVEL_WARN 2 /* Warnings */
|
||||
#define LOG_LEVEL_INFO 3 /* Basic info */
|
||||
#define LOG_LEVEL_DBG 4 /* Detailled debug */
|
||||
#define LOG_LEVEL_ANNOTATE 5 /* Cooja annotations */
|
||||
|
||||
/* Prefix all logs with file name and line-of-code */
|
||||
#ifdef LOG_CONF_WITH_LOC
|
||||
@ -83,6 +82,13 @@ void uip_debug_ipaddr_print(const uip_ipaddr_t *addr);
|
||||
#define LOG_OUTPUT(...) printf(__VA_ARGS__)
|
||||
#endif /* LOG_CONF_OUTPUT */
|
||||
|
||||
/* Cooja annotations */
|
||||
#ifdef LOG_CONF_WITH_ANNOTATE
|
||||
#define LOG_WITH_ANNOTATE LOG_CONF_WITH_ANNOTATE
|
||||
#else /* LOG_CONF_WITH_ANNOTATE */
|
||||
#define LOG_WITH_ANNOTATE 0
|
||||
#endif /* LOG_CONF_WITH_ANNOTATE */
|
||||
|
||||
/* Main log function */
|
||||
#define LOG(level, ...) do { \
|
||||
if (level <= LOG_LEVEL) { \
|
||||
@ -96,7 +102,7 @@ void uip_debug_ipaddr_print(const uip_ipaddr_t *addr);
|
||||
|
||||
/* For Cooja annotations */
|
||||
#define LOG_ANNOTATE(...) do { \
|
||||
if (LOG_LEVEL_ANNOTATE <= LOG_LEVEL) { \
|
||||
if (LOG_WITH_ANNOTATE) { \
|
||||
LOG_OUTPUT(__VA_ARGS__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
6
examples/logging/Makefile
Normal file
6
examples/logging/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
CONTIKI_PROJECT = logging
|
||||
all: $(CONTIKI_PROJECT)
|
||||
|
||||
CFLAGS += -DPROJECT_CONF_H=\"project-conf.h\"
|
||||
CONTIKI = ../..
|
||||
include $(CONTIKI)/Makefile.include
|
6
examples/logging/README.md
Normal file
6
examples/logging/README.md
Normal file
@ -0,0 +1,6 @@
|
||||
Logging
|
||||
===========
|
||||
|
||||
This example shows how to configure the logging system. See core/net/sys/log.h
|
||||
and core/net/sys/log-conf.h more information on logging. Edit project-conf.h
|
||||
for configure debug levels for the different modules.
|
55
examples/logging/logging.c
Normal file
55
examples/logging/logging.c
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A very simple Contiki application showing how Contiki programs look
|
||||
* \author
|
||||
* Adam Dunkels <adam@sics.se>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
#include <stdio.h> /* For printf() */
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS(logging_example_process, "Logging example process");
|
||||
AUTOSTART_PROCESSES(&logging_example_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(logging_example_process, ev, data)
|
||||
{
|
||||
PROCESS_BEGIN();
|
||||
|
||||
printf("Hello, world, from logging example process\n");
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
51
examples/logging/project-conf.h
Normal file
51
examples/logging/project-conf.h
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef PROJECT_CONF_H_
|
||||
#define PROJECT_CONF_H_
|
||||
|
||||
/* Set maximum debug level on all modules. See core/sys/log-conf.h for
|
||||
* a list of supported modules. The different log levels are defined in
|
||||
* core/sys/log.h:
|
||||
* LOG_LEVEL_NONE No log
|
||||
* LOG_LEVEL_ERR Errors
|
||||
* LOG_LEVEL_WARN Warnings
|
||||
* LOG_LEVEL_INFO Basic info
|
||||
* LOG_LEVEL_DBG Detailled debug
|
||||
*/
|
||||
#define IPV6_LOG_LEVEL LOG_LEVEL_DBG
|
||||
#define SICSLOWPAN_LOG_LEVEL LOG_LEVEL_DBG
|
||||
#define TCPIP_LOG_LEVEL LOG_LEVEL_DBG
|
||||
#define MAC_LOG_LEVEL LOG_LEVEL_DBG
|
||||
#define FRAMER_LOG_LEVEL LOG_LEVEL_DBG
|
||||
|
||||
/* Enable cooja annotations */
|
||||
#define LOG_CONF_WITH_ANNOTATE 1
|
||||
|
||||
#endif
|
@ -6,6 +6,7 @@ hello-world/native \
|
||||
hello-world/sky \
|
||||
eeprom-test/native \
|
||||
ipv6/multicast/sky \
|
||||
logging/native \
|
||||
|
||||
TOOLS=
|
||||
|
||||
|
@ -41,7 +41,8 @@ cfs-coffee/openmote-cc2538 \
|
||||
cfs-coffee/zoul \
|
||||
ipv6/rpl-tsch/zoul \
|
||||
ipv6/rpl-tsch/zoul:MAKE_WITH_ORCHESTRA=1 \
|
||||
ipv6/rpl-tsch/zoul:MAKE_WITH_SECURITY=1
|
||||
ipv6/rpl-tsch/zoul:MAKE_WITH_SECURITY=1 \
|
||||
logging/zoul \
|
||||
|
||||
TOOLS=
|
||||
|
||||
|
@ -18,7 +18,8 @@ platform-specific/jn516x/tsch/uart1-test-node/jn516x \
|
||||
sensniff/jn516x \
|
||||
ipv6/rpl-tsch/jn516x \
|
||||
ipv6/rpl-tsch/jn516x:MAKE_WITH_ORCHESTRA=1 \
|
||||
ipv6/rpl-tsch/jn516x:MAKE_WITH_SECURITY=1
|
||||
ipv6/rpl-tsch/jn516x:MAKE_WITH_SECURITY=1 \
|
||||
logging/jn516x
|
||||
|
||||
TOOLS=
|
||||
|
||||
|
@ -5,14 +5,15 @@ TOOLSDIR=../../tools
|
||||
# even though it's not a valid IPV6 address. This is due to limitation
|
||||
# of the testing framework which splits compliation arguments using
|
||||
# a colon.
|
||||
|
||||
|
||||
EXAMPLES = \
|
||||
hello-world/nrf52dk \
|
||||
platform-specific/nrf52dk/coap-demo/nrf52dk:coap-server \
|
||||
platform-specific/nrf52dk/coap-demo/nrf52dk:coap-client:SERVER_IPV6_ADDR=ffff \
|
||||
platform-specific/nrf52dk/mqtt-demo/nrf52dk \
|
||||
platform-specific/nrf52dk/blink-hello/nrf52dk \
|
||||
platform-specific/nrf52dk/timer-test/nrf52dk
|
||||
platform-specific/nrf52dk/timer-test/nrf52dk \
|
||||
logging/nrf52dk
|
||||
|
||||
TOOLS=
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user