Contiki-NG
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 /* Prefix all logs with file name and line-of-code */
58 #ifdef LOG_CONF_WITH_LOC
59 #define LOG_WITH_LOC LOG_CONF_WITH_LOC
60 #else /* LOG_CONF_WITH_LOC */
61 #define LOG_WITH_LOC 0
62 #endif /* LOG_CONF_WITH_LOC */
63 
64 /* Prefix all logs with Module name and logging level */
65 #ifdef LOG_CONF_WITH_MODULE_PREFIX
66 #define LOG_WITH_MODULE_PREFIX LOG_CONF_WITH_MODULE_PREFIX
67 #else /* LOG_CONF_WITH_MODULE_PREFIX */
68 #define LOG_WITH_MODULE_PREFIX 1
69 #endif /* LOG_CONF_WITH_MODULE_PREFIX */
70 
71 /* Cooja annotations */
72 #ifdef LOG_CONF_WITH_ANNOTATE
73 #define LOG_WITH_ANNOTATE LOG_CONF_WITH_ANNOTATE
74 #else /* LOG_CONF_WITH_ANNOTATE */
75 #define LOG_WITH_ANNOTATE 0
76 #endif /* LOG_CONF_WITH_ANNOTATE */
77 
78 /* Custom output function -- default is printf */
79 #ifdef LOG_CONF_OUTPUT
80 #define LOG_OUTPUT(...) LOG_CONF_OUTPUT(__VA_ARGS__)
81 #else /* LOG_CONF_OUTPUT */
82 #define LOG_OUTPUT(...) printf(__VA_ARGS__)
83 #endif /* LOG_CONF_OUTPUT */
84 
85 /*
86  * Custom output function to prefix logs with level and module.
87  *
88  * This will only be called when LOG_CONF_WITH_MODULE_PREFIX is enabled and
89  * all implementations should be based on LOG_OUTPUT.
90  *
91  * \param level The log level
92  * \param levelstr The log level as string
93  * \param module The module string descriptor
94  */
95 #ifdef LOG_CONF_OUTPUT_PREFIX
96 #define LOG_OUTPUT_PREFIX(level, levelstr, module) LOG_CONF_OUTPUT_PREFIX(level, levelstr, module)
97 #else /* LOG_CONF_OUTPUT_PREFIX */
98 #define LOG_OUTPUT_PREFIX(level, levelstr, module) LOG_OUTPUT("[%-4s: %-10s] ", levelstr, module)
99 #endif /* LOG_CONF_OUTPUT_PREFIX */
100 
101 /******************************************************************************/
102 /********************* A list of currently supported modules ******************/
103 /******************************************************************************/
104 
105 #ifndef LOG_CONF_LEVEL_RPL
106 #define LOG_CONF_LEVEL_RPL LOG_LEVEL_NONE /* Only for rpl-lite */
107 #endif /* LOG_CONF_LEVEL_RPL */
108 
109 #ifndef LOG_CONF_LEVEL_TCPIP
110 #define LOG_CONF_LEVEL_TCPIP LOG_LEVEL_NONE
111 #endif /* LOG_CONF_LEVEL_TCPIP */
112 
113 #ifndef LOG_CONF_LEVEL_IPV6
114 #define LOG_CONF_LEVEL_IPV6 LOG_LEVEL_NONE
115 #endif /* LOG_CONF_LEVEL_IPV6 */
116 
117 #ifndef LOG_CONF_LEVEL_6LOWPAN
118 #define LOG_CONF_LEVEL_6LOWPAN LOG_LEVEL_NONE
119 #endif /* LOG_CONF_LEVEL_6LOWPAN */
120 
121 #ifndef LOG_CONF_LEVEL_NULLNET
122 #define LOG_CONF_LEVEL_NULLNET LOG_LEVEL_NONE
123 #endif /* LOG_CONF_LEVEL_NULLNET */
124 
125 #ifndef LOG_CONF_LEVEL_MAC
126 #define LOG_CONF_LEVEL_MAC LOG_LEVEL_NONE
127 #endif /* LOG_CONF_LEVEL_MAC */
128 
129 #ifndef LOG_CONF_LEVEL_FRAMER
130 #define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_NONE
131 #endif /* LOG_CONF_LEVEL_FRAMER */
132 
133 #ifndef LOG_CONF_LEVEL_6TOP
134 #define LOG_CONF_LEVEL_6TOP LOG_LEVEL_NONE
135 #endif /* LOG_CONF_LEVEL_6TOP */
136 
137 #ifndef LOG_CONF_LEVEL_COAP
138 #define LOG_CONF_LEVEL_COAP LOG_LEVEL_NONE
139 #endif /* LOG_CONF_LEVEL_COAP */
140 
141 #ifndef LOG_CONF_LEVEL_SNMP
142 #define LOG_CONF_LEVEL_SNMP LOG_LEVEL_NONE
143 #endif /* LOG_CONF_LEVEL_COAP */
144 
145 #ifndef LOG_CONF_LEVEL_LWM2M
146 #define LOG_CONF_LEVEL_LWM2M LOG_LEVEL_NONE
147 #endif /* LOG_CONF_LEVEL_LWM2M */
148 
149 #ifndef LOG_CONF_LEVEL_MAIN
150 #define LOG_CONF_LEVEL_MAIN LOG_LEVEL_INFO
151 #endif /* LOG_CONF_LEVEL_MAIN */
152 
153 #endif /* __LOG_CONF_H__ */
154 
155 /** @} */
156 /** @} */