Added per-module runtime log level configuration
This commit is contained in:
parent
2847a05e0a
commit
8966460b1f
@ -248,6 +248,19 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args))
|
|||||||
PT_END(pt);
|
PT_END(pt);
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void
|
||||||
|
shell_output_log_levels(shell_output_func output)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
SHELL_OUTPUT(output, "Log levels:\n");
|
||||||
|
while(all_modules[i].name != NULL) {
|
||||||
|
SHELL_OUTPUT(output, "-- %-10s: %s\n",
|
||||||
|
all_modules[i].name,
|
||||||
|
log_level_to_str(*all_modules[i].curr_log_level));
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
static
|
static
|
||||||
PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
|
PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
|
||||||
{
|
{
|
||||||
@ -255,12 +268,23 @@ PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
|
|||||||
static int level;
|
static int level;
|
||||||
char *next_args;
|
char *next_args;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
|
char *module;
|
||||||
|
|
||||||
PT_BEGIN(pt);
|
PT_BEGIN(pt);
|
||||||
|
|
||||||
SHELL_ARGS_INIT(args, next_args);
|
SHELL_ARGS_INIT(args, next_args);
|
||||||
|
|
||||||
/* Get and parse argument */
|
/* Get and parse argument: module name */
|
||||||
|
SHELL_ARGS_NEXT(args, next_args);
|
||||||
|
module = args;
|
||||||
|
prev_level = log_get_level(module);
|
||||||
|
if(module == NULL || (strcmp("all", module) && prev_level == -1)) {
|
||||||
|
SHELL_OUTPUT(output, "Invalid first argument: %s\n", module)
|
||||||
|
shell_output_log_levels(output);
|
||||||
|
PT_EXIT(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get and parse argument: log level */
|
||||||
SHELL_ARGS_NEXT(args, next_args);
|
SHELL_ARGS_NEXT(args, next_args);
|
||||||
if(args == NULL) {
|
if(args == NULL) {
|
||||||
level = -1;
|
level = -1;
|
||||||
@ -269,23 +293,25 @@ PT_THREAD(cmd_log(struct pt *pt, shell_output_func output, char *args))
|
|||||||
}
|
}
|
||||||
if((level == 0 && args == ptr)
|
if((level == 0 && args == ptr)
|
||||||
|| level < LOG_LEVEL_NONE || level > LOG_LEVEL_DBG) {
|
|| level < LOG_LEVEL_NONE || level > LOG_LEVEL_DBG) {
|
||||||
SHELL_OUTPUT(output, "Invalid argument: %s\n", args);
|
SHELL_OUTPUT(output, "Invalid second argument: %s\n", args);
|
||||||
PT_EXIT(pt);
|
PT_EXIT(pt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set log level */
|
/* Set log level */
|
||||||
prev_level = log_get_level();
|
|
||||||
if(level != prev_level) {
|
if(level != prev_level) {
|
||||||
log_set_level(level);
|
log_set_level(module, level);
|
||||||
if(level >= LOG_LEVEL_DBG) {
|
if(!strcmp(module, "mac") || !strcmp(module, "all")) {
|
||||||
tsch_log_init();
|
if(level >= LOG_LEVEL_DBG) {
|
||||||
SHELL_OUTPUT(output, "TSCH logging started\n");
|
tsch_log_init();
|
||||||
} else {
|
SHELL_OUTPUT(output, "TSCH logging started\n");
|
||||||
tsch_log_stop();
|
} else {
|
||||||
SHELL_OUTPUT(output, "TSCH logging stopped\n");
|
tsch_log_stop();
|
||||||
|
SHELL_OUTPUT(output, "TSCH logging stopped\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SHELL_OUTPUT(output, "Log level set to %u (%s)\n", level, log_level_to_str(level));
|
|
||||||
|
shell_output_log_levels(output);
|
||||||
|
|
||||||
PT_END(pt);
|
PT_END(pt);
|
||||||
}
|
}
|
||||||
@ -583,9 +609,9 @@ shell_commands_init(void)
|
|||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
struct shell_command_t shell_commands[] = {
|
struct shell_command_t shell_commands[] = {
|
||||||
{ "help", cmd_help, "'> help': Shows this help" },
|
{ "help", cmd_help, "'> help': Shows this help" },
|
||||||
{ "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" },
|
{ "ip-addr", cmd_ipaddr, "'> ip-addr': Shows all IPv6 addresses" },
|
||||||
{ "ip-nbr", cmd_ip_neighbors, "'> ip-nbr': Shows all IPv6 neighbors" },
|
{ "ip-nbr", cmd_ip_neighbors, "'> ip-nbr': Shows all IPv6 neighbors" },
|
||||||
{ "log", cmd_log, "'> log level': Sets log level (0--4). Level 4 also enables TSCH per-slot logging." },
|
{ "log", cmd_log, "'> log module level': Sets log level (0--4) for a given module (or \"all\"). For module \"mac\", level 4 also enables per-slot logging." },
|
||||||
{ "ping", cmd_ping, "'> ping addr': Pings the IPv6 address 'addr'" },
|
{ "ping", cmd_ping, "'> ping addr': Pings the IPv6 address 'addr'" },
|
||||||
{ "rpl-set-root", cmd_rpl_set_root, "'> rpl-set-root 0/1 [prefix]': Sets node as root (on) or not (off). A /64 prefix can be optionally specified." },
|
{ "rpl-set-root", cmd_rpl_set_root, "'> rpl-set-root 0/1 [prefix]': Sets node as root (on) or not (off). A /64 prefix can be optionally specified." },
|
||||||
{ "rpl-status", cmd_rpl_status, "'> rpl-status': Shows a summary of the current RPL state" },
|
{ "rpl-status", cmd_rpl_status, "'> rpl-status': Shows a summary of the current RPL state" },
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "TCP/IP"
|
#define LOG_MODULE "TCP/IP"
|
||||||
#define LOG_LEVEL TCPIP_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_TCPIP
|
||||||
|
|
||||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN + uip_ext_len])
|
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[UIP_LLIPH_LEN + uip_ext_len])
|
||||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "6LoWPAN"
|
#define LOG_MODULE "6LoWPAN"
|
||||||
#define LOG_LEVEL SICSLOWPAN_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_6LOWPAN
|
||||||
|
|
||||||
#ifdef SICSLOWPAN_CONF_COMPRESSION
|
#ifdef SICSLOWPAN_CONF_COMPRESSION
|
||||||
#define SICSLOWPAN_COMPRESSION SICSLOWPAN_CONF_COMPRESSION
|
#define SICSLOWPAN_COMPRESSION SICSLOWPAN_CONF_COMPRESSION
|
||||||
|
@ -55,7 +55,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "IPv6 Nbr"
|
#define LOG_MODULE "IPv6 Nbr"
|
||||||
#define LOG_LEVEL IPV6_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
#ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
|
#ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
|
||||||
#define NEIGHBOR_STATE_CHANGED(n) UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED(n)
|
#define NEIGHBOR_STATE_CHANGED(n) UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED(n)
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "IPv6 Route"
|
#define LOG_MODULE "IPv6 Route"
|
||||||
#define LOG_LEVEL IPV6_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
/* A configurable function called after adding a new neighbor as next hop */
|
/* A configurable function called after adding a new neighbor as next hop */
|
||||||
#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK
|
#ifdef NETSTACK_CONF_ROUTING_NEIGHBOR_ADDED_CALLBACK
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "IPv6 DS"
|
#define LOG_MODULE "IPv6 DS"
|
||||||
#define LOG_LEVEL IPV6_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
struct etimer uip_ds6_timer_periodic; /**< Timer for maintenance of data structures */
|
struct etimer uip_ds6_timer_periodic; /**< Timer for maintenance of data structures */
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "ICMPv6"
|
#define LOG_MODULE "ICMPv6"
|
||||||
#define LOG_LEVEL IPV6_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||||
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
#define UIP_ICMP_BUF ((struct uip_icmp_hdr *)&uip_buf[uip_l2_l3_hdr_len])
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "IPv6 NDP"
|
#define LOG_MODULE "IPv6 NDP"
|
||||||
#define LOG_LEVEL IPV6_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
/** @{ */
|
/** @{ */
|
||||||
|
@ -96,7 +96,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "IPv6"
|
#define LOG_MODULE "IPv6"
|
||||||
#define LOG_LEVEL IPV6_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "Websocket"
|
#define LOG_MODULE "Websocket"
|
||||||
#define LOG_LEVEL IPV6_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
STATE_WAITING_FOR_HEADER,
|
STATE_WAITING_FOR_HEADER,
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "Websocket"
|
#define LOG_MODULE "Websocket"
|
||||||
#define LOG_LEVEL IPV6_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_IPV6
|
||||||
|
|
||||||
PROCESS(websocket_process, "Websockets process");
|
PROCESS(websocket_process, "Websockets process");
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "CSMA"
|
#define LOG_MODULE "CSMA"
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||||
|
|
||||||
/* Constants of the IEEE 802.15.4 standard */
|
/* Constants of the IEEE 802.15.4 standard */
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "CSMA"
|
#define LOG_MODULE "CSMA"
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static void
|
static void
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "Frame 15.4"
|
#define LOG_MODULE "Frame 15.4"
|
||||||
#define LOG_LEVEL FRAMER_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_FRAMER
|
||||||
|
|
||||||
/* c.f. IEEE 802.15.4e Table 4b */
|
/* c.f. IEEE 802.15.4e Table 4b */
|
||||||
enum ieee802154e_header_ie_id {
|
enum ieee802154e_header_ie_id {
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "Frame 15.4"
|
#define LOG_MODULE "Frame 15.4"
|
||||||
#define LOG_LEVEL FRAMER_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_FRAMER
|
||||||
|
|
||||||
/** \brief The sequence number (0x00 - 0xff) added to the transmitted
|
/** \brief The sequence number (0x00 - 0xff) added to the transmitted
|
||||||
* data or MAC command frame. The default is a random value within
|
* data or MAC command frame. The default is a random value within
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "MAC"
|
#define LOG_MODULE "MAC"
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#define TSCH_LOG_PER_SLOT TSCH_LOG_CONF_PER_SLOT
|
#define TSCH_LOG_PER_SLOT TSCH_LOG_CONF_PER_SLOT
|
||||||
#else /* TSCH_LOG_CONF_PER_SLOT */
|
#else /* TSCH_LOG_CONF_PER_SLOT */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define TSCH_LOG_PER_SLOT (MAC_LOG_LEVEL >= LOG_LEVEL_DBG)
|
#define TSCH_LOG_PER_SLOT (LOG_LEVEL_MAC >= LOG_LEVEL_DBG)
|
||||||
#endif /* TSCH_LOG_CONF_PER_SLOT */
|
#endif /* TSCH_LOG_CONF_PER_SLOT */
|
||||||
|
|
||||||
/* The length of the log queue, i.e. maximum number postponed log messages */
|
/* The length of the log queue, i.e. maximum number postponed log messages */
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "TSCH Pkt"
|
#define LOG_MODULE "TSCH Pkt"
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* Construct enhanced ACK packet and return ACK length */
|
/* Construct enhanced ACK packet and return ACK length */
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "TSCH Queue"
|
#define LOG_MODULE "TSCH Queue"
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||||
|
|
||||||
/* Check if TSCH_QUEUE_NUM_PER_NEIGHBOR is power of two */
|
/* Check if TSCH_QUEUE_NUM_PER_NEIGHBOR is power of two */
|
||||||
#if (TSCH_QUEUE_NUM_PER_NEIGHBOR & (TSCH_QUEUE_NUM_PER_NEIGHBOR - 1)) != 0
|
#if (TSCH_QUEUE_NUM_PER_NEIGHBOR & (TSCH_QUEUE_NUM_PER_NEIGHBOR - 1)) != 0
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "TSCH RPL"
|
#define LOG_MODULE "TSCH RPL"
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
/* To use, set #define TSCH_CALLBACK_KA_SENT tsch_rpl_callback_ka_sent */
|
/* To use, set #define TSCH_CALLBACK_KA_SENT tsch_rpl_callback_ka_sent */
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "TSCH Sched"
|
#define LOG_MODULE "TSCH Sched"
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||||
|
|
||||||
/* Pre-allocated space for links */
|
/* Pre-allocated space for links */
|
||||||
MEMB(link_memb, struct tsch_link, TSCH_SCHEDULE_MAX_LINKS);
|
MEMB(link_memb, struct tsch_link, TSCH_SCHEDULE_MAX_LINKS);
|
||||||
|
@ -69,7 +69,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "TSCH"
|
#define LOG_MODULE "TSCH"
|
||||||
#define LOG_LEVEL MAC_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_MAC
|
||||||
|
|
||||||
/* Use to collect link statistics even on Keep-Alive, even though they were
|
/* Use to collect link statistics even on Keep-Alive, even though they were
|
||||||
* not sent from an upper layer and don't have a valid packet_sent callback */
|
* not sent from an upper layer and don't have a valid packet_sent callback */
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
#define RPL_DAG_GRACE_PERIOD (CLOCK_SECOND * 20 * 1)
|
#define RPL_DAG_GRACE_PERIOD (CLOCK_SECOND * 20 * 1)
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
extern rpl_of_t rpl_of0, rpl_mrhof;
|
extern rpl_of_t rpl_of0, rpl_mrhof;
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
#define UIP_IP_BUF ((struct uip_ip_hdr *)&uip_buf[UIP_LLH_LEN])
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
#define RPL_DIO_GROUNDED 0x80
|
#define RPL_DIO_GROUNDED 0x80
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/* RFC6551 and RFC6719 do not mandate the use of a specific formula to
|
/* RFC6551 and RFC6719 do not mandate the use of a specific formula to
|
||||||
* compute the ETX value. This MRHOF implementation relies on the value
|
* compute the ETX value. This MRHOF implementation relies on the value
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Policy for neighbor addition
|
* Policy for neighbor addition
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/* A configurable function called after every RPL parent switch */
|
/* A configurable function called after every RPL parent switch */
|
||||||
#ifdef RPL_CALLBACK_PARENT_SWITCH
|
#ifdef RPL_CALLBACK_PARENT_SWITCH
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/* Total number of nodes */
|
/* Total number of nodes */
|
||||||
static int num_nodes;
|
static int num_nodes;
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/* Constants from RFC6552. We use the default values. */
|
/* Constants from RFC6552. We use the default values. */
|
||||||
#define RANK_STRETCH 0 /* Must be in the range [0;5] */
|
#define RANK_STRETCH 0 /* Must be in the range [0;5] */
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
/* A configurable function called after update of the RPL DIO interval */
|
/* A configurable function called after update of the RPL DIO interval */
|
||||||
#ifdef RPL_CALLBACK_NEW_DIO_INTERVAL
|
#ifdef RPL_CALLBACK_NEW_DIO_INTERVAL
|
||||||
|
@ -48,7 +48,7 @@
|
|||||||
/* Log configuration */
|
/* Log configuration */
|
||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#define LOG_MODULE "RPL"
|
#define LOG_MODULE "RPL"
|
||||||
#define LOG_LEVEL RPL_LOG_LEVEL
|
#define LOG_LEVEL LOG_LEVEL_RPL
|
||||||
|
|
||||||
uip_ipaddr_t rpl_multicast_addr;
|
uip_ipaddr_t rpl_multicast_addr;
|
||||||
|
|
||||||
|
@ -78,29 +78,29 @@
|
|||||||
/********************* A list of currently supported modules ******************/
|
/********************* A list of currently supported modules ******************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
#ifndef RPL_LOG_LEVEL
|
#ifndef LOG_CONF_LEVEL_RPL
|
||||||
#define RPL_LOG_LEVEL LOG_LEVEL_NONE /* Only for rpl-lite */
|
#define LOG_CONF_LEVEL_RPL LOG_LEVEL_NONE /* Only for rpl-lite */
|
||||||
#endif /* RPL_LOG_LEVEL */
|
#endif /* LOG_CONF_LEVEL_RPL */
|
||||||
|
|
||||||
#ifndef TCPIP_LOG_LEVEL
|
#ifndef LOG_CONF_LEVEL_TCPIP
|
||||||
#define TCPIP_LOG_LEVEL LOG_LEVEL_NONE
|
#define LOG_CONF_LEVEL_TCPIP LOG_LEVEL_NONE
|
||||||
#endif /* TCPIP_LOG_LEVEL */
|
#endif /* LOG_CONF_LEVEL_TCPIP */
|
||||||
|
|
||||||
#ifndef IPV6_LOG_LEVEL
|
#ifndef LOG_CONF_LEVEL_IPV6
|
||||||
#define IPV6_LOG_LEVEL LOG_LEVEL_NONE
|
#define LOG_CONF_LEVEL_IPV6 LOG_LEVEL_NONE
|
||||||
#endif /* IPV6_LOG_LEVEL */
|
#endif /* LOG_CONF_LEVEL_IPV6 */
|
||||||
|
|
||||||
#ifndef SICSLOWPAN_LOG_LEVEL
|
#ifndef LOG_CONF_LEVEL_6LOWPAN
|
||||||
#define SICSLOWPAN_LOG_LEVEL LOG_LEVEL_NONE
|
#define LOG_CONF_LEVEL_6LOWPAN LOG_LEVEL_NONE
|
||||||
#endif /* SICSLOWPAN_LOG_LEVEL */
|
#endif /* LOG_CONF_LEVEL_6LOWPAN */
|
||||||
|
|
||||||
#ifndef MAC_LOG_LEVEL
|
#ifndef LOG_CONF_LEVEL_MAC
|
||||||
#define MAC_LOG_LEVEL LOG_LEVEL_NONE
|
#define LOG_CONF_LEVEL_MAC LOG_LEVEL_NONE
|
||||||
#endif /* MAC_LOG_LEVELL */
|
#endif /* LOG_CONF_LEVEL_MAC */
|
||||||
|
|
||||||
#ifndef FRAMER_LOG_LEVEL
|
#ifndef LOG_CONF_LEVEL_FRAMER
|
||||||
#define FRAMER_LOG_LEVEL LOG_LEVEL_NONE
|
#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_NONE
|
||||||
#endif /* FRAMER_LOG_LEVEL */
|
#endif /* LOG_CONF_LEVEL_FRAMER */
|
||||||
|
|
||||||
#endif /* __LOG_CONF_H__ */
|
#endif /* __LOG_CONF_H__ */
|
||||||
|
|
||||||
|
@ -53,7 +53,23 @@
|
|||||||
#include "sys/log.h"
|
#include "sys/log.h"
|
||||||
#include "net/ip/ip64-addr.h"
|
#include "net/ip/ip64-addr.h"
|
||||||
|
|
||||||
int curr_log_level = LOG_LEVEL_DBG;
|
|
||||||
|
int curr_log_level_rpl = LOG_CONF_LEVEL_RPL;
|
||||||
|
int curr_log_level_tcpip = LOG_CONF_LEVEL_TCPIP;
|
||||||
|
int curr_log_level_ipv6 = LOG_CONF_LEVEL_IPV6;
|
||||||
|
int curr_log_level_6lowpan = LOG_CONF_LEVEL_6LOWPAN;
|
||||||
|
int curr_log_level_mac = LOG_CONF_LEVEL_MAC;
|
||||||
|
int curr_log_level_framer = LOG_CONF_LEVEL_FRAMER;
|
||||||
|
|
||||||
|
struct log_module all_modules[] = {
|
||||||
|
{"rpl", &curr_log_level_rpl, LOG_CONF_LEVEL_RPL},
|
||||||
|
{"tcpip", &curr_log_level_tcpip, LOG_CONF_LEVEL_TCPIP},
|
||||||
|
{"ipv6", &curr_log_level_ipv6, LOG_CONF_LEVEL_IPV6},
|
||||||
|
{"6lowpan", &curr_log_level_6lowpan, LOG_CONF_LEVEL_6LOWPAN},
|
||||||
|
{"mac", &curr_log_level_mac, LOG_CONF_LEVEL_MAC},
|
||||||
|
{"framer", &curr_log_level_framer, LOG_CONF_LEVEL_FRAMER},
|
||||||
|
{NULL, NULL, 0},
|
||||||
|
};
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
@ -135,17 +151,31 @@ log_lladdr_compact(const linkaddr_t *lladdr)
|
|||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
void
|
void
|
||||||
log_set_level(int level)
|
log_set_level(const char *module, int level)
|
||||||
{
|
{
|
||||||
if(level >= LOG_LEVEL_NONE && level <= LOG_LEVEL_DBG) {
|
if(level >= LOG_LEVEL_NONE && level <= LOG_LEVEL_DBG) {
|
||||||
curr_log_level = level;
|
int i = 0;
|
||||||
|
int module_all = !strcmp("all", module);
|
||||||
|
while(all_modules[i].name != NULL) {
|
||||||
|
if(module_all || !strcmp(module, all_modules[i].name)) {
|
||||||
|
*all_modules[i].curr_log_level = MIN(level, all_modules[i].max_log_level);
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
int
|
int
|
||||||
log_get_level(void)
|
log_get_level(const char *module)
|
||||||
{
|
{
|
||||||
return curr_log_level;
|
int i = 0;
|
||||||
|
while(all_modules[i].name != NULL) {
|
||||||
|
if(!strcmp(module, all_modules[i].name)) {
|
||||||
|
return *all_modules[i].curr_log_level;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
const char *
|
const char *
|
||||||
|
@ -65,10 +65,34 @@
|
|||||||
#define LOG_LEVEL_INFO 3 /* Basic info */
|
#define LOG_LEVEL_INFO 3 /* Basic info */
|
||||||
#define LOG_LEVEL_DBG 4 /* Detailled debug */
|
#define LOG_LEVEL_DBG 4 /* Detailled debug */
|
||||||
|
|
||||||
|
/* Per-module log level */
|
||||||
|
|
||||||
|
struct log_module {
|
||||||
|
const char *name;
|
||||||
|
int *curr_log_level;
|
||||||
|
int max_log_level;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern int curr_log_level_rpl;
|
||||||
|
extern int curr_log_level_tcpip;
|
||||||
|
extern int curr_log_level_ipv6;
|
||||||
|
extern int curr_log_level_6lowpan;
|
||||||
|
extern int curr_log_level_mac;
|
||||||
|
extern int curr_log_level_framer;
|
||||||
|
|
||||||
|
extern struct log_module all_modules[];
|
||||||
|
|
||||||
|
#define LOG_LEVEL_RPL MIN((LOG_CONF_LEVEL_RPL), curr_log_level_rpl)
|
||||||
|
#define LOG_LEVEL_TCPIP MIN((LOG_CONF_LEVEL_TCPIP), curr_log_level_tcpip)
|
||||||
|
#define LOG_LEVEL_IPV6 MIN((LOG_CONF_LEVEL_IPV6), curr_log_level_ipv6)
|
||||||
|
#define LOG_LEVEL_6LOWPAN MIN((LOG_CONF_LEVEL_6LOWPAN), curr_log_level_6lowpan)
|
||||||
|
#define LOG_LEVEL_MAC MIN((LOG_CONF_LEVEL_MAC), curr_log_level_mac)
|
||||||
|
#define LOG_LEVEL_FRAMER MIN((LOG_CONF_LEVEL_FRAMER), curr_log_level_framer)
|
||||||
|
|
||||||
/* Main log function */
|
/* Main log function */
|
||||||
|
|
||||||
#define LOG(newline, level, levelstr, ...) do { \
|
#define LOG(newline, level, levelstr, ...) do { \
|
||||||
if(level <= MIN(LOG_LEVEL, curr_log_level)) { \
|
if(level <= (LOG_LEVEL)) { \
|
||||||
if(newline) { \
|
if(newline) { \
|
||||||
LOG_OUTPUT("[%-4s: %-10s] ", levelstr, LOG_MODULE); \
|
LOG_OUTPUT("[%-4s: %-10s] ", levelstr, LOG_MODULE); \
|
||||||
if(LOG_WITH_LOC) { \
|
if(LOG_WITH_LOC) { \
|
||||||
@ -88,7 +112,7 @@
|
|||||||
|
|
||||||
/* Link-layer address */
|
/* Link-layer address */
|
||||||
#define LOG_LLADDR(level, lladdr) do { \
|
#define LOG_LLADDR(level, lladdr) do { \
|
||||||
if(level <= MIN(LOG_LEVEL, curr_log_level)) { \
|
if(level <= (LOG_LEVEL)) { \
|
||||||
if(LOG_WITH_COMPACT_ADDR) { \
|
if(LOG_WITH_COMPACT_ADDR) { \
|
||||||
log_lladdr_compact(lladdr); \
|
log_lladdr_compact(lladdr); \
|
||||||
} else { \
|
} else { \
|
||||||
@ -99,7 +123,7 @@
|
|||||||
|
|
||||||
/* IPv6 address */
|
/* IPv6 address */
|
||||||
#define LOG_6ADDR(level, ipaddr) do { \
|
#define LOG_6ADDR(level, ipaddr) do { \
|
||||||
if(level <= MIN(LOG_LEVEL, curr_log_level)) { \
|
if(level <= (LOG_LEVEL)) { \
|
||||||
if(LOG_WITH_COMPACT_ADDR) { \
|
if(LOG_WITH_COMPACT_ADDR) { \
|
||||||
log_6addr_compact(ipaddr); \
|
log_6addr_compact(ipaddr); \
|
||||||
} else { \
|
} else { \
|
||||||
@ -135,9 +159,6 @@
|
|||||||
#define LOG_INFO_ENABLED (MIN(LOG_LEVEL, curr_log_level) >= LOG_LEVEL_INFO)
|
#define LOG_INFO_ENABLED (MIN(LOG_LEVEL, curr_log_level) >= LOG_LEVEL_INFO)
|
||||||
#define LOG_DBG_ENABLED (MIN(LOG_LEVEL, curr_log_level) >= LOG_LEVEL_DBG)
|
#define LOG_DBG_ENABLED (MIN(LOG_LEVEL, curr_log_level) >= LOG_LEVEL_DBG)
|
||||||
|
|
||||||
/* The current log level */
|
|
||||||
extern int curr_log_level;
|
|
||||||
|
|
||||||
#if NETSTACK_CONF_WITH_IPV6
|
#if NETSTACK_CONF_WITH_IPV6
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,15 +191,17 @@ void log_lladdr_compact(const linkaddr_t *lladdr);
|
|||||||
* Sets a log level at run-time. Logs are included in the firmware via
|
* Sets a log level at run-time. Logs are included in the firmware via
|
||||||
* the compile-time flags in log-conf.h, but this allows to force lower log
|
* the compile-time flags in log-conf.h, but this allows to force lower log
|
||||||
* levels, system-wide.
|
* levels, system-wide.
|
||||||
|
* \param module The target module string descriptor
|
||||||
* \param level The log level
|
* \param level The log level
|
||||||
*/
|
*/
|
||||||
void log_set_level(int level);
|
void log_set_level(const char *module, int level);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current log level.
|
* Returns the current log level.
|
||||||
|
* \param module The target module string descriptor
|
||||||
* \return The current log level
|
* \return The current log level
|
||||||
*/
|
*/
|
||||||
int log_get_level(void);
|
int log_get_level(const char *module);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a textual description of a log level
|
* Returns a textual description of a log level
|
||||||
|
@ -72,7 +72,7 @@ PROCESS_THREAD(node_process, ev, data)
|
|||||||
|
|
||||||
#if WITH_SHELL
|
#if WITH_SHELL
|
||||||
serial_shell_init();
|
serial_shell_init();
|
||||||
log_set_level(LOG_LEVEL_WARN);
|
log_set_level("all", LOG_LEVEL_WARN);
|
||||||
tsch_log_stop();
|
tsch_log_stop();
|
||||||
#endif /* WITH_SHELL */
|
#endif /* WITH_SHELL */
|
||||||
|
|
||||||
|
@ -157,12 +157,12 @@
|
|||||||
#endif /* CONTIKI_TARGET_COOJA */
|
#endif /* CONTIKI_TARGET_COOJA */
|
||||||
|
|
||||||
/* Logging */
|
/* Logging */
|
||||||
#define RPL_LOG_LEVEL LOG_LEVEL_INFO
|
#define LOG_CONF_LEVEL_RPL LOG_LEVEL_INFO
|
||||||
#define TCPIP_LOG_LEVEL LOG_LEVEL_WARN
|
#define LOG_CONF_LEVEL_TCPIP LOG_LEVEL_WARN
|
||||||
#define IPV6_LOG_LEVEL LOG_LEVEL_WARN
|
#define LOG_CONF_LEVEL_IPV6 LOG_LEVEL_WARN
|
||||||
#define SICSLOWPAN_LOG_LEVEL LOG_LEVEL_WARN
|
#define LOG_CONF_LEVEL_6LOWPAN LOG_LEVEL_WARN
|
||||||
#define MAC_LOG_LEVEL LOG_LEVEL_INFO
|
#define LOG_CONF_LEVEL_MAC LOG_LEVEL_INFO
|
||||||
#define FRAMER_LOG_LEVEL LOG_LEVEL_WARN
|
#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_DBG
|
||||||
#define TSCH_LOG_CONF_PER_SLOT 1
|
#define TSCH_LOG_CONF_PER_SLOT 1
|
||||||
|
|
||||||
#endif /* __PROJECT_CONF_H__ */
|
#endif /* __PROJECT_CONF_H__ */
|
||||||
|
@ -39,11 +39,12 @@
|
|||||||
* LOG_LEVEL_INFO Basic info
|
* LOG_LEVEL_INFO Basic info
|
||||||
* LOG_LEVEL_DBG Detailled debug
|
* LOG_LEVEL_DBG Detailled debug
|
||||||
*/
|
*/
|
||||||
#define IPV6_LOG_LEVEL LOG_LEVEL_DBG
|
#define LOG_CONF_LEVEL_IPV6 LOG_LEVEL_DBG
|
||||||
#define SICSLOWPAN_LOG_LEVEL LOG_LEVEL_DBG
|
#define LOG_CONF_LEVEL_RPL LOG_LEVEL_DBG
|
||||||
#define TCPIP_LOG_LEVEL LOG_LEVEL_DBG
|
#define LOG_CONF_LEVEL_6LOWPAN LOG_LEVEL_DBG
|
||||||
#define MAC_LOG_LEVEL LOG_LEVEL_DBG
|
#define LOG_CONF_LEVEL_TCPIP LOG_LEVEL_DBG
|
||||||
#define FRAMER_LOG_LEVEL LOG_LEVEL_DBG
|
#define LOG_CONF_LEVEL_MAC LOG_LEVEL_DBG
|
||||||
|
#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_DBG
|
||||||
|
|
||||||
/* Enable cooja annotations */
|
/* Enable cooja annotations */
|
||||||
#define LOG_CONF_WITH_ANNOTATE 1
|
#define LOG_CONF_WITH_ANNOTATE 1
|
||||||
|
Loading…
Reference in New Issue
Block a user