Contiki-NG
Loading...
Searching...
No Matches
log-conf.h
Go to the documentation of this file.
1/*
2* Copyright (c) 2017, Inria.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the Institute nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * This file is part of the Contiki operating system.
30 *
31 */
32
33/**
34 * \file
35 * Default log levels for a number of modules
36 * \author
37 * Simon Duquennoy <simon.duquennoy@inria.fr>
38 */
39
40/** \addtogroup sys
41 * @{ */
42
43/** \addtogroup log
44* @{ */
45
46#ifndef LOG_CONF_H_
47#define LOG_CONF_H_
48
49/* Log only the last 16 bytes of link-layer and IPv6 addresses (or, if)
50 * the deployment module is enabled, the node IDs */
51#ifdef LOG_CONF_WITH_COMPACT_ADDR
52#define LOG_WITH_COMPACT_ADDR LOG_CONF_WITH_COMPACT_ADDR
53#else /* LOG_CONF_WITH_COMPACT_ADDR */
54#define LOG_WITH_COMPACT_ADDR 0
55#endif /* LOG_CONF_WITH_COMPACT_ADDR */
56
57/* Log bytes as compact hex dump or with whitespace between hexcharacters */
58#ifdef LOG_CONF_WITH_COMPACT_BYTES
59#define LOG_WITH_COMPACT_BYTES LOG_CONF_WITH_COMPACT_BYTES
60#else /* LOG_CONF_WITH_COMPACT_BYTES */
61#define LOG_WITH_COMPACT_BYTES 1
62#endif /* LOG_CONF_WITH_COMPACT_BYTES */
63
64/* Prefix all logs with file name and line-of-code */
65#ifdef LOG_CONF_WITH_LOC
66#define LOG_WITH_LOC LOG_CONF_WITH_LOC
67#else /* LOG_CONF_WITH_LOC */
68#define LOG_WITH_LOC 0
69#endif /* LOG_CONF_WITH_LOC */
70
71/* Prefix all logs with Module name and logging level */
72#ifdef LOG_CONF_WITH_MODULE_PREFIX
73#define LOG_WITH_MODULE_PREFIX LOG_CONF_WITH_MODULE_PREFIX
74#else /* LOG_CONF_WITH_MODULE_PREFIX */
75#define LOG_WITH_MODULE_PREFIX 1
76#endif /* LOG_CONF_WITH_MODULE_PREFIX */
77
78/* Cooja annotations */
79#ifdef LOG_CONF_WITH_ANNOTATE
80#define LOG_WITH_ANNOTATE LOG_CONF_WITH_ANNOTATE
81#else /* LOG_CONF_WITH_ANNOTATE */
82#define LOG_WITH_ANNOTATE 0
83#endif /* LOG_CONF_WITH_ANNOTATE */
84
85/* Custom output function -- default is printf */
86#ifdef LOG_CONF_OUTPUT
87#define LOG_OUTPUT(...) LOG_CONF_OUTPUT(__VA_ARGS__)
88#else /* LOG_CONF_OUTPUT */
89#define LOG_OUTPUT(...) printf(__VA_ARGS__)
90#endif /* LOG_CONF_OUTPUT */
91
92/* Color the prefix based on the log level. Disabled by default */
93#ifdef LOG_CONF_WITH_COLOR
94#define LOG_WITH_COLOR LOG_CONF_WITH_COLOR
95#else /* LOG_CONF_WITH_COLOR */
96#define LOG_WITH_COLOR 0
97#endif /* LOG_CONF_WITH_COLOR */
98
99/*
100 * Custom output function to prefix logs with level and module.
101 *
102 * This will only be called when LOG_CONF_WITH_MODULE_PREFIX is enabled and
103 * all implementations should be based on LOG_OUTPUT.
104 *
105 * \param level The log level
106 * \param levelstr The log level as string
107 * \param module The module string descriptor
108 */
109#ifdef LOG_CONF_OUTPUT_PREFIX
110#define LOG_OUTPUT_PREFIX(level, levelstr, module) LOG_CONF_OUTPUT_PREFIX(level, levelstr, module)
111#else /* LOG_CONF_OUTPUT_PREFIX */
112#define LOG_OUTPUT_PREFIX(level, levelstr, module) LOG_OUTPUT("[%-4s: %-10s] ", levelstr, module)
113#endif /* LOG_CONF_OUTPUT_PREFIX */
114
115/******************************************************************************/
116/********************* A list of currently supported modules ******************/
117/******************************************************************************/
118
119#ifndef LOG_CONF_LEVEL_RPL
120#define LOG_CONF_LEVEL_RPL LOG_LEVEL_NONE /* Only for rpl-lite */
121#endif /* LOG_CONF_LEVEL_RPL */
122
123#ifndef LOG_CONF_LEVEL_TCPIP
124#define LOG_CONF_LEVEL_TCPIP LOG_LEVEL_NONE
125#endif /* LOG_CONF_LEVEL_TCPIP */
126
127#ifndef LOG_CONF_LEVEL_IPV6
128#define LOG_CONF_LEVEL_IPV6 LOG_LEVEL_NONE
129#endif /* LOG_CONF_LEVEL_IPV6 */
130
131#ifndef LOG_CONF_LEVEL_6LOWPAN
132#define LOG_CONF_LEVEL_6LOWPAN LOG_LEVEL_NONE
133#endif /* LOG_CONF_LEVEL_6LOWPAN */
134
135#ifndef LOG_CONF_LEVEL_NULLNET
136#define LOG_CONF_LEVEL_NULLNET LOG_LEVEL_NONE
137#endif /* LOG_CONF_LEVEL_NULLNET */
138
139#ifndef LOG_CONF_LEVEL_MAC
140#define LOG_CONF_LEVEL_MAC LOG_LEVEL_NONE
141#endif /* LOG_CONF_LEVEL_MAC */
142
143#ifndef LOG_CONF_LEVEL_FRAMER
144#define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_NONE
145#endif /* LOG_CONF_LEVEL_FRAMER */
146
147#ifndef LOG_CONF_LEVEL_6TOP
148#define LOG_CONF_LEVEL_6TOP LOG_LEVEL_NONE
149#endif /* LOG_CONF_LEVEL_6TOP */
150
151#ifndef LOG_CONF_LEVEL_COAP
152#define LOG_CONF_LEVEL_COAP LOG_LEVEL_NONE
153#endif /* LOG_CONF_LEVEL_COAP */
154
155#ifndef LOG_CONF_LEVEL_DTLS
156#define LOG_CONF_LEVEL_DTLS LOG_LEVEL_NONE
157#endif /* LOG_CONF_LEVEL_DTLS */
158
159#ifndef LOG_CONF_LEVEL_SNMP
160#define LOG_CONF_LEVEL_SNMP LOG_LEVEL_NONE
161#endif /* LOG_CONF_LEVEL_SNMP */
162
163#ifndef LOG_CONF_LEVEL_LWM2M
164#define LOG_CONF_LEVEL_LWM2M LOG_LEVEL_NONE
165#endif /* LOG_CONF_LEVEL_LWM2M */
166
167#ifndef LOG_CONF_LEVEL_MAIN
168#define LOG_CONF_LEVEL_MAIN LOG_LEVEL_INFO
169#endif /* LOG_CONF_LEVEL_MAIN */
170
171#ifndef LOG_CONF_LEVEL_SYS
172#define LOG_CONF_LEVEL_SYS LOG_LEVEL_NONE
173#endif /* LOG_CONF_LEVEL_SYS */
174
175#endif /* LOG_CONF_H_ */
176
177/** @} */
178/** @} */