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