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 /* Color the prefix based on the log level. Disabled by default */
86 #ifdef LOG_CONF_WITH_COLOR
87 #define LOG_WITH_COLOR LOG_CONF_WITH_COLOR
88 #else /* LOG_CONF_WITH_COLOR */
89 #define LOG_WITH_COLOR 0
90 #endif /* LOG_CONF_WITH_COLOR */
91 
92 /*
93  * Custom output function to prefix logs with level and module.
94  *
95  * This will only be called when LOG_CONF_WITH_MODULE_PREFIX is enabled and
96  * all implementations should be based on LOG_OUTPUT.
97  *
98  * \param level The log level
99  * \param levelstr The log level as string
100  * \param module The module string descriptor
101  */
102 #ifdef LOG_CONF_OUTPUT_PREFIX
103 #define LOG_OUTPUT_PREFIX(level, levelstr, module) LOG_CONF_OUTPUT_PREFIX(level, levelstr, module)
104 #else /* LOG_CONF_OUTPUT_PREFIX */
105 #define LOG_OUTPUT_PREFIX(level, levelstr, module) LOG_OUTPUT("[%-4s: %-10s] ", levelstr, module)
106 #endif /* LOG_CONF_OUTPUT_PREFIX */
107 
108 /******************************************************************************/
109 /********************* A list of currently supported modules ******************/
110 /******************************************************************************/
111 
112 #ifndef LOG_CONF_LEVEL_RPL
113 #define LOG_CONF_LEVEL_RPL LOG_LEVEL_NONE /* Only for rpl-lite */
114 #endif /* LOG_CONF_LEVEL_RPL */
115 
116 #ifndef LOG_CONF_LEVEL_TCPIP
117 #define LOG_CONF_LEVEL_TCPIP LOG_LEVEL_NONE
118 #endif /* LOG_CONF_LEVEL_TCPIP */
119 
120 #ifndef LOG_CONF_LEVEL_IPV6
121 #define LOG_CONF_LEVEL_IPV6 LOG_LEVEL_NONE
122 #endif /* LOG_CONF_LEVEL_IPV6 */
123 
124 #ifndef LOG_CONF_LEVEL_6LOWPAN
125 #define LOG_CONF_LEVEL_6LOWPAN LOG_LEVEL_NONE
126 #endif /* LOG_CONF_LEVEL_6LOWPAN */
127 
128 #ifndef LOG_CONF_LEVEL_NULLNET
129 #define LOG_CONF_LEVEL_NULLNET LOG_LEVEL_NONE
130 #endif /* LOG_CONF_LEVEL_NULLNET */
131 
132 #ifndef LOG_CONF_LEVEL_MAC
133 #define LOG_CONF_LEVEL_MAC LOG_LEVEL_NONE
134 #endif /* LOG_CONF_LEVEL_MAC */
135 
136 #ifndef LOG_CONF_LEVEL_FRAMER
137 #define LOG_CONF_LEVEL_FRAMER LOG_LEVEL_NONE
138 #endif /* LOG_CONF_LEVEL_FRAMER */
139 
140 #ifndef LOG_CONF_LEVEL_6TOP
141 #define LOG_CONF_LEVEL_6TOP LOG_LEVEL_NONE
142 #endif /* LOG_CONF_LEVEL_6TOP */
143 
144 #ifndef LOG_CONF_LEVEL_COAP
145 #define LOG_CONF_LEVEL_COAP LOG_LEVEL_NONE
146 #endif /* LOG_CONF_LEVEL_COAP */
147 
148 #ifndef LOG_CONF_LEVEL_SNMP
149 #define LOG_CONF_LEVEL_SNMP LOG_LEVEL_NONE
150 #endif /* LOG_CONF_LEVEL_COAP */
151 
152 #ifndef LOG_CONF_LEVEL_LWM2M
153 #define LOG_CONF_LEVEL_LWM2M LOG_LEVEL_NONE
154 #endif /* LOG_CONF_LEVEL_LWM2M */
155 
156 #ifndef LOG_CONF_LEVEL_MAIN
157 #define LOG_CONF_LEVEL_MAIN LOG_LEVEL_INFO
158 #endif /* LOG_CONF_LEVEL_MAIN */
159 
160 #endif /* __LOG_CONF_H__ */
161 
162 /** @} */
163 /** @} */